From ae224c6252097545aa01e2be71f91e33df04b998 Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 13 Dec 2001 01:31:23 +0000 Subject: [PATCH] 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 --- .../java/com/samskivert/test/TestUtil.java | 23 +++++-------------- .../samskivert/xml/SetPropertyFieldsRule.java | 12 ++++++---- .../servlet/SiteResourceLoaderTest.java | 8 +++---- .../com/samskivert/util/HashIntMapTest.java | 3 +-- .../com/samskivert/util/IntListUtilTest.java | 3 +-- .../com/samskivert/xml/SetFieldRuleTest.java | 5 ++-- 6 files changed, 23 insertions(+), 31 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/test/TestUtil.java b/projects/samskivert/src/java/com/samskivert/test/TestUtil.java index 87422227..eef4759a 100644 --- a/projects/samskivert/src/java/com/samskivert/test/TestUtil.java +++ b/projects/samskivert/src/java/com/samskivert/test/TestUtil.java @@ -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 test_dir which is the - * path to the project top-level test directory and that the top-level - * test directory contains a subdirectory named rsrc, 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 - * rsrc 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 rsrc. */ - protected static final String RESOURCE_DIR = "rsrc"; } diff --git a/projects/samskivert/src/java/com/samskivert/xml/SetPropertyFieldsRule.java b/projects/samskivert/src/java/com/samskivert/xml/SetPropertyFieldsRule.java index cd12838e..fb291e66 100644 --- a/projects/samskivert/src/java/com/samskivert/xml/SetPropertyFieldsRule.java +++ b/projects/samskivert/src/java/com/samskivert/xml/SetPropertyFieldsRule.java @@ -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); diff --git a/projects/samskivert/tests/src/java/com/samskivert/servlet/SiteResourceLoaderTest.java b/projects/samskivert/tests/src/java/com/samskivert/servlet/SiteResourceLoaderTest.java index 7567c4d2..d394a16f 100644 --- a/projects/samskivert/tests/src/java/com/samskivert/servlet/SiteResourceLoaderTest.java +++ b/projects/samskivert/tests/src/java/com/samskivert/servlet/SiteResourceLoaderTest.java @@ -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); } diff --git a/projects/samskivert/tests/src/java/com/samskivert/util/HashIntMapTest.java b/projects/samskivert/tests/src/java/com/samskivert/util/HashIntMapTest.java index 9b74741c..9cc4fb55 100644 --- a/projects/samskivert/tests/src/java/com/samskivert/util/HashIntMapTest.java +++ b/projects/samskivert/tests/src/java/com/samskivert/util/HashIntMapTest.java @@ -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 { diff --git a/projects/samskivert/tests/src/java/com/samskivert/util/IntListUtilTest.java b/projects/samskivert/tests/src/java/com/samskivert/util/IntListUtilTest.java index 40b3a304..63bc29ce 100644 --- a/projects/samskivert/tests/src/java/com/samskivert/util/IntListUtilTest.java +++ b/projects/samskivert/tests/src/java/com/samskivert/util/IntListUtilTest.java @@ -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 { diff --git a/projects/samskivert/tests/src/java/com/samskivert/xml/SetFieldRuleTest.java b/projects/samskivert/tests/src/java/com/samskivert/xml/SetFieldRuleTest.java index 177b7b40..fb46cfad 100644 --- a/projects/samskivert/tests/src/java/com/samskivert/xml/SetFieldRuleTest.java +++ b/projects/samskivert/tests/src/java/com/samskivert/xml/SetFieldRuleTest.java @@ -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();