Various unit test fixes.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1748 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2006-01-03 21:49:09 +00:00
parent ca8a69f9e1
commit d87f5f635f
5 changed files with 20 additions and 23 deletions
+6 -9
View File
@@ -1,12 +1,8 @@
<!-- build configuration --> <!-- build configuration -->
<project name="samskivert tests" default="test" basedir="."> <project name="samskivert tests" default="test" basedir=".">
<!-- we want to access the environment --> <!-- we need to do this to avoid conflicts with the XML jar files loaded -->
<property environment="env"/> <!-- to run ant versus the XML jar files we load for our tests -->
<property name="java.libraries" value="${env.JAVA_LIBS}"/>
<!-- we need to do this to avoid conflicts with the XML jar files loaded
to run ant versus the XML jar files we load for our tests -->
<property name="junit.fork" value="true"/> <property name="junit.fork" value="true"/>
<!-- things you probably don't want to change --> <!-- things you probably don't want to change -->
@@ -20,7 +16,6 @@
<pathelement location="${deploy.dir}/classes"/> <pathelement location="${deploy.dir}/classes"/>
<fileset dir="../lib" includes="**/*.jar"/> <fileset dir="../lib" includes="**/*.jar"/>
<fileset dir="lib" includes="**/*.jar"/> <fileset dir="lib" includes="**/*.jar"/>
<fileset dir="${java.libraries}" includes="**/*.jar"/>
</path> </path>
<!-- prepares the application directories --> <!-- prepares the application directories -->
@@ -51,7 +46,9 @@
<!-- run the tests --> <!-- run the tests -->
<target name="test" depends="compile" description="Run tests."> <target name="test" depends="compile" description="Run tests.">
<junit printsummary="no" haltonfailure="yes" fork="${junit.fork}"> <taskdef name="unit" classpathref="classpath"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
<unit printsummary="no" haltonfailure="yes" fork="${junit.fork}">
<classpath refid="classpath"/> <classpath refid="classpath"/>
<sysproperty key="test_dir" value="${test.dir}"/> <sysproperty key="test_dir" value="${test.dir}"/>
<formatter type="brief" usefile="false"/> <formatter type="brief" usefile="false"/>
@@ -60,7 +57,7 @@
<include name="**/*Test.java"/> <include name="**/*Test.java"/>
</fileset> </fileset>
</batchtest> </batchtest>
</junit> </unit>
</target> </target>
</project> </project>
@@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletRequest;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.commons.io.StreamUtils; import org.apache.commons.io.IOUtils;
import com.samskivert.test.TestUtil; import com.samskivert.test.TestUtil;
@@ -78,7 +78,7 @@ public class SiteResourceLoaderTest extends TestCase
if (cin == null) { if (cin == null) {
throw new IOException("Unable to load " + compareFile); throw new IOException("Unable to load " + compareFile);
} }
cmp.append(StreamUtils.streamAsString(cin)); cmp.append(IOUtils.toString(cin));
// Log.info("Loaded resources [cmp=" + compareFile + "]: " + gen); // Log.info("Loaded resources [cmp=" + compareFile + "]: " + gen);
@@ -107,7 +107,7 @@ public class SiteResourceLoaderTest extends TestCase
rpath = TestUtil.getResourcePath(rpath); rpath = TestUtil.getResourcePath(rpath);
rin = new FileInputStream(rpath); rin = new FileInputStream(rpath);
} }
buffer.append(StreamUtils.streamAsString(rin)); buffer.append(IOUtils.toString(rin));
} }
public static Test suite () public static Test suite ()
@@ -130,6 +130,6 @@ public class HashIntMapTest extends TestCase
} }
protected static final String TEST1 = protected static final String TEST1 =
"(19, 18, 17, 16, 15, 14, 13, 12, 11, 10)"; "(15, 16, 14, 19, 11, 18, 12, 17, 13, 10)";
protected static final String TEST2 = "(11, 10)"; protected static final String TEST2 = "(11, 10)";
} }
@@ -31,7 +31,7 @@ public class QuickSortTest extends TestCase
for (int d = 1; d <= 100; d++) { for (int d = 1; d <= 100; d++) {
for (int n = 0; n < 100; n++) { for (int n = 0; n < 100; n++) {
a[n] = new Integer(n / d); a[n] = new Integer(n / d);
QuickSort.csort (a, 0, n, comp); QuickSort.sort(a, 0, n, comp);
for (int i = 0; i <= n; i++) { for (int i = 0; i <= n; i++) {
assertTrue("Failure for up " + n + "/" + d, assertTrue("Failure for up " + n + "/" + d,
a[i].intValue() == i / d); a[i].intValue() == i / d);
@@ -45,7 +45,7 @@ public class QuickSortTest extends TestCase
for (int i = 0; i <= n; i++) { for (int i = 0; i <= n; i++) {
a[i] = new Integer((n - i) / d); a[i] = new Integer((n - i) / d);
} }
QuickSort.csort (a, 0, n, comp); QuickSort.sort(a, 0, n, comp);
for (int i = 0; i <= n; i++) { for (int i = 0; i <= n; i++) {
assertTrue("Failure for down " + n + "/" + d, assertTrue("Failure for down " + n + "/" + d,
a[i].intValue() == i / d); a[i].intValue() == i / d);
@@ -61,20 +61,20 @@ public class QuickSortTest extends TestCase
a[i] = new Integer(rand(30000)); a[i] = new Integer(rand(30000));
} }
QuickSort.csort (a, 0, n, comp); QuickSort.sort(a, 0, n, comp);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assertTrue("Failure for random " + n, assertTrue("Failure for random " + n,
a[i].intValue() <= a[i+1].intValue()); a[i].intValue() <= a[i+1].intValue());
} }
QuickSort.csort (a, 0, n, comp); QuickSort.sort(a, 0, n, comp);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assertTrue("Failure for random " + n + " (resort)", assertTrue("Failure for random " + n + " (resort)",
a[i].intValue() <= a[i+1].intValue()); a[i].intValue() <= a[i+1].intValue());
} }
a[rand(n+1)] = new Integer(rand(30000)); a[rand(n+1)] = new Integer(rand(30000));
QuickSort.csort (a, 0, n, comp); QuickSort.sort(a, 0, n, comp);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assertTrue("Failure for random " + n + " (resort 2)", assertTrue("Failure for random " + n + " (resort 2)",
a[i].intValue() <= a[i+1].intValue()); a[i].intValue() <= a[i+1].intValue());
@@ -66,15 +66,15 @@ public class SetFieldRuleTest extends TestCase
// set up some rules // set up some rules
digester.addRule("object/intField", digester.addRule("object/intField",
new SetFieldRule(digester, "intField")); new SetFieldRule("intField"));
digester.addRule("object/stringField", digester.addRule("object/stringField",
new SetFieldRule(digester, "stringField")); new SetFieldRule("stringField"));
digester.addRule("object/integerField", digester.addRule("object/integerField",
new SetFieldRule(digester, "integerField")); new SetFieldRule("integerField"));
digester.addRule("object/intArrayField", digester.addRule("object/intArrayField",
new SetFieldRule(digester, "intArrayField")); new SetFieldRule("intArrayField"));
digester.addRule("object/stringArrayField", digester.addRule("object/stringArrayField",
new SetFieldRule(digester, "stringArrayField")); new SetFieldRule("stringArrayField"));
try { try {
String xmlpath = String xmlpath =