[Plexus-svn] SF.net SVN: plexus:[887] trunk/plexus-graph/src/test/java/com/phoenixst/ plexus
Status: Alpha
Brought to you by:
rconner
|
From: <rc...@us...> - 2010-09-15 22:23:05
|
Revision: 887
http://plexus.svn.sourceforge.net/plexus/?rev=887&view=rev
Author: rconner
Date: 2010-09-15 22:22:57 +0000 (Wed, 15 Sep 2010)
Log Message:
-----------
Getting most of the rest of the tests working
Modified Paths:
--------------
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteBipartiteGraphTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteGraphTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteTreeTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CycleTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/DefaultGraphExamplesTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/EmptyGraphTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PathTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PetersenGraphTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PlanarMeshTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PrismTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/StarTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/ToroidalMeshTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/WheelTest.java
trunk/plexus-graph/src/test/java/com/phoenixst/plexus/util/SingletonGraphTest.java
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteBipartiteGraphTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteBipartiteGraphTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteBipartiteGraphTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,92 +15,109 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link CompleteBipartiteGraph} tester.
+ * A {@link CompleteBipartiteGraph} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class CompleteBipartiteGraphTest extends AbstractGraphTest
+public abstract class CompleteBipartiteGraphTest extends AbstractGraphTest
{
+ void set( final int m, final int n )
+ {
+ setGraph( new CompleteBipartiteGraph( m, n ) );
+ createPresentNodeRanges( m + n );
+ createEdgeArrays( m + n, new Predicate()
+ {
+ public boolean evaluate( Object object )
+ {
+ Graph.Edge edge = (Graph.Edge) object;
+ if( !edge.isDirected() ) {
+ return false;
+ }
+ int tail = ((Integer) edge.getTail()).intValue();
+ int head = ((Integer) edge.getHead()).intValue();
+ return (tail < m && m <= head);
+ }
+ } );
+ }
- private static class TestPredicate
- implements Predicate
+
+ public static class Test_0_0 extends CompleteBipartiteGraphTest
{
- private final int m;
+ @Before
+ public void init()
+ {
+ set( 0, 0 );
+ }
+ }
- TestPredicate( int m )
+ public static class Test_0_1 extends CompleteBipartiteGraphTest
+ {
+ @Before
+ public void init()
{
- super();
- this.m = m;
+ set( 0, 1 );
}
+ }
- public boolean evaluate( Object object )
+ public static class Test_1_0 extends CompleteBipartiteGraphTest
+ {
+ @Before
+ public void init()
{
- Graph.Edge edge = (Graph.Edge) object;
- if( !edge.isDirected() ) {
- return false;
- }
- int tail = ((Integer) edge.getTail()).intValue();
- int head = ((Integer) edge.getHead()).intValue();
- return (tail < m && m <= head);
+ set( 1, 0 );
}
}
-
- private int m;
- private int n;
-
-
- public CompleteBipartiteGraphTest( int m, int n )
+ public static class Test_0_5 extends CompleteBipartiteGraphTest
{
- super();
- this.m = m;
- this.n = n;
+ @Before
+ public void init()
+ {
+ set( 0, 5 );
+ }
}
-
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_5_0 extends CompleteBipartiteGraphTest
{
- super.setUp();
- setUp( new CompleteBipartiteGraph( m, n ) );
- createPresentNodeRanges( m + n );
- createEdgeArrays( m + n, new TestPredicate( m ) );
+ @Before
+ public void init()
+ {
+ set( 5, 0 );
+ }
}
-
- private static Test suite( int m, int n )
+ public static class Test_1_5 extends CompleteBipartiteGraphTest
{
- return new CompleteBipartiteGraphTest( m, n ).getInstanceSuite( "Bipartite[" + m + "," + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 1, 5 );
+ }
}
-
- public static Test suite()
+ public static class Test_5_1 extends CompleteBipartiteGraphTest
{
- TestSuite suite = new TestSuite( "CompleteBipartiteGraph Tests" );
- suite.addTest( suite( 0, 0 ) );
- suite.addTest( suite( 0, 1 ) );
- suite.addTest( suite( 1, 0 ) );
- suite.addTest( suite( 0, 5 ) );
- suite.addTest( suite( 5, 0 ) );
- suite.addTest( suite( 1, 5 ) );
- suite.addTest( suite( 5, 1 ) );
- suite.addTest( suite( 2, 3 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 5, 1 );
+ }
}
-
- public static void main( String[] args )
+ public static class Test_2_3 extends CompleteBipartiteGraphTest
{
- junit.textui.TestRunner.run( suite() );
+ @Before
+ public void init()
+ {
+ set( 2, 3 );
+ }
}
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteGraphTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteGraphTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteGraphTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,22 +15,25 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link CompleteGraph} tester.
+ * A {@link CompleteGraph} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class CompleteGraphTest extends AbstractGraphTest
+public abstract class CompleteGraphTest extends AbstractGraphTest
{
-
- private static final Predicate TEST_PREDICATE = new Predicate()
+ void set( final int n )
+ {
+ setGraph( new CompleteGraph( n ) );
+ createPresentNodeRanges( n );
+ createEdgeArrays( n, new Predicate()
{
public boolean evaluate( Object object )
{
@@ -42,50 +45,43 @@
int head = ((Integer) edge.getHead()).intValue();
return tail < head;
}
- };
-
-
- private final int n;
-
-
- public CompleteGraphTest( int n )
- {
- super();
- this.n = n;
+ } );
}
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_1 extends CompleteGraphTest
{
- super.setUp();
- setUp( new CompleteGraph( n ) );
- createPresentNodeRanges( n );
- createEdgeArrays( n, TEST_PREDICATE );
+ @Before
+ public void init()
+ {
+ set( 1 );
+ }
}
-
- private static Test suite( int n )
+ public static class Test_2 extends CompleteGraphTest
{
- return new CompleteGraphTest( n ).getInstanceSuite( "Complete[" + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 2 );
+ }
}
-
- public static Test suite()
+ public static class Test_3 extends CompleteGraphTest
{
- TestSuite suite = new TestSuite( "CompleteGraph Tests" );
- suite.addTest( suite( 1 ) );
- suite.addTest( suite( 2 ) );
- suite.addTest( suite( 3 ) );
- suite.addTest( suite( 5 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 3 );
+ }
}
-
- public static void main( String[] args )
+ public static class Test_5 extends CompleteGraphTest
{
- junit.textui.TestRunner.run( suite() );
+ @Before
+ public void init()
+ {
+ set( 5 );
+ }
}
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteTreeTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteTreeTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CompleteTreeTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,64 +15,24 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link CompleteTree} tester.
+ * A {@link CompleteTree} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class CompleteTreeTest extends AbstractGraphTest
+public abstract class CompleteTreeTest extends AbstractGraphTest
{
-
- private static class TestPredicate
- implements Predicate
+ void set( final int height, final int numChildren )
{
- private final int numChildren;
+ setGraph( new CompleteTree( height, numChildren ) );
- TestPredicate( int numChildren )
- {
- super();
- this.numChildren = numChildren;
- }
-
- public boolean evaluate( Object object )
- {
- Graph.Edge edge = (Graph.Edge) object;
- if( !edge.isDirected() ) {
- return false;
- }
- int tail = ((Integer) edge.getTail()).intValue();
- int head = ((Integer) edge.getHead()).intValue();
- return tail < head && tail == (head - 1) / numChildren;
- }
- }
-
-
- private int height;
- private int numChildren;
-
-
- public CompleteTreeTest( int height, int numChildren )
- {
- super();
- this.height = height;
- this.numChildren = numChildren;
- }
-
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- setUp( new CompleteTree( height, numChildren ) );
-
int n;
if( numChildren == 1 ) {
n = height + 1;
@@ -85,32 +45,73 @@
}
createPresentNodeRanges( n );
- createEdgeArrays( n, new TestPredicate( numChildren ) );
+ createEdgeArrays( n, new Predicate()
+ {
+ public boolean evaluate( Object object )
+ {
+ Graph.Edge edge = (Graph.Edge) object;
+ if( !edge.isDirected() ) {
+ return false;
+ }
+ int tail = ((Integer) edge.getTail()).intValue();
+ int head = ((Integer) edge.getHead()).intValue();
+ return tail < head && tail == (head - 1) / numChildren;
+ }
+ } );
}
- private static Test suite( int height, int numChildren )
+ public static class Test_0_1 extends CompleteTreeTest
{
- return new CompleteTreeTest( height, numChildren ).getInstanceSuite( "Tree[" + height + "," + numChildren + "]" );
+ @Before
+ public void init()
+ {
+ set( 0, 1 );
+ }
}
+ public static class Test_0_10 extends CompleteTreeTest
+ {
+ @Before
+ public void init()
+ {
+ set( 0, 10 );
+ }
+ }
- public static Test suite()
+ public static class Test_1_1 extends CompleteTreeTest
{
- TestSuite suite = new TestSuite( "CompleteTree Tests" );
- suite.addTest( suite( 0, 1 ) );
- suite.addTest( suite( 0, 10 ) );
- suite.addTest( suite( 1, 1 ) );
- suite.addTest( suite( 1, 5 ) );
- suite.addTest( suite( 5, 1 ) );
- suite.addTest( suite( 2, 3 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 1, 1 );
+ }
}
+ public static class Test_1_5 extends CompleteTreeTest
+ {
+ @Before
+ public void init()
+ {
+ set( 1, 5 );
+ }
+ }
- public static void main( String[] args )
+ public static class Test_5_1 extends CompleteTreeTest
{
- junit.textui.TestRunner.run( suite() );
+ @Before
+ public void init()
+ {
+ set( 5, 1 );
+ }
}
+ public static class Test_2_3 extends CompleteTreeTest
+ {
+ @Before
+ public void init()
+ {
+ set( 2, 3 );
+ }
+ }
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CycleTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CycleTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/CycleTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,85 +15,56 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link Cycle} tester.
+ * A {@link Cycle} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class CycleTest extends AbstractGraphTest
+public abstract class CycleTest extends AbstractGraphTest
{
-
- private static class TestPredicate
- implements Predicate
+ void set( final int n )
{
- private final int n;
-
- TestPredicate( int n )
+ setGraph( new Cycle( n ) );
+ createPresentNodeRanges( n );
+ createEdgeArrays( n, new Predicate()
{
- super();
- this.n = n;
- }
-
- public boolean evaluate( Object object )
- {
- Graph.Edge edge = (Graph.Edge) object;
- if( !edge.isDirected() ) {
- return false;
+ public boolean evaluate( Object object )
+ {
+ Graph.Edge edge = (Graph.Edge) object;
+ if( !edge.isDirected() ) {
+ return false;
+ }
+ int tail = ((Integer) edge.getTail()).intValue();
+ int head = ((Integer) edge.getHead()).intValue();
+ return (tail + 1 == head)
+ || (tail == n - 1 && head == 0);
}
- int tail = ((Integer) edge.getTail()).intValue();
- int head = ((Integer) edge.getHead()).intValue();
- return (tail + 1 == head)
- || (tail == n - 1 && head == 0);
- }
+ } );
}
- private int n;
-
-
- public CycleTest( int n )
+ public static class Test_3 extends CycleTest
{
- super();
- this.n = n;
+ @Before
+ public void init()
+ {
+ set( 3 );
+ }
}
-
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_5 extends CycleTest
{
- super.setUp();
- setUp( new Cycle( n ) );
- createPresentNodeRanges( n );
- createEdgeArrays( n, new TestPredicate( n ) );
+ @Before
+ public void init()
+ {
+ set( 5 );
+ }
}
-
-
- private static Test suite( int n )
- {
- return new CycleTest( n ).getInstanceSuite( "Cycle[" + n + "]" );
- }
-
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite( "Cycle Tests" );
- suite.addTest( suite( 3 ) );
- suite.addTest( suite( 5 ) );
- return suite;
- }
-
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/DefaultGraphExamplesTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/DefaultGraphExamplesTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/DefaultGraphExamplesTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -23,10 +23,10 @@
/**
- * A {@link com.phoenixst.plexus.DefaultGraph} tester for copies
- * of examples graphs, at least the immutable operations.
+ * A {@link com.phoenixst.plexus.DefaultGraph} tester for copies of examples
+ * graphs, at least the immutable operations.
*
- * @author Ray A. Conner
+ * @author rconner
*/
public class DefaultGraphExamplesTest extends AbstractGraphTest
{
@@ -101,10 +101,4 @@
return suite;
}
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/EmptyGraphTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/EmptyGraphTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/EmptyGraphTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,70 +15,57 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
import com.phoenixst.plexus.AbstractGraphTest;
/**
- * An {@link EmptyGraph} tester.
+ * An {@link EmptyGraph} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class EmptyGraphTest extends AbstractGraphTest
+public abstract class EmptyGraphTest extends AbstractGraphTest
{
-
- private static final Predicate TEST_PREDICATE = new Predicate()
+ void set( final int n )
+ {
+ setGraph( new EmptyGraph( n ) );
+ createPresentNodeRanges( n );
+ createEdgeArrays( n, new Predicate()
{
public boolean evaluate( Object object )
{
return false;
}
- };
-
-
- private final int n;
-
-
- public EmptyGraphTest( int n )
- {
- super();
- this.n = n;
+ } );
}
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_0 extends EmptyGraphTest
{
- super.setUp();
- setUp( new EmptyGraph( n ) );
- createPresentNodeRanges( n );
- createEdgeArrays( n, TEST_PREDICATE );
+ @Before
+ public void init()
+ {
+ set( 0 );
+ }
}
-
- private static Test suite( int n )
+ public static class Test_1 extends EmptyGraphTest
{
- return new EmptyGraphTest( n ).getInstanceSuite( "Empty[" + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 1 );
+ }
}
-
- public static Test suite()
+ public static class Test_5 extends EmptyGraphTest
{
- TestSuite suite = new TestSuite( "EmptyGraph Tests" );
- suite.addTest( suite( 0 ) );
- suite.addTest( suite( 1 ) );
- suite.addTest( suite( 5 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 5 );
+ }
}
-
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PathTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PathTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PathTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,22 +15,25 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link Path} tester.
+ * A {@link Path} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class PathTest extends AbstractGraphTest
+public abstract class PathTest extends AbstractGraphTest
{
-
- private static final Predicate TEST_PREDICATE = new Predicate()
+ void set( final int n )
+ {
+ setGraph( new Path( n ) );
+ createPresentNodeRanges( n );
+ createEdgeArrays( n, new Predicate()
{
public boolean evaluate( Object object )
{
@@ -42,49 +45,34 @@
int head = ((Integer) edge.getHead()).intValue();
return tail + 1 == head;
}
- };
-
-
- private final int n;
-
-
- public PathTest( int n )
- {
- super();
- this.n = n;
+ } );
}
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_2 extends PathTest
{
- super.setUp();
- setUp( new Path( n ) );
- createPresentNodeRanges( n );
- createEdgeArrays( n, TEST_PREDICATE );
+ @Before
+ public void init()
+ {
+ set( 2 );
+ }
}
-
- private static Test suite( int n )
+ public static class Test_3 extends PathTest
{
- return new PathTest( n ).getInstanceSuite( "Path[" + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 3 );
+ }
}
-
- public static Test suite()
+ public static class Test_5 extends PathTest
{
- TestSuite suite = new TestSuite( "Path Tests" );
- suite.addTest( suite( 2 ) );
- suite.addTest( suite( 3 ) );
- suite.addTest( suite( 5 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 5 );
+ }
}
-
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PetersenGraphTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PetersenGraphTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PetersenGraphTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,22 +15,26 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link PetersenGraph} tester.
+ * A {@link PetersenGraph} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
public class PetersenGraphTest extends AbstractGraphTest
{
-
- private static final Predicate TEST_PREDICATE = new Predicate()
+ @Before
+ public void init()
+ {
+ setGraph( PetersenGraph.INSTANCE );
+ createPresentNodeRanges( 10 );
+ createEdgeArrays( 10, new Predicate()
{
// Assumes tail < head
private boolean evaluate( int tail, int head )
@@ -60,35 +64,6 @@
return false;
}
}
- };
-
-
- public PetersenGraphTest()
- {
- super();
+ } );
}
-
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- setUp( PetersenGraph.INSTANCE );
- createPresentNodeRanges( 10 );
- createEdgeArrays( 10, TEST_PREDICATE );
- }
-
-
- public static Test suite()
- {
- return new TestSuite( PetersenGraphTest.class, "PetersenGraph Tests" );
- }
-
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PlanarMeshTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PlanarMeshTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PlanarMeshTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -17,84 +17,79 @@
import java.util.List;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link PlanarMesh} tester.
+ * A {@link PlanarMesh} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class PlanarMeshTest extends AbstractGraphTest
+public abstract class PlanarMeshTest extends AbstractGraphTest
{
-
- private static final Predicate TEST_PREDICATE = new Predicate()
+ void set( final int m, final int n )
+ {
+ setGraph( new PlanarMesh( m, n ) );
+ createPresentNodeRanges( m, n );
+ createEdgeArrays( m, n, new Predicate()
{
+ @SuppressWarnings( "unchecked" )
public boolean evaluate( Object object )
{
Graph.Edge edge = (Graph.Edge) object;
if( !edge.isDirected() ) {
return false;
}
- List tail = (List) edge.getTail();
- List head = (List) edge.getHead();
- int tailA = ((Integer) tail.get( 0 )).intValue();
- int tailB = ((Integer) tail.get( 1 )).intValue();
- int headA = ((Integer) head.get( 0 )).intValue();
- int headB = ((Integer) head.get( 1 )).intValue();
+ List< Integer > tail = (List< Integer >) edge.getTail();
+ List< Integer > head = (List< Integer >) edge.getHead();
+ int tailA = tail.get( 0 ).intValue();
+ int tailB = tail.get( 1 ).intValue();
+ int headA = head.get( 0 ).intValue();
+ int headB = head.get( 1 ).intValue();
return ( (tailA == headA) && (tailB + 1 == headB) )
|| ( (tailB == headB) && (tailA + 1 == headA) );
}
- };
-
-
- private final int m;
- private final int n;
-
-
- public PlanarMeshTest( int m, int n )
- {
- super();
- this.m = m;
- this.n = n;
+ } );
}
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_2_2 extends PlanarMeshTest
{
- super.setUp();
- setUp( new PlanarMesh( m, n ) );
- createPresentNodeRanges( m, n );
- createEdgeArrays( m, n, TEST_PREDICATE );
+ @Before
+ public void init()
+ {
+ set( 2, 2 );
+ }
}
-
- private static Test suite( int m, int n )
+ public static class Test_2_5 extends PlanarMeshTest
{
- return new PlanarMeshTest( m, n ).getInstanceSuite( "Plane[" + m + "," + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 2, 5 );
+ }
}
-
- public static Test suite()
+ public static class Test_5_2 extends PlanarMeshTest
{
- TestSuite suite = new TestSuite( "PlanarMesh Tests" );
- suite.addTest( suite( 2, 2 ) );
- suite.addTest( suite( 2, 5 ) );
- suite.addTest( suite( 5, 2 ) );
- suite.addTest( suite( 5, 5 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 5, 2 );
+ }
}
-
- public static void main( String[] args )
+ public static class Test_5_5 extends PlanarMeshTest
{
- junit.textui.TestRunner.run( suite() );
+ @Before
+ public void init()
+ {
+ set( 5, 5 );
+ }
}
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PrismTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PrismTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/PrismTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -17,99 +17,85 @@
import java.util.List;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link Prism} tester.
+ * A {@link Prism} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class PrismTest extends AbstractGraphTest
+public abstract class PrismTest extends AbstractGraphTest
{
-
- private static class TestPredicate
- implements Predicate
+ void set( final int m, final int n )
{
- private final int n;
-
- TestPredicate( int n )
+ setGraph( new Prism( m, n ) );
+ createPresentNodeRanges( m, n );
+ createEdgeArrays( m, n, new Predicate()
{
- super();
- this.n = n;
- }
-
- public boolean evaluate( Object object )
- {
- Graph.Edge edge = (Graph.Edge) object;
- if( !edge.isDirected() ) {
- return false;
+ @SuppressWarnings( "unchecked" )
+ public boolean evaluate( Object object )
+ {
+ Graph.Edge edge = (Graph.Edge) object;
+ if( !edge.isDirected() ) {
+ return false;
+ }
+ List< Integer > tail = (List< Integer >) edge.getTail();
+ List< Integer > head = (List< Integer >) edge.getHead();
+ int tailA = tail.get( 0 ).intValue();
+ int tailB = tail.get( 1 ).intValue();
+ int headA = head.get( 0 ).intValue();
+ int headB = head.get( 1 ).intValue();
+ if( tailA == headA ) {
+ return tailB + 1 == headB;
+ } else if( tailB == headB ) {
+ return (tailA + 1 == headA)
+ || (tailA == n - 1 && headA == 0);
+ } else {
+ return false;
+ }
}
- List tail = (List) edge.getTail();
- List head = (List) edge.getHead();
- int tailA = ((Integer) tail.get( 0 )).intValue();
- int tailB = ((Integer) tail.get( 1 )).intValue();
- int headA = ((Integer) head.get( 0 )).intValue();
- int headB = ((Integer) head.get( 1 )).intValue();
- if( tailA == headA ) {
- return tailB + 1 == headB;
- } else if( tailB == headB ) {
- return (tailA + 1 == headA)
- || (tailA == n - 1 && headA == 0);
- } else {
- return false;
- }
- }
+ } );
}
- private int m;
- private int n;
-
-
- public PrismTest( int m, int n )
+ public static class Test_3_2 extends PrismTest
{
- super();
- this.m = m;
- this.n = n;
+ @Before
+ public void init()
+ {
+ set( 3, 2 );
+ }
}
-
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_3_5 extends PrismTest
{
- super.setUp();
- setUp( new Prism( m, n ) );
- createPresentNodeRanges( m, n );
- createEdgeArrays( m, n, new TestPredicate( m ) );
+ @Before
+ public void init()
+ {
+ set( 3, 5 );
+ }
}
-
- private static Test suite( int m, int n )
+ public static class Test_5_2 extends PrismTest
{
- return new PrismTest( m, n ).getInstanceSuite( "Prism[" + m + "," + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 5, 2 );
+ }
}
-
- public static Test suite()
+ public static class Test_5_5 extends PrismTest
{
- TestSuite suite = new TestSuite( "Prism Tests" );
- suite.addTest( suite( 3, 2 ) );
- suite.addTest( suite( 3, 5 ) );
- suite.addTest( suite( 5, 2 ) );
- suite.addTest( suite( 5, 5 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 5, 5 );
+ }
}
-
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/StarTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/StarTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/StarTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,22 +15,25 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link Star} tester.
+ * A {@link Star} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class StarTest extends AbstractGraphTest
+public abstract class StarTest extends AbstractGraphTest
{
-
- private static final Predicate TEST_PREDICATE = new Predicate()
+ void set( final int n )
+ {
+ setGraph( new Star( n ) );
+ createPresentNodeRanges( n + 1 );
+ createEdgeArrays( n + 1, new Predicate()
{
public boolean evaluate( Object object )
{
@@ -42,49 +45,43 @@
int head = ((Integer) edge.getHead()).intValue();
return tail == 0 && head != 0;
}
- };
-
-
- private final int n;
-
-
- public StarTest( int n )
- {
- super();
- this.n = n;
+ } );
}
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_0 extends StarTest
{
- super.setUp();
- setUp( new Star( n ) );
- createPresentNodeRanges( n + 1 );
- createEdgeArrays( n + 1, TEST_PREDICATE );
+ @Before
+ public void init()
+ {
+ set( 0 );
+ }
}
-
- private static Test suite( int n )
+ public static class Test_1 extends StarTest
{
- return new StarTest( n ).getInstanceSuite( "Star[" + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 1 );
+ }
}
-
- public static Test suite()
+ public static class Test_3 extends StarTest
{
- TestSuite suite = new TestSuite( "Star Tests" );
- suite.addTest( suite( 0 ) );
- suite.addTest( suite( 1 ) );
- suite.addTest( suite( 5 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 3 );
+ }
}
-
- public static void main( String[] args )
+ public static class Test_5 extends StarTest
{
- junit.textui.TestRunner.run( suite() );
+ @Before
+ public void init()
+ {
+ set( 5 );
+ }
}
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/ToroidalMeshTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/ToroidalMeshTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/ToroidalMeshTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -17,102 +17,86 @@
import java.util.List;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link ToroidalMesh} tester.
+ * A {@link ToroidalMesh} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class ToroidalMeshTest extends AbstractGraphTest
+public abstract class ToroidalMeshTest extends AbstractGraphTest
{
-
- private static class TestPredicate
- implements Predicate
+ void set( final int m, final int n )
{
- private final int m;
- private final int n;
-
- TestPredicate( int m, int n )
+ setGraph( new ToroidalMesh( m, n ) );
+ createPresentNodeRanges( m, n );
+ createEdgeArrays( m, n, new Predicate()
{
- super();
- this.m = m;
- this.n = n;
- }
-
- public boolean evaluate( Object object )
- {
- Graph.Edge edge = (Graph.Edge) object;
- if( !edge.isDirected() ) {
- return false;
+ @SuppressWarnings( "unchecked" )
+ public boolean evaluate( Object object )
+ {
+ Graph.Edge edge = (Graph.Edge) object;
+ if( !edge.isDirected() ) {
+ return false;
+ }
+ List< Integer > tail = (List< Integer >) edge.getTail();
+ List< Integer > head = (List< Integer >) edge.getHead();
+ int tailA = tail.get( 0 ).intValue();
+ int tailB = tail.get( 1 ).intValue();
+ int headA = head.get( 0 ).intValue();
+ int headB = head.get( 1 ).intValue();
+ if( tailA == headA ) {
+ return (tailB + 1 == headB)
+ || (tailB == n - 1 && headB == 0);
+ } else if( tailB == headB ) {
+ return (tailA + 1 == headA)
+ || (tailA == m - 1 && headA == 0);
+ } else {
+ return false;
+ }
}
- List tail = (List) edge.getTail();
- List head = (List) edge.getHead();
- int tailA = ((Integer) tail.get( 0 )).intValue();
- int tailB = ((Integer) tail.get( 1 )).intValue();
- int headA = ((Integer) head.get( 0 )).intValue();
- int headB = ((Integer) head.get( 1 )).intValue();
- if( tailA == headA ) {
- return (tailB + 1 == headB)
- || (tailB == n - 1 && headB == 0);
- } else if( tailB == headB ) {
- return (tailA + 1 == headA)
- || (tailA == m - 1 && headA == 0);
- } else {
- return false;
- }
- }
+ } );
}
- private int m;
- private int n;
-
-
- public ToroidalMeshTest( int m, int n )
+ public static class Test_3_3 extends ToroidalMeshTest
{
- super();
- this.m = m;
- this.n = n;
+ @Before
+ public void init()
+ {
+ set( 3, 3 );
+ }
}
-
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_3_5 extends ToroidalMeshTest
{
- super.setUp();
- setUp( new ToroidalMesh( m, n ) );
- createPresentNodeRanges( m, n );
- createEdgeArrays( m, n, new TestPredicate( m, n ) );
+ @Before
+ public void init()
+ {
+ set( 3, 5 );
+ }
}
-
- private static Test suite( int m, int n )
+ public static class Test_5_3 extends ToroidalMeshTest
{
- return new ToroidalMeshTest( m, n ).getInstanceSuite( "Torus[" + m + "," + n + "]" );
+ @Before
+ public void init()
+ {
+ set( 5, 3 );
+ }
}
-
- public static Test suite()
+ public static class Test_5_5 extends ToroidalMeshTest
{
- TestSuite suite = new TestSuite( "ToroidalMesh Tests" );
- suite.addTest( suite( 3, 3 ) );
- suite.addTest( suite( 3, 5 ) );
- suite.addTest( suite( 5, 3 ) );
- suite.addTest( suite( 5, 5 ) );
- return suite;
+ @Before
+ public void init()
+ {
+ set( 5, 5 );
+ }
}
-
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/WheelTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/WheelTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/examples/WheelTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 1994-2005 by Phoenix Software Technologists,
+ * Copyright (C) 1994-2010 by Phoenix Software Technologists,
* Inc. and others. All rights reserved.
*
* THIS PROGRAM AND DOCUMENTATION IS PROVIDED UNDER THE TERMS OF THE
@@ -15,86 +15,57 @@
package com.phoenixst.plexus.examples;
-import junit.framework.*;
-
import org.apache.commons.collections.Predicate;
+import org.junit.Before;
-import com.phoenixst.plexus.*;
+import com.phoenixst.plexus.AbstractGraphTest;
+import com.phoenixst.plexus.Graph;
/**
- * A {@link Wheel} tester.
+ * A {@link Wheel} tester.
*
- * @author Ray A. Conner
+ * @author rconner
*/
-public class WheelTest extends AbstractGraphTest
+public abstract class WheelTest extends AbstractGraphTest
{
-
- private static class TestPredicate
- implements Predicate
+ void set( final int n )
{
- private final int n;
-
- TestPredicate( int n )
+ setGraph( new Wheel( n ) );
+ createPresentNodeRanges( n + 1 );
+ createEdgeArrays( n + 1, new Predicate()
{
- super();
- this.n = n;
- }
-
- public boolean evaluate( Object object )
- {
- Graph.Edge edge = (Graph.Edge) object;
- if( !edge.isDirected() ) {
- return false;
+ public boolean evaluate( Object object )
+ {
+ Graph.Edge edge = (Graph.Edge) object;
+ if( !edge.isDirected() ) {
+ return false;
+ }
+ int tail = ((Integer) edge.getTail()).intValue();
+ int head = ((Integer) edge.getHead()).intValue();
+ return ( tail == 0 )
+ ? head != 0
+ : (tail + 1 == head) || (tail == n && head == 1);
}
- int tail = ((Integer) edge.getTail()).intValue();
- int head = ((Integer) edge.getHead()).intValue();
- return ( tail == 0 )
- ? head != 0
- : (tail + 1 == head) || (tail == n && head == 1);
- }
+ } );
}
- private int n;
-
-
- public WheelTest( int n )
+ public static class Test_3 extends WheelTest
{
- super();
- this.n = n;
+ @Before
+ public void init()
+ {
+ set( 3 );
+ }
}
-
- @Override
- protected void setUp()
- throws Exception
+ public static class Test_5 extends WheelTest
{
- super.setUp();
- setUp( new Wheel( n ) );
- createPresentNodeRanges( n + 1 );
- createEdgeArrays( n + 1, new TestPredicate( n ) );
+ @Before
+ public void init()
+ {
+ set( 5 );
+ }
}
-
-
- private static Test suite( int n )
- {
- return new WheelTest( n ).getInstanceSuite( "Wheel[" + n + "]" );
- }
-
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite( "Wheel Tests" );
- suite.addTest( suite( 3 ) );
- suite.addTest( suite( 5 ) );
- return suite;
- }
-
-
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
}
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/plexus/util/SingletonGraphTest.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/plexus/util/SingletonGraphTest.java 2010-09-15 22:00:18 UTC (rev 886)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/plexus/util/SingletonGraphTest.java 2010-09-15 22:22:57 UTC (rev 887)
@@ -28,7 +28,7 @@
*/
public abstract class SingletonGraphTest extends AbstractGraphTest
{
- void setNode( Object node )
+ void setNode( final Object node )
{
setGraph( new SingletonGraph( node ) );
setPresentNodes( node );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|