Search in sources :

Example 1 with NodeManager

use of org.neo4j.kernel.impl.core.NodeManager 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());
}
Also used : NodeManager(org.neo4j.kernel.impl.core.NodeManager) GraphDbModule(org.neo4j.kernel.impl.core.GraphDbModule) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1 GraphDbModule (org.neo4j.kernel.impl.core.GraphDbModule)1 NodeManager (org.neo4j.kernel.impl.core.NodeManager)1