Permalink
Browse files

Extended neo4j test suite to to some extent incorporate testing the i…

…njected graph functionality
  • Loading branch information...
1 parent 2a42901 commit 374d260195f253e416cb107dcc4cba6a06938a8b @jakewins committed Jul 13, 2010
@@ -3,76 +3,114 @@
import com.tinkerpop.blueprints.BaseTest;
import com.tinkerpop.blueprints.pgm.Vertex;
-
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public class Neo4jEdgeTest extends BaseTest {
+public class Neo4jEdgeTest extends BaseTest
+{
- public void testTransactionsForEdges() {
- Neo4jGraph graph = Neo4jGraphTest.doNeo4jGraphTest();
- if (null != graph) {
- Vertex v = graph.addVertex(null);
- Vertex u = graph.addVertex(null);
- graph.setAutoTransactions(false);
- try {
- graph.addEdge(null, v, u, "test");
- assertTrue(false);
- } catch (Exception e) {
- assertTrue(true);
- }
- graph.startTransaction();
- try {
- graph.addEdge(null, v, u, "test");
- assertTrue(true);
- } catch (Exception e) {
- assertTrue(false);
+ public void testTransactionsForEdgesUsingInjectedGraph()
+ {
+ this.testTransactionsForEdges( Neo4jGraphTest.doInjectedNeo4jGraphTest() );
+ }
+
+ public void testTransactionsForEdgesUsingInternalGraph()
+ {
+ this.testTransactionsForEdges( Neo4jGraphTest.doNeo4jGraphTest() );
+ }
+
+ public void testBruteEdgeTransactionsUsingInjectedGraph()
+ {
+ this.testBruteEdgeTransactions( Neo4jGraphTest.doInjectedNeo4jGraphTest() );
+ }
+
+ public void testBruteEdgeTransactionsUsingInternalGraph()
+ {
+ this.testBruteEdgeTransactions( Neo4jGraphTest.doNeo4jGraphTest() );
+ }
+
+ //
+ // INTERNALS
+ //
+
+ protected void testBruteEdgeTransactions( Neo4jGraph graph )
+ {
+ if ( null != graph )
+ {
+ graph.setAutoTransactions( false );
+ for ( int i = 0; i < 100; i++ )
+ {
+ graph.startTransaction();
+ Vertex v = graph.addVertex( null );
+ Vertex u = graph.addVertex( null );
+ graph.addEdge( null, v, u, "test" );
+ graph.stopTransaction( true );
}
- graph.stopTransaction(false);
graph.startTransaction();
- assertEquals(count(graph.getVertices()), 2);
- assertEquals(count(graph.getEdges()), 0);
- try {
- graph.addEdge(null, u, v, "test");
- assertTrue(true);
- } catch (Exception e) {
- assertTrue(false);
+ assertEquals( count( graph.getVertices() ), 200 );
+ assertEquals( count( graph.getEdges() ), 100 );
+ graph.stopTransaction( true );
+ for ( int i = 0; i < 100; i++ )
+ {
+ graph.startTransaction();
+ Vertex v = graph.addVertex( null );
+ Vertex u = graph.addVertex( null );
+ graph.addEdge( null, v, u, "test" );
+ graph.stopTransaction( false );
}
- graph.stopTransaction(true);
graph.startTransaction();
- assertEquals(count(graph.getVertices()), 2);
- assertEquals(count(graph.getEdges()), 1);
- graph.stopTransaction(true);
-
+ assertEquals( count( graph.getVertices() ), 200 );
+ assertEquals( count( graph.getEdges() ), 100 );
+ graph.stopTransaction( true );
}
}
- public void testBruteEdgeTransactions() {
- Neo4jGraph graph = Neo4jGraphTest.doNeo4jGraphTest();
- if (null != graph) {
- graph.setAutoTransactions(false);
- for (int i = 0; i < 100; i++) {
- graph.startTransaction();
- Vertex v = graph.addVertex(null);
- Vertex u = graph.addVertex(null);
- graph.addEdge(null, v, u, "test");
- graph.stopTransaction(true);
+ protected void testTransactionsForEdges( Neo4jGraph graph )
+ {
+
+ if ( null != graph )
+ {
+ Vertex v = graph.addVertex( null );
+ Vertex u = graph.addVertex( null );
+ graph.setAutoTransactions( false );
+ try
+ {
+ graph.addEdge( null, v, u, "test" );
+ assertTrue( false );
+ }
+ catch ( Exception e )
+ {
+ assertTrue( true );
}
graph.startTransaction();
- assertEquals(count(graph.getVertices()), 200);
- assertEquals(count(graph.getEdges()), 100);
- graph.stopTransaction(true);
- for (int i = 0; i < 100; i++) {
- graph.startTransaction();
- Vertex v = graph.addVertex(null);
- Vertex u = graph.addVertex(null);
- graph.addEdge(null, v, u, "test");
- graph.stopTransaction(false);
+ try
+ {
+ graph.addEdge( null, v, u, "test" );
+ assertTrue( true );
+ }
+ catch ( Exception e )
+ {
+ assertTrue( false );
+ }
+ graph.stopTransaction( false );
+ graph.startTransaction();
+ assertEquals( count( graph.getVertices() ), 2 );
+ assertEquals( count( graph.getEdges() ), 0 );
+ try
+ {
+ graph.addEdge( null, u, v, "test" );
+ assertTrue( true );
+ }
+ catch ( Exception e )
+ {
+ assertTrue( false );
}
+ graph.stopTransaction( true );
graph.startTransaction();
- assertEquals(count(graph.getVertices()), 200);
- assertEquals(count(graph.getEdges()), 100);
- graph.stopTransaction(true);
+ assertEquals( count( graph.getVertices() ), 2 );
+ assertEquals( count( graph.getEdges() ), 1 );
+ graph.stopTransaction( true );
+
}
}
}
Oops, something went wrong.

0 comments on commit 374d260

Please sign in to comment.