Test revamp in progress.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2009 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2008-08-25 09:25:58 +00:00
parent 65a48e78a1
commit a29e4450da
35 changed files with 101 additions and 64 deletions
@@ -1,7 +1,7 @@
//
// $Id$
package com.samskivert.jdbc.depot;
package com.samskivert.jdbc.tests;
import java.sql.Date;
import java.sql.Timestamp;
@@ -1,13 +1,14 @@
//
// $Id$
package com.samskivert.jdbc.depot;
package com.samskivert.jdbc.tests;
import java.sql.Date;
import java.sql.Timestamp;
import com.samskivert.jdbc.ConnectionProvider;
import com.samskivert.jdbc.StaticConnectionProvider;
import com.samskivert.jdbc.depot.DepotRepository;
/**
* A test tool for the Depot repository services.
@@ -18,7 +18,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.servlet;
package com.samskivert.servlet.tests;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -33,6 +33,9 @@ import junit.framework.TestCase;
import org.apache.commons.io.IOUtils;
import com.samskivert.servlet.Site;
import com.samskivert.servlet.SiteIdentifier;
import com.samskivert.servlet.SiteResourceLoader;
import com.samskivert.test.TestUtil;
public class SiteResourceLoaderTest extends TestCase
@@ -142,7 +145,7 @@ public class SiteResourceLoaderTest extends TestCase
}
}
public Iterator enumerateSites ()
public Iterator<Site> enumerateSites ()
{
return null; // not used
}
@@ -1,13 +1,14 @@
//
// $Id: AdjustTestApp.java,v 1.2 2003/01/15 03:24:53 mdb Exp $
package com.samskivert.swing;
package com.samskivert.swing.tests;
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import com.samskivert.swing.RuntimeAdjust;
import com.samskivert.util.Config;
/**
@@ -40,10 +41,8 @@ public class AdjustTestApp
new String[] { "debug", "info", "warning" }, "info");
JFrame frame = new JFrame();
((JComponent)frame.getContentPane()).setBorder(
BorderFactory.createEmptyBorder(5, 5, 5, 5));
frame.getContentPane().add(RuntimeAdjust.createAdjustEditor(),
BorderLayout.CENTER);
((JComponent)frame.getContentPane()).setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
frame.getContentPane().add(RuntimeAdjust.createAdjustEditor(), BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
@@ -1,12 +1,14 @@
//
// $Id: LabelDemo.java,v 1.10 2004/02/25 13:22:25 mdb Exp $
package com.samskivert.swing;
package com.samskivert.swing.tests;
import java.awt.*;
import java.io.*;
import javax.swing.*;
import com.samskivert.swing.Label;
public class LabelDemo extends JPanel
{
public LabelDemo ()
@@ -97,8 +99,8 @@ public class LabelDemo extends JPanel
g2.setColor(Color.white);
switch (ii) {
case 0: break;
case 1: g2.fillRect(x, y, 110, size.height);
case 2: g2.fillRect(x, y, size.width, 30);
case 1: g2.fillRect(x, y, 110, size.height); break;
case 2: g2.fillRect(x, y, size.width, 30); break;
case 3: break;
}
@@ -1,7 +1,7 @@
//
// $Id: TestComboButtonBox.java,v 1.1 2002/03/10 05:10:37 mdb Exp $
package com.samskivert.swing;
package com.samskivert.swing.tests;
import java.awt.Color;
import java.awt.Graphics;
@@ -11,6 +11,8 @@ import java.awt.image.BufferedImage;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFrame;
import com.samskivert.swing.ComboButtonBox;
/**
* Tests the image button box.
*/
@@ -18,8 +20,7 @@ public class TestComboButtonBox
{
protected static Image createImage (Color color)
{
BufferedImage img =
new BufferedImage(24, 24, BufferedImage.TYPE_INT_ARGB);
BufferedImage img = new BufferedImage(24, 24, BufferedImage.TYPE_INT_ARGB);
Graphics g = img.getGraphics();
g.setColor(color);
g.fillRect(0, 0, 24, 24);
@@ -38,8 +39,7 @@ public class TestComboButtonBox
model.addElement(createImage(Color.red));
model.addElement(createImage(Color.yellow));
ComboButtonBox box =
new ComboButtonBox(ComboButtonBox.HORIZONTAL, model);
ComboButtonBox box = new ComboButtonBox(ComboButtonBox.HORIZONTAL, model);
frame.getContentPane().add(box);
frame.pack();
frame.show();
@@ -18,7 +18,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.swing.util;
package com.samskivert.swing.tests;
import java.awt.Point;
import java.util.ArrayList;
@@ -27,6 +27,8 @@ import java.util.Random;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.swing.util.ProximityTracker;
public class ProximityTrackerTest extends TestCase
{
public ProximityTrackerTest ()
@@ -38,7 +40,7 @@ public class ProximityTrackerTest extends TestCase
{
Random rand = new Random();
ProximityTracker tracker = new ProximityTracker();
ArrayList points = new ArrayList();
ArrayList<Point> points = new ArrayList<Point>();
// create 100 random points and add them to the tracker and our
// comparison list
@@ -64,7 +66,7 @@ public class ProximityTrackerTest extends TestCase
Point cp = null;
int mindist = Integer.MAX_VALUE;
for (int p = 0; p < points.size(); p++) {
Point hp = (Point)points.get(p);
Point hp = points.get(p);
int dist = ProximityTracker.distance(hp.x, hp.y, x, y);
if (dist < mindist) {
mindist = dist;
@@ -18,7 +18,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.util;
package com.samskivert.util.tests;
import java.util.Arrays;
import java.util.Random;
@@ -26,6 +26,8 @@ import java.util.Random;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.ArrayIntSet;
public class ArrayIntSetTest extends TestCase
{
public ArrayIntSetTest ()
@@ -1,12 +1,14 @@
//
// $Id: ArrayUtilTest.java,v 1.2 2002/09/06 02:12:26 shaper Exp $
package com.samskivert.util;
package com.samskivert.util.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.Log;
import com.samskivert.util.ArrayUtil;
import com.samskivert.util.StringUtil;
/**
* Tests the {@link ArrayUtil} class.
@@ -1,11 +1,13 @@
//
// $Id: CheapIntMapTest.java,v 1.1 2003/02/06 19:57:29 mdb Exp $
package com.samskivert.util;
package com.samskivert.util.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.CheapIntMap;
/**
* Tests the {@link CheapIntMap} class.
*/
@@ -1,7 +1,7 @@
//
// $Id: CollectionUtilTest.java,v 1.2 2002/09/23 01:45:47 mdb Exp $
package com.samskivert.util;
package com.samskivert.util.tests;
import java.util.ArrayList;
import java.util.List;
@@ -10,6 +10,10 @@ import java.util.Random;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.CollectionUtil;
import com.samskivert.util.ComparableArrayList;
import com.samskivert.util.StringUtil;
/**
* Tests the {@link CollectionUtil} class.
*/
@@ -22,20 +26,20 @@ public class CollectionUtilTest extends TestCase
public void runTest ()
{
ArrayList list = new ArrayList();
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 100; i++) {
list.add(new Integer(i));
}
for (int i = 0; i < 10; i++) {
List subset = CollectionUtil.selectRandomSubset(list, 10);
List<Integer> subset = CollectionUtil.selectRandomSubset(list, 10);
// System.out.println(StringUtil.toString(subset));
assertTrue("length == 10", subset.size() == 10);
}
// test comparable array list insertion
Random rand = new Random();
ComparableArrayList slist = new ComparableArrayList();
ComparableArrayList<Integer> slist = new ComparableArrayList<Integer>();
for (int ii = 0; ii < 25; ii++) {
Integer value = new Integer(rand.nextInt(100));
slist.insertSorted(value);
@@ -1,7 +1,7 @@
//
// $Id: ConfigTest.java,v 1.3 2002/03/28 22:21:06 mdb Exp $
package com.samskivert.util;
package com.samskivert.util.tests;
import java.util.Iterator;
import java.util.Properties;
@@ -9,6 +9,9 @@ import java.util.Properties;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.Config;
import com.samskivert.util.StringUtil;
/**
* Tests the {@link Config} class.
*/
@@ -18,13 +18,15 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.util;
package com.samskivert.util.tests;
import java.util.Properties;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.ConfigUtil;
/**
* Our test properties files:
*
@@ -18,7 +18,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.util;
package com.samskivert.util.tests;
import java.io.*;
import java.util.ArrayList;
@@ -27,6 +27,9 @@ import java.util.Collections;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.HashIntMap;
import com.samskivert.util.StringUtil;
public class HashIntMapTest extends TestCase
{
public HashIntMapTest ()
@@ -18,13 +18,15 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.util;
package com.samskivert.util.tests;
import java.util.Arrays;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.IntListUtil;
public class IntListUtilTest extends TestCase
{
public IntListUtilTest ()
@@ -1,11 +1,13 @@
//
// $Id: LRUHashMapTest.java,v 1.1 2003/01/17 00:40:45 mdb Exp $
package com.samskivert.util;
package com.samskivert.util.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.LRUHashMap;
/**
* Tests the {@link LRUHashMap} class.
*/
@@ -18,9 +20,10 @@ public class LRUHashMapTest extends TestCase
public void runTest ()
{
LRUHashMap map = new LRUHashMap(10, new LRUHashMap.ItemSizer() {
public int computeSize (Object item) {
return ((Integer)item).intValue();
LRUHashMap<String,Integer> map =
new LRUHashMap<String,Integer>(10, new LRUHashMap.ItemSizer<Integer>() {
public int computeSize (Integer item) {
return item.intValue();
}
});
@@ -1,11 +1,13 @@
//
// $Id: ObserverListTest.java,v 1.2 2004/02/25 13:21:08 mdb Exp $
package com.samskivert.util;
package com.samskivert.util.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.ObserverList;
/**
* Tests the {@link ObserverList} class.
*/
@@ -19,13 +21,13 @@ public class ObserverListTest extends TestCase
public void runTest ()
{
// Log.info("Testing safe list.");
testList(new ObserverList(ObserverList.SAFE_IN_ORDER_NOTIFY));
testList(new ObserverList<TestObserver>(ObserverList.SAFE_IN_ORDER_NOTIFY));
// Log.info("Testing unsafe list.");
testList(new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY));
testList(new ObserverList<TestObserver>(ObserverList.FAST_UNSAFE_NOTIFY));
}
public void testList (final ObserverList list)
public void testList (final ObserverList<TestObserver> list)
{
final int[] notifies = new int[1];
@@ -39,10 +41,10 @@ public class ObserverListTest extends TestCase
int ocount = list.size();
notifies[0] = 0;
list.apply(new ObserverList.ObserverOp() {
public boolean apply (Object obs) {
list.apply(new ObserverList.ObserverOp<TestObserver>() {
public boolean apply (TestObserver obs) {
notifies[0]++;
((TestObserver)obs).foozle();
obs.foozle();
// 1/3 of the time, remove the observer; 1/3 of the
// time append a new observer; 1/3 of the time do
@@ -1,13 +1,15 @@
//
// $Id: QuickSortTest.java,v 1.2 2002/04/11 04:07:42 mdb Exp $
package com.samskivert.util;
package com.samskivert.util.tests;
import java.util.Comparator;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.QuickSort;
/**
* Tests the {@link QuickSort} class.
*/
@@ -22,9 +24,9 @@ public class QuickSortTest extends TestCase
{
Integer[] a = new Integer[100];
Comparator comp = new Comparator() {
public int compare (Object x, Object y) {
return ((Integer)x).intValue() - ((Integer)y).intValue();
Comparator<Integer> comp = new Comparator<Integer>() {
public int compare (Integer x, Integer y) {
return x.intValue() - y.intValue();
}
};
@@ -1,11 +1,15 @@
//
// $Id$
package com.samskivert.util;
package com.samskivert.util.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.Queue;
import com.samskivert.util.RunQueue;
import com.samskivert.util.SerialExecutor;
/**
* Tests the {@link SerialExecutor} class.
*/
@@ -41,7 +45,7 @@ public class SerialExecutorTest extends TestCase
// process the results posted on our run queue
for (int ii = 0; ii < added; ii++) {
Runnable r = (Runnable)_queue.get();
Runnable r = _queue.get();
r.run();
}
@@ -134,7 +138,7 @@ public class SerialExecutorTest extends TestCase
}
protected Thread _main;
protected Queue _queue = new Queue();
protected Queue<Runnable> _queue = new Queue<Runnable>();
protected int _sleeps, _interrupts, _doubleints, _exits;
protected int _results, _timeouts;
@@ -18,11 +18,13 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.util;
package com.samskivert.util.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.util.StringUtil;
public class StringUtilTest extends TestCase
{
public StringUtilTest ()
@@ -45,8 +47,7 @@ public class StringUtilTest extends TestCase
// make sure null to empty string works
tokens = new String[] { "this", null, "is", null, "a", null, "test" };
joined = StringUtil.joinEscaped(tokens);
assertTrue("null elements work",
joined.equals("this, , is, , a, , test"));
assertTrue("null elements work", joined.equals("this, , is, , a, , test"));
}
public static Test suite ()
@@ -18,7 +18,9 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.util;
package com.samskivert.util.tests;
import com.samskivert.util.SystemInfo;
public class SystemInfoDemo
{
@@ -18,7 +18,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.samskivert.xml;
package com.samskivert.xml.tests;
import java.io.InputStream;
import java.io.FileInputStream;
@@ -30,6 +30,7 @@ import org.apache.commons.digester.Digester;
import com.samskivert.test.TestUtil;
import com.samskivert.util.StringUtil;
import com.samskivert.xml.SetFieldRule;
public class SetFieldRuleTest extends TestCase
{
@@ -65,16 +66,11 @@ public class SetFieldRuleTest extends TestCase
digester.push(object);
// set up some rules
digester.addRule("object/intField",
new SetFieldRule("intField"));
digester.addRule("object/stringField",
new SetFieldRule("stringField"));
digester.addRule("object/integerField",
new SetFieldRule("integerField"));
digester.addRule("object/intArrayField",
new SetFieldRule("intArrayField"));
digester.addRule("object/stringArrayField",
new SetFieldRule("stringArrayField"));
digester.addRule("object/intField", new SetFieldRule("intField"));
digester.addRule("object/stringField", new SetFieldRule("stringField"));
digester.addRule("object/integerField", new SetFieldRule("integerField"));
digester.addRule("object/intArrayField", new SetFieldRule("intArrayField"));
digester.addRule("object/stringArrayField", new SetFieldRule("stringArrayField"));
try {
String xmlpath =