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 // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -38,15 +38,12 @@ public class TestUtil
* Returns the path via which a test-related resource can be loaded. * Returns the path via which a test-related resource can be loaded.
* This assumes that the mechanism used to invoke the test code * This assumes that the mechanism used to invoke the test code
* defined a system property named <code>test_dir</code> which is the * 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 * path to the project top-level test directory, to which the supplied
* test directory contains a subdirectory named <code>rsrc</code>, to * path will be appended to obtain the path to the resource.
* which the supplied path will be appended to obtain the path to the
* resource.
* *
* @param path the path to the resource, relative to the * @param path the path to the resource, relative to the the top-level
* <code>rsrc</code> directory in the top-level test directory. It * test directory. It should contain a leading slash but one will be
* should contain a leading slash but one will be provided if * provided if necessary.
* necessary.
*/ */
public static String getResourcePath (String path) public static String getResourcePath (String path)
{ {
@@ -59,10 +56,6 @@ public class TestUtil
} }
StringBuffer rpath = new StringBuffer(testdir); StringBuffer rpath = new StringBuffer(testdir);
if (rpath.charAt(rpath.length()-1) != '/') {
rpath.append("/");
}
rpath.append(RESOURCE_DIR);
if (!path.startsWith("/")) { if (!path.startsWith("/")) {
rpath.append("/"); rpath.append("/");
} }
@@ -88,8 +81,4 @@ public class TestUtil
// from which to load it // from which to load it
return new FileInputStream(getResourcePath(path)); 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 // samskivert library - useful routines for java programs
// Copyright (C) 2001 Walter Korman // Copyright (C) 2001 Walter Korman
@@ -58,8 +58,12 @@ public class SetPropertyFieldsRule extends Rule
} }
// look for a public field with this name // look for a public field with this name
Field field = topclass.getField(name); Field field = null;
if (field == null) { try {
field = topclass.getField(name);
} catch (NoSuchFieldException nsfe) {
digester.log("Skipping property '" + name +
"' for which there is no field.");
continue; continue;
} }
@@ -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 // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -56,7 +56,7 @@ public class SiteResourceLoaderTest extends TestCase
// now create a resource loader and load up some resources // now create a resource loader and load up some resources
SiteResourceLoader loader = new SiteResourceLoader( SiteResourceLoader loader = new SiteResourceLoader(
ident, TestUtil.getResourcePath("servlet/srl")); ident, TestUtil.getResourcePath("rsrc/servlet/srl"));
try { try {
testResourceLoader(SiteIdentifier.DEFAULT_SITE_ID, testResourceLoader(SiteIdentifier.DEFAULT_SITE_ID,
@@ -80,7 +80,7 @@ public class SiteResourceLoaderTest extends TestCase
appendResource(siteId, gen, loader, "/footer.txt"); appendResource(siteId, gen, loader, "/footer.txt");
StringBuffer cmp = new StringBuffer(); StringBuffer cmp = new StringBuffer();
compareFile = "servlet/srl/" + compareFile; compareFile = "rsrc/servlet/srl/" + compareFile;
InputStream cin = TestUtil.getResourceAsStream(compareFile); InputStream cin = TestUtil.getResourceAsStream(compareFile);
if (cin == null) { if (cin == null) {
throw new IOException("Unable to load " + compareFile); throw new IOException("Unable to load " + compareFile);
@@ -110,7 +110,7 @@ public class SiteResourceLoaderTest extends TestCase
if (rin == null) { if (rin == null) {
// fall back to the "default" resource if we couldn't load a // fall back to the "default" resource if we couldn't load a
// site-specific version // site-specific version
String rpath = "servlet/srl/default/" + path; String rpath = "rsrc/servlet/srl/default/" + path;
rpath = TestUtil.getResourcePath(rpath); rpath = TestUtil.getResourcePath(rpath);
rin = new FileInputStream(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 // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -26,7 +26,6 @@ import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.samskivert.Log; import com.samskivert.Log;
import com.samskivert.test.TestUtil;
public class HashIntMapTest extends TestCase 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 // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -24,7 +24,6 @@ import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.samskivert.Log; import com.samskivert.Log;
import com.samskivert.test.TestUtil;
public class IntListUtilTest extends TestCase 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 // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -78,7 +78,8 @@ public class SetFieldRuleTest extends TestCase
new SetFieldRule(digester, "stringArrayField")); new SetFieldRule(digester, "stringArrayField"));
try { try {
String xmlpath = TestUtil.getResourcePath("xml/setfieldtest.xml"); String xmlpath =
TestUtil.getResourcePath("rsrc/xml/setfieldtest.xml");
InputStream input = new FileInputStream(xmlpath); InputStream input = new FileInputStream(xmlpath);
digester.parse(input); digester.parse(input);
input.close(); input.close();