Modified TestUtil not to prepend 'rsrc' to test resource file paths

because it's silly. Prepend your own damned 'rsrc' if you want to look in
that directory.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@510 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2001-12-13 01:31:23 +00:00
parent 2df834bc75
commit ae224c6252
6 changed files with 23 additions and 31 deletions
@@ -1,5 +1,5 @@
//
// $Id: TestUtil.java,v 1.1 2001/11/05 09:13:24 mdb Exp $
// $Id: TestUtil.java,v 1.2 2001/12/13 01:31:22 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -38,15 +38,12 @@ public class TestUtil
* Returns the path via which a test-related resource can be loaded.
* This assumes that the mechanism used to invoke the test code
* defined a system property named <code>test_dir</code> which is the
* path to the project top-level test directory and that the top-level
* test directory contains a subdirectory named <code>rsrc</code>, to
* which the supplied path will be appended to obtain the path to the
* resource.
* path to the project top-level test directory, to which the supplied
* path will be appended to obtain the path to the resource.
*
* @param path the path to the resource, relative to the
* <code>rsrc</code> directory in the top-level test directory. It
* should contain a leading slash but one will be provided if
* necessary.
* @param path the path to the resource, relative to the the top-level
* test directory. It should contain a leading slash but one will be
* provided if necessary.
*/
public static String getResourcePath (String path)
{
@@ -59,10 +56,6 @@ public class TestUtil
}
StringBuffer rpath = new StringBuffer(testdir);
if (rpath.charAt(rpath.length()-1) != '/') {
rpath.append("/");
}
rpath.append(RESOURCE_DIR);
if (!path.startsWith("/")) {
rpath.append("/");
}
@@ -88,8 +81,4 @@ public class TestUtil
// from which to load it
return new FileInputStream(getResourcePath(path));
}
/** The name of the directory in the top-level test directory that
* contains test-related resources. This is <code>rsrc</code>. */
protected static final String RESOURCE_DIR = "rsrc";
}
@@ -1,5 +1,5 @@
//
// $Id: SetPropertyFieldsRule.java,v 1.1 2001/11/26 23:44:40 mdb Exp $
// $Id: SetPropertyFieldsRule.java,v 1.2 2001/12/13 01:31:23 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Walter Korman
@@ -58,10 +58,14 @@ public class SetPropertyFieldsRule extends Rule
}
// look for a public field with this name
Field field = topclass.getField(name);
if (field == null) {
Field field = null;
try {
field = topclass.getField(name);
} catch (NoSuchFieldException nsfe) {
digester.log("Skipping property '" + name +
"' for which there is no field.");
continue;
}
}
// convert the value into the appropriate object type
String valstr = attrs.getValue(i);
@@ -1,5 +1,5 @@
//
// $Id: SiteResourceLoaderTest.java,v 1.3 2001/11/08 01:57:18 mdb Exp $
// $Id: SiteResourceLoaderTest.java,v 1.4 2001/12/13 01:31:23 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -56,7 +56,7 @@ public class SiteResourceLoaderTest extends TestCase
// now create a resource loader and load up some resources
SiteResourceLoader loader = new SiteResourceLoader(
ident, TestUtil.getResourcePath("servlet/srl"));
ident, TestUtil.getResourcePath("rsrc/servlet/srl"));
try {
testResourceLoader(SiteIdentifier.DEFAULT_SITE_ID,
@@ -80,7 +80,7 @@ public class SiteResourceLoaderTest extends TestCase
appendResource(siteId, gen, loader, "/footer.txt");
StringBuffer cmp = new StringBuffer();
compareFile = "servlet/srl/" + compareFile;
compareFile = "rsrc/servlet/srl/" + compareFile;
InputStream cin = TestUtil.getResourceAsStream(compareFile);
if (cin == null) {
throw new IOException("Unable to load " + compareFile);
@@ -110,7 +110,7 @@ public class SiteResourceLoaderTest extends TestCase
if (rin == null) {
// fall back to the "default" resource if we couldn't load a
// site-specific version
String rpath = "servlet/srl/default/" + path;
String rpath = "rsrc/servlet/srl/default/" + path;
rpath = TestUtil.getResourcePath(rpath);
rin = new FileInputStream(rpath);
}
@@ -1,5 +1,5 @@
//
// $Id: HashIntMapTest.java,v 1.1 2001/11/26 19:34:31 mdb Exp $
// $Id: HashIntMapTest.java,v 1.2 2001/12/13 01:31:23 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -26,7 +26,6 @@ import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.Log;
import com.samskivert.test.TestUtil;
public class HashIntMapTest extends TestCase
{
@@ -1,5 +1,5 @@
//
// $Id: IntListUtilTest.java,v 1.1 2001/11/06 02:13:29 mdb Exp $
// $Id: IntListUtilTest.java,v 1.2 2001/12/13 01:31:23 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -24,7 +24,6 @@ import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.Log;
import com.samskivert.test.TestUtil;
public class IntListUtilTest extends TestCase
{
@@ -1,5 +1,5 @@
//
// $Id: SetFieldRuleTest.java,v 1.1 2001/11/17 03:45:52 mdb Exp $
// $Id: SetFieldRuleTest.java,v 1.2 2001/12/13 01:31:23 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -78,7 +78,8 @@ public class SetFieldRuleTest extends TestCase
new SetFieldRule(digester, "stringArrayField"));
try {
String xmlpath = TestUtil.getResourcePath("xml/setfieldtest.xml");
String xmlpath =
TestUtil.getResourcePath("rsrc/xml/setfieldtest.xml");
InputStream input = new FileInputStream(xmlpath);
digester.parse(input);
input.close();