Converted all tests to JUnit 4. Nixed vestigial Velocity-related test class.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2809 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert
2010-08-27 00:34:13 +00:00
parent 91639537f0
commit 83e1c95c34
17 changed files with 60 additions and 476 deletions
@@ -28,20 +28,15 @@ import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
import com.samskivert.io.StreamUtil;
import com.samskivert.test.TestUtil;
public class SiteResourceLoaderTest extends TestCase
public class SiteResourceLoaderTest
{
public SiteResourceLoaderTest ()
{
super(SiteResourceLoaderTest.class.getName());
}
@Override
@Test
public void runTest ()
{
// we need to fake a couple of things to get the test to work
@@ -108,11 +103,6 @@ public class SiteResourceLoaderTest extends TestCase
buffer.append(StreamUtil.toString(rin, "UTF-8"));
}
public static Test suite ()
{
return new SiteResourceLoaderTest();
}
public static class TestSiteIdentifier implements SiteIdentifier
{
public int identifySite (HttpServletRequest req)
@@ -24,19 +24,14 @@ import java.awt.Point;
import java.util.ArrayList;
import java.util.Random;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
import com.samskivert.swing.util.ProximityTracker;
public class ProximityTrackerTest extends TestCase
public class ProximityTrackerTest
{
public ProximityTrackerTest ()
{
super(ProximityTrackerTest.class.getName());
}
@Override
@Test
public void runTest ()
{
Random rand = new Random();
@@ -89,17 +84,6 @@ public class ProximityTrackerTest extends TestCase
}
}
public static Test suite ()
{
return new ProximityTrackerTest();
}
public static void main (String[] args)
{
ProximityTrackerTest test = new ProximityTrackerTest();
test.runTest();
}
protected static final int MAX_X = 1000;
protected static final int MAX_Y = 1000;
}
@@ -20,22 +20,17 @@
package com.samskivert.util;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
import static com.samskivert.Log.log;
/**
* Tests the {@link ArrayUtil} class.
*/
public class ArrayUtilTest extends TestCase
public class ArrayUtilTest
{
public ArrayUtilTest ()
{
super(ArrayUtilTest.class.getName());
}
@Override
@Test
public void runTest ()
{
// test reversing an array
@@ -157,15 +152,4 @@ public class ArrayUtilTest extends TestCase
work = ArrayUtil.splice(work, 2, 2);
log.info("splice concat 2, 2: " + StringUtil.toString(work));
}
public static Test suite ()
{
return new ArrayUtilTest();
}
public static void main (String[] args)
{
ArrayUtilTest test = new ArrayUtilTest();
test.runTest();
}
}
@@ -20,20 +20,15 @@
package com.samskivert.util;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Tests the {@link CheapIntMap} class.
*/
public class CheapIntMapTest extends TestCase
public class CheapIntMapTest
{
public CheapIntMapTest ()
{
super(CheapIntMapTest.class.getName());
}
@Override
@Test
public void runTest ()
{
CheapIntMap map = new CheapIntMap(10);
@@ -68,15 +63,4 @@ public class CheapIntMapTest extends TestCase
}
}
}
public static Test suite ()
{
return new CheapIntMapTest();
}
public static void main (String[] args)
{
CheapIntMapTest test = new CheapIntMapTest();
test.runTest();
}
}
@@ -23,20 +23,15 @@ package com.samskivert.util;
import java.util.Iterator;
import java.util.Properties;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Tests the {@link Config} class.
*/
public class ConfigTest extends TestCase
public class ConfigTest
{
public ConfigTest ()
{
super(ConfigTest.class.getName());
}
@Override
@Test
public void runTest ()
{
PrefsConfig config = new PrefsConfig("rsrc/util/test");
@@ -68,15 +63,4 @@ public class ConfigTest extends TestCase
Properties subprops = config.getSubProperties("sub");
System.out.println("Sub: " + StringUtil.toString(subprops.propertyNames()));
}
public static Test suite ()
{
return new ConfigTest();
}
public static void main (String[] args)
{
ConfigTest test = new ConfigTest();
test.runTest();
}
}
@@ -22,8 +22,8 @@ package com.samskivert.util;
import java.util.Properties;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Our test properties files:
@@ -64,14 +64,9 @@ import junit.framework.TestCase;
* three = test - three
* </pre>
*/
public class ConfigUtilTest extends TestCase
public class ConfigUtilTest
{
public ConfigUtilTest ()
{
super(ConfigUtilTest.class.getName());
}
@Override
@Test
public void runTest ()
{
try {
@@ -88,17 +83,6 @@ public class ConfigUtilTest extends TestCase
}
}
public static Test suite ()
{
return new ConfigUtilTest();
}
public static void main (String[] args)
{
ConfigUtilTest test = new ConfigUtilTest();
test.runTest();
}
protected static final String DUMP =
"{prop4=one, two, three,, and a half, four, " +
"prop3=9, 8, 7, 6, prop2=twenty five, prop1=25, " +
@@ -24,17 +24,12 @@ import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
public class HashIntMapTest extends TestCase
public class HashIntMapTest
{
public HashIntMapTest ()
{
super(HashIntMapTest.class.getName());
}
@Override
@Test
public void runTest ()
{
HashIntMap<Integer> table = new HashIntMap<Integer>();
@@ -134,11 +129,6 @@ public class HashIntMapTest extends TestCase
assertTrue(valuestr + ".equals(" + exvals + ")", valuestr.equals(exvals));
}
public static Test suite ()
{
return new HashIntMapTest();
}
protected static final String TEST1 = "(10, 11, 12, 13, 14, 15, 16, 17, 18, 19)";
protected static final String TEST2 = "(10, 11)";
}
@@ -22,17 +22,12 @@ package com.samskivert.util;
import java.util.Arrays;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
public class IntListUtilTest extends TestCase
public class IntListUtilTest
{
public IntListUtilTest ()
{
super(IntListUtilTest.class.getName());
}
@Override
@Test
public void runTest ()
{
int[] list = null;
@@ -110,9 +105,4 @@ public class IntListUtilTest extends TestCase
assertTrue("removeAt(0)",
Arrays.equals(list, new int[] { 5, 6, 7, 0 }));
}
public static Test suite ()
{
return new IntListUtilTest();
}
}
@@ -20,20 +20,15 @@
package com.samskivert.util;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Tests the {@link LRUHashMap} class.
*/
public class LRUHashMapTest extends TestCase
public class LRUHashMapTest
{
public LRUHashMapTest ()
{
super(LRUHashMapTest.class.getName());
}
@Override
@Test
public void runTest ()
{
LRUHashMap<String,Integer> map =
@@ -62,15 +57,4 @@ public class LRUHashMapTest extends TestCase
map.put("three.3", 3);
assertTrue("size == 2", map.size() == 2);
}
public static Test suite ()
{
return new LRUHashMapTest();
}
public static void main (String[] args)
{
LRUHashMapTest test = new LRUHashMapTest();
test.runTest();
}
}
@@ -20,20 +20,15 @@
package com.samskivert.util;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Tests the {@link ObserverList} class.
*/
public class ObserverListTest extends TestCase
public class ObserverListTest
{
public ObserverListTest ()
{
super(ObserverListTest.class.getName());
}
@Override
@Test
public void runTest ()
{
// Log.info("Testing safe list.");
@@ -86,17 +81,6 @@ public class ObserverListTest extends TestCase
}
}
public static Test suite ()
{
return new ObserverListTest();
}
public static void main (String[] args)
{
ObserverListTest test = new ObserverListTest();
test.runTest();
}
protected static class TestObserver
{
public TestObserver (int index)
@@ -22,20 +22,15 @@ package com.samskivert.util;
import java.util.Comparator;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Tests the {@link QuickSort} class.
*/
public class QuickSortTest extends TestCase
public class QuickSortTest
{
public QuickSortTest ()
{
super(QuickSortTest.class.getName());
}
@Override
@Test
public void runTest ()
{
Integer[] a = new Integer[100];
@@ -102,17 +97,6 @@ public class QuickSortTest extends TestCase
// " random arrays");
}
public static Test suite ()
{
return new QuickSortTest();
}
public static void main (String[] args)
{
QuickSortTest test = new QuickSortTest();
test.runTest();
}
private static int rand (int n)
{
return (int)(Math.random() * n);
@@ -22,22 +22,21 @@ package com.samskivert.util;
import java.util.concurrent.Executor;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Tests the {@link SerialExecutor} class.
*/
public class SerialExecutorTest extends TestCase
public class SerialExecutorTest
implements Executor, RunQueue
{
public SerialExecutorTest ()
{
super(SerialExecutorTest.class.getName());
_main = Thread.currentThread();
}
@Override
@Test
public void runTest ()
{
SerialExecutor executor = new SerialExecutor(this);
@@ -110,17 +109,6 @@ public class SerialExecutorTest extends TestCase
return true;
}
public static Test suite ()
{
return new SerialExecutorTest();
}
public static void main (String[] args)
{
SerialExecutorTest test = new SerialExecutorTest();
test.runTest();
}
protected class Sleeper implements SerialExecutor.ExecutorTask
{
public Sleeper (long sleepFor, boolean hang) {
@@ -20,17 +20,12 @@
package com.samskivert.util;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
public class StringUtilTest extends TestCase
public class StringUtilTest
{
public StringUtilTest ()
{
super(StringUtilTest.class.getName());
}
@Override
@Test
public void runTest ()
{
String source = "mary, had, a,, little, lamb, and, a, comma,,";
@@ -48,9 +43,4 @@ public class StringUtilTest extends TestCase
joined = StringUtil.joinEscaped(tokens);
assertTrue("null elements work", joined.equals("this, , is, , a, , test"));
}
public static Test suite ()
{
return new StringUtilTest();
}
}
@@ -20,13 +20,13 @@
package com.samskivert.util;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
/**
* A test case for {@link Throttle}.
*/
public class ThrottleTest extends TestCase
public class ThrottleTest
{
public static class TestThrottle extends Throttle
{
@@ -46,23 +46,7 @@ public class ThrottleTest extends TestCase
}
}
public static Test suite ()
{
return new ThrottleTest();
}
public static void main (String[] args)
{
ThrottleTest test = new ThrottleTest();
test.runTest();
}
public ThrottleTest ()
{
super(ThrottleTest.class.getName());
}
@Override
@Test
public void runTest ()
{
testUpdate(4);
@@ -23,21 +23,16 @@ package com.samskivert.xml;
import java.io.InputStream;
import java.io.FileInputStream;
import junit.framework.Test;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
import org.apache.commons.digester.Digester;
import com.samskivert.test.TestUtil;
import com.samskivert.util.StringUtil;
public class SetFieldRuleTest extends TestCase
public class SetFieldRuleTest
{
public SetFieldRuleTest ()
{
super(SetFieldRuleTest.class.getName());
}
public static class TestObject
{
public int intField;
@@ -56,8 +51,7 @@ public class SetFieldRuleTest extends TestCase
}
}
@Override
public void runTest ()
@Test public void runTest ()
{
Digester digester = new Digester();
@@ -85,17 +79,6 @@ public class SetFieldRuleTest extends TestCase
assertTrue(EXPECTED.equals(object.toString()));
}
public static Test suite ()
{
return new SetFieldRuleTest();
}
public static void main (String[] args)
{
SetFieldRuleTest test = new SetFieldRuleTest();
test.runTest();
}
protected static final String EXPECTED =
"[intField=5, stringField=howdy partner!, integerField=15, " +
"intArrayField=(1, 2, 3, 4, 5), " +