use of org.neo4j.kernel.impl.core.GraphDbModule in project graphdb by neo4j-attic.
the class TestNeo4j method testIdUsageInfo.
// private static enum RelTypes implements RelationshipType
// {
// ONE_MORE_RELATIONSHIP;
// }
// TODO: fix this testcase
@Test
public void testIdUsageInfo() {
GraphDbModule graphDbModule = ((EmbeddedGraphDatabase) getGraphDb()).getConfig().getGraphDbModule();
NodeManager nm = graphDbModule.getNodeManager();
long nodeCount = nm.getNumberOfIdsInUse(Node.class);
long relCount = nm.getNumberOfIdsInUse(Relationship.class);
if (nodeCount > nm.getHighestPossibleIdInUse(Node.class)) {
// fail( "Node count greater than highest id " + nodeCount );
}
if (relCount > nm.getHighestPossibleIdInUse(Relationship.class)) {
// fail( "Rel count greater than highest id " + relCount );
}
// assertTrue( nodeCount <= nm.getHighestPossibleIdInUse( Node.class )
// );
// assertTrue( relCount <= nm.getHighestPossibleIdInUse(
// Relationship.class ) );
Node n1 = nm.createNode();
Node n2 = nm.createNode();
Relationship r1 = n1.createRelationshipTo(n2, MyRelTypes.TEST);
// assertEquals( nodeCount + 2, nm.getNumberOfIdsInUse( Node.class ) );
// assertEquals( relCount + 1, nm.getNumberOfIdsInUse(
// Relationship.class ) );
r1.delete();
n1.delete();
n2.delete();
// must commit for ids to be reused
try {
getTransaction().success();
getTransaction().finish();
} catch (Exception e) {
fail("" + e);
}
// assertEquals( nodeCount, nm.getNumberOfIdsInUse( Node.class ) );
// assertEquals( relCount, nm.getNumberOfIdsInUse( Relationship.class )
// );
setTransaction(getGraphDb().beginTx());
}
use of org.neo4j.kernel.impl.core.GraphDbModule in project graphdb by neo4j-attic.
the class TestNeo4j method testReferenceNode.
@Test
public void testReferenceNode() {
// fix this test when we can set reference node again
Node oldReferenceNode = null;
try {
// get old reference node if one is set
oldReferenceNode = getGraphDb().getReferenceNode();
} catch (RuntimeException e) {
// ok no one set, oldReferenceNode is null then
}
try {
GraphDbModule graphDbModule = ((EmbeddedGraphDatabase) getGraphDb()).getConfig().getGraphDbModule();
Node newReferenceNode = getGraphDb().createNode();
graphDbModule.setReferenceNodeId(newReferenceNode.getId());
assertEquals(newReferenceNode, getGraphDb().getReferenceNode());
newReferenceNode.delete();
if (oldReferenceNode != null) {
graphDbModule.setReferenceNodeId(oldReferenceNode.getId());
assertEquals(oldReferenceNode, getGraphDb().getReferenceNode());
}
} catch (Exception e) {
e.printStackTrace();
fail("" + e);
}
}
Aggregations