Skip to content

Commit

Permalink
Added another test case. Fixed JMX issue with fork=true.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmontag committed Feb 12, 2011
1 parent 3febbc0 commit 74d89e6
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 58 deletions.
7 changes: 2 additions & 5 deletions build.xml
Expand Up @@ -119,7 +119,7 @@

<target name="generate-test-graph" depends="init,clean,retrieve-dependencies,compile">
<mkdir dir="${db.version.dir}"/>
<java classpathref="classpath" classname="org.neo4j.compatibility.Generate" failonerror="true">
<java fork="true" classpathref="classpath" classname="org.neo4j.compatibility.Generate" failonerror="true">
<sysproperty key="version.dir" value="${db.version.dir}"/>
</java>
<property name="version.zip.file" value="${build.dir}/db-${neo4j.version}.zip"/>
Expand All @@ -141,10 +141,7 @@
<target name="verify-build" depends="init,clean,retrieve-dependencies,compile,unpack-stores">
<dirset id="versions.csv" dir="${db.versions.top.dir}" includes="*"/>
<pathconvert dirsep="/" pathsep="," property="versions.csv" refid="versions.csv"/>
<java classpathref="classpath" classname="org.neo4j.compatibility.Verify" failonerror="true">
<permissions>
<grant class="java.security.AllPermission"/>
</permissions>
<java fork="true" classpathref="classpath" classname="org.neo4j.compatibility.Verify" failonerror="true">
<sysproperty key="versions.csv" value="${versions.csv}"/>
</java>
</target>
Expand Down
8 changes: 8 additions & 0 deletions src/versions/1.2.M01/agents/ExhaustiveGraph.java
@@ -0,0 +1,8 @@
package agents;

import org.neo4j.compatibility.IgnoringStoreAgent;
import org.neo4j.compatibility.StoreAgent;

public class ExhaustiveGraph extends IgnoringStoreAgent
{
}
48 changes: 0 additions & 48 deletions src/versions/1.2.M01/agents/SimpleGraph.java

This file was deleted.

81 changes: 81 additions & 0 deletions src/versions/default/agents/ExhaustiveGraph.java
@@ -0,0 +1,81 @@
package agents;

import org.neo4j.compatibility.StoreAgent;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.index.Index;
import org.neo4j.kernel.EmbeddedGraphDatabase;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.assertEquals;

public class ExhaustiveGraph implements StoreAgent
{
private static final RelationshipType KNOWS = DynamicRelationshipType.withName( "KNOWS" );
private static final RelationshipType WORKS_FOR = DynamicRelationshipType.withName( "LIKES" );

public void generate( String dbPath )
{
GraphDatabaseService graphDb = new EmbeddedGraphDatabase( dbPath );
Index<Node> personIndex = graphDb.index().forNodes( "persons" );
Transaction tx = graphDb.beginTx();
try
{
Node personA = graphDb.createNode();
Node personB = graphDb.createNode();
Node personC = graphDb.createNode();
Node personD = graphDb.createNode();

personIndex.add( personA, "name", "A" );
personIndex.add( personB, "name", "B" );
personIndex.add( personC, "name", "C" );
personIndex.add( personD, "name", "D" );

personA.createRelationshipTo( personB, KNOWS );
personA.createRelationshipTo( personB, WORKS_FOR );
personA.createRelationshipTo( personC, KNOWS );
personA.createRelationshipTo( personD, KNOWS );
personB.createRelationshipTo( personC, WORKS_FOR );
personC.createRelationshipTo( personD, WORKS_FOR );

tx.success();
}
finally
{
tx.finish();
}
graphDb.shutdown();
}

public void verify( String dbPath )
{
GraphDatabaseService graphDb = new EmbeddedGraphDatabase( dbPath );
Index<Node> personIndex = graphDb.index().forNodes( "persons" );

Node personA = personIndex.get( "name", "A" ).getSingle();
Node personB = personIndex.get( "name", "B" ).getSingle();
Node personC = personIndex.get( "name", "C" ).getSingle();
Node personD = personIndex.get( "name", "D" ).getSingle();

Set<Node> actual = new HashSet<Node>();
for ( Relationship rel : personA.getRelationships( KNOWS, Direction.OUTGOING ) )
{
actual.add( rel.getEndNode() );
}
assertEquals( new HashSet<Node>( Arrays.asList( personB, personC, personD ) ), actual );

assertEquals( personA, personB.getSingleRelationship( WORKS_FOR, Direction.INCOMING ) );
assertEquals( personC, personB.getSingleRelationship( WORKS_FOR, Direction.OUTGOING ) );

assertEquals( personD, personC.getSingleRelationship( WORKS_FOR, Direction.OUTGOING ) );
assertEquals( personC, personD.getSingleRelationship( WORKS_FOR, Direction.INCOMING ) );
}
}
2 changes: 1 addition & 1 deletion src/versions/default/agents/FulltextIndexingGraph.java
Expand Up @@ -15,7 +15,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class FulltextIndexingGraph extends DefaultStoreAgent
public class FulltextIndexingGraph implements StoreAgent
{
private static final RelationshipType REL_TYPE = DynamicRelationshipType.withName( "REL" );

Expand Down
4 changes: 2 additions & 2 deletions src/versions/default/agents/SimpleGraph.java
Expand Up @@ -16,7 +16,7 @@

import static org.junit.Assert.assertEquals;

public class SimpleGraph extends DefaultStoreAgent
public class SimpleGraph implements StoreAgent
{
private static final RelationshipType REL_TYPE = DynamicRelationshipType.withName( "REL" );

Expand All @@ -43,7 +43,7 @@ public void verify( String dbPath )
Node n = graphDb.getNodeById( 1 );
Node n2 = n.getSingleRelationship( REL_TYPE, Direction.OUTGOING ).getEndNode();
assertEquals( new HashSet<Node>( Arrays.asList( graphDb.getReferenceNode(), n, n2 ) ),
new HashSet<Node>( IteratorUtil.asCollection( graphDb.getAllNodes() ) ) );
IteratorUtil.addToCollection( graphDb.getAllNodes(), new HashSet<Node>() ) );
graphDb.shutdown();
}
}
2 changes: 1 addition & 1 deletion src/versions/default/agents/SimpleIndexingGraph.java
Expand Up @@ -13,7 +13,7 @@

import static org.junit.Assert.assertEquals;

public class SimpleIndexingGraph extends DefaultStoreAgent
public class SimpleIndexingGraph implements StoreAgent
{
private static final RelationshipType REL_TYPE = DynamicRelationshipType.withName( "REL" );

Expand Down
2 changes: 1 addition & 1 deletion src/versions/default/agents/UnclosedIndexingGraph.java
Expand Up @@ -13,7 +13,7 @@

import static org.junit.Assert.assertEquals;

public class UnclosedIndexingGraph extends DefaultStoreAgent
public class UnclosedIndexingGraph implements StoreAgent
{
private static final RelationshipType REL_TYPE = DynamicRelationshipType.withName( "REL" );

Expand Down

0 comments on commit 74d89e6

Please sign in to comment.