Handle test resources in a more standard way as well.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2810 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert
2010-08-27 00:51:49 +00:00
parent 83e1c95c34
commit 08fa16d2d8
20 changed files with 13 additions and 12 deletions
+4 -2
View File
@@ -40,6 +40,9 @@
<fileset dir="${src.dir}" includes="**/*.properties"/> <fileset dir="${src.dir}" includes="**/*.properties"/>
<fileset dir="${src.dir}" includes="**/*.tmpl"/> <fileset dir="${src.dir}" includes="**/*.tmpl"/>
</copy> </copy>
<copy todir="${tclasses.dir}">
<fileset dir="src/test/resources" includes="**"/>
</copy>
<copy todir="${deploy.dir}/lib" flatten="true"> <copy todir="${deploy.dir}/lib" flatten="true">
<fileset refid="${app.name}.libs"/> <fileset refid="${app.name}.libs"/>
</copy> </copy>
@@ -142,11 +145,10 @@
<classpath> <classpath>
<pathelement location="${classes.dir}"/> <pathelement location="${classes.dir}"/>
<pathelement location="${tclasses.dir}"/> <pathelement location="${tclasses.dir}"/>
<pathelement location="${basedir}"/> <!-- for rsrc/ -->
<fileset dir="${deploy.dir}/lib" includes="*.jar"/> <fileset dir="${deploy.dir}/lib" includes="*.jar"/>
<fileset dir="lib/test" includes="*.jar"/> <fileset dir="lib/test" includes="*.jar"/>
</classpath> </classpath>
<sysproperty key="test_dir" value="${basedir}"/> <sysproperty key="test_dir" value="${tclasses.dir}"/>
<formatter type="brief" usefile="false"/> <formatter type="brief" usefile="false"/>
<batchtest> <batchtest>
<fileset dir="${test.dir}"> <fileset dir="${test.dir}">
@@ -44,7 +44,7 @@ public class SiteResourceLoaderTest
// 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("rsrc/servlet/srl")); ident, TestUtil.getResourcePath("servlet/srl"));
try { try {
testResourceLoader(SiteIdentifier.DEFAULT_SITE_ID, testResourceLoader(SiteIdentifier.DEFAULT_SITE_ID,
@@ -67,7 +67,7 @@ public class SiteResourceLoaderTest
appendResource(siteId, gen, loader, "/footer.txt"); appendResource(siteId, gen, loader, "/footer.txt");
StringBuffer cmp = new StringBuffer(); StringBuffer cmp = new StringBuffer();
compareFile = "rsrc/servlet/srl/" + compareFile; compareFile = "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);
@@ -96,7 +96,7 @@ public class SiteResourceLoaderTest
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 = "rsrc/servlet/srl/default/" + path; String rpath = "servlet/srl/default/" + path;
rpath = TestUtil.getResourcePath(rpath); rpath = TestUtil.getResourcePath(rpath);
rin = new FileInputStream(rpath); rin = new FileInputStream(rpath);
} }
@@ -34,7 +34,7 @@ public class ConfigTest
@Test @Test
public void runTest () public void runTest ()
{ {
PrefsConfig config = new PrefsConfig("rsrc/util/test"); PrefsConfig config = new PrefsConfig("util/test");
System.out.println("prop1: " + config.getValue("prop1", 1)); System.out.println("prop1: " + config.getValue("prop1", 1));
System.out.println("prop2: " + config.getValue("prop2", "two")); System.out.println("prop2: " + config.getValue("prop2", "two"));
@@ -70,7 +70,7 @@ public class ConfigUtilTest
public void runTest () public void runTest ()
{ {
try { try {
String path = "rsrc/util/test.properties"; String path = "util/test.properties";
Properties props = ConfigUtil.loadInheritedProperties(path); Properties props = ConfigUtil.loadInheritedProperties(path);
assertTrue("props valid", props.toString().equals(DUMP)); assertTrue("props valid", props.toString().equals(DUMP));
@@ -42,7 +42,7 @@ public class VelocityTest
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
VelocityEngine engine = VelocityUtil.createEngine(); VelocityEngine engine = VelocityUtil.createEngine();
engine.mergeTemplate("com/samskivert/velocity/tests/test.tmpl", "UTF-8", ctx, writer); engine.mergeTemplate("velocity/test.tmpl", "UTF-8", ctx, writer);
assertTrue(writer.toString().trim().equals("Hello bar.")); assertTrue(writer.toString().trim().equals("Hello bar."));
} }
@@ -67,8 +67,7 @@ public class SetFieldRuleTest
digester.addRule("object/stringArrayField", new SetFieldRule("stringArrayField")); digester.addRule("object/stringArrayField", new SetFieldRule("stringArrayField"));
try { try {
String xmlpath = String xmlpath = TestUtil.getResourcePath("xml/setfieldtest.xml");
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();
@@ -3,7 +3,7 @@
# #
# A test properties file # A test properties file
_extends = rsrc/util/grandparent.properties _extends = util/grandparent.properties
prop1 = 13 prop1 = 13
prop2 = nine prop2 = nine
@@ -3,7 +3,7 @@
# #
# A test properties file # A test properties file
_extends = rsrc/util/parent.properties _extends = util/parent.properties
prop1 = 25 prop1 = 25
prop2 = twenty five prop2 = twenty five