Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added another test case. Fixed JMX issue with fork=true.
- Loading branch information
Showing
8 changed files
with
96 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package agents; | ||
|
||
import org.neo4j.compatibility.IgnoringStoreAgent; | ||
import org.neo4j.compatibility.StoreAgent; | ||
|
||
public class ExhaustiveGraph extends IgnoringStoreAgent | ||
{ | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters