Search in sources :

Example 1 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project neo4j-clean-remote-db-addon by jexp.

the class DeleteDatabaseTest method startServerWithACleanDb.

@BeforeClass
public static void startServerWithACleanDb() {
    graphDatabase = new EmbeddedGraphDatabase("target/db1");
    ServerConfigurator config = new ServerConfigurator(graphDatabase);
    config.configuration().setProperty("org.neo4j.server.thirdparty.delete.key", "secret-key");
    config.getThirdpartyJaxRsClasses().add(new ThirdPartyJaxRsPackage("org.neo4j.server.extension.test.delete", "/cleandb"));
    WrappingNeoServerBootstrapper bootstrapper = new WrappingNeoServerBootstrapper(graphDatabase, config);
    bootstrapper.start();
    neoServer = bootstrapper.getServer();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) ServerConfigurator(org.neo4j.server.configuration.ServerConfigurator) ThirdPartyJaxRsPackage(org.neo4j.server.configuration.ThirdPartyJaxRsPackage) BeforeClass(org.junit.BeforeClass)

Example 2 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class MultiJvmTest method shutdownDbsAndVerify.

@After
public void shutdownDbsAndVerify() throws Exception {
    shutdownDbs();
    GraphDatabaseService masterDb = new EmbeddedGraphDatabase(dbPath(0).getAbsolutePath());
    try {
        for (int i = 1; i < jvms.size(); i++) {
            GraphDatabaseService slaveDb = new EmbeddedGraphDatabase(dbPath(i).getAbsolutePath());
            try {
                verify(masterDb, slaveDb);
            } finally {
                slaveDb.shutdown();
            }
        }
    } finally {
        masterDb.shutdown();
    }
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) After(org.junit.After)

Example 3 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class SingleJvmTest method verifyAndShutdownDbs.

@After
public void verifyAndShutdownDbs() {
    try {
        verify(master.getGraphDb(), haDbs.toArray(new GraphDatabaseService[haDbs.size()]));
    } finally {
        shutdownDbs();
    }
    GraphDatabaseService masterOfflineDb = new EmbeddedGraphDatabase(dbPath(0).getAbsolutePath());
    GraphDatabaseService[] slaveOfflineDbs = new GraphDatabaseService[haDbs.size()];
    for (int i = 1; i <= haDbs.size(); i++) {
        slaveOfflineDbs[i - 1] = new EmbeddedGraphDatabase(dbPath(i).getAbsolutePath());
    }
    try {
        verify(masterOfflineDb, slaveOfflineDbs);
    } finally {
        masterOfflineDb.shutdown();
        for (GraphDatabaseService db : slaveOfflineDbs) {
            db.shutdown();
        }
    }
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) After(org.junit.After)

Example 4 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class AbstractNeo4jTestCase method setUpDb.

@BeforeClass
public static void setUpDb() {
    deleteFileOrDirectory(new File(getStorePath("neo-test")));
    graphDb = new EmbeddedGraphDatabase(getStorePath("neo-test"));
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 5 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestBigStore method createAndVerifyGraphStartingWithId.

private void createAndVerifyGraphStartingWithId(long startId, int requiredHeapMb) throws Exception {
    assumeTrue(machineIsOkToRunThisTest(testName.getMethodName(), requiredHeapMb));
    /*
         * Will create a layout like this:
         * 
         * (refNode) --> (node) --> (highNode)
         *           ...
         *           ...
         *           
         * Each node/relationship will have a bunch of different properties on them.
         */
    setHighIds(startId - 1000);
    byte[] bytes = new byte[45];
    bytes[2] = 5;
    bytes[10] = 42;
    Map<String, Object> properties = map("number", 11, "short string", "test", "long string", "This is a long value, long enough", "array", bytes);
    Transaction tx = db.beginTx();
    int count = 10000;
    for (int i = 0; i < count; i++) {
        Node node = db.createNode();
        setProperties(node, properties);
        Relationship rel = db.getReferenceNode().createRelationshipTo(node, this);
        setProperties(rel, properties);
        Node highNode = db.createNode();
        node.createRelationshipTo(highNode, OTHER_TYPE);
        setProperties(highNode, properties);
        if (i % 100 == 0 && i > 0) {
            tx.success();
            tx.finish();
            tx = db.beginTx();
        }
    }
    tx.success();
    tx.finish();
    db.shutdown();
    db = new EmbeddedGraphDatabase(PATH);
    // Verify the data
    int verified = 0;
    for (Relationship rel : db.getReferenceNode().getRelationships(Direction.OUTGOING)) {
        Node node = rel.getEndNode();
        assertProperties(properties, node);
        assertProperties(properties, rel);
        Node highNode = node.getSingleRelationship(OTHER_TYPE, Direction.OUTGOING).getEndNode();
        assertProperties(properties, highNode);
        verified++;
    }
    assertEquals(count, verified);
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship)

Aggregations

EmbeddedGraphDatabase (org.neo4j.kernel.EmbeddedGraphDatabase)84 Test (org.junit.Test)50 File (java.io.File)35 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)32 Node (org.neo4j.graphdb.Node)26 Transaction (org.neo4j.graphdb.Transaction)17 Relationship (org.neo4j.graphdb.Relationship)14 BeforeClass (org.junit.BeforeClass)13 HashMap (java.util.HashMap)7 BatchInserterImpl (org.neo4j.kernel.impl.batchinsert.BatchInserterImpl)6 RandomAccessFile (java.io.RandomAccessFile)5 BatchInserter (org.neo4j.kernel.impl.batchinsert.BatchInserter)5 BatchInserterIndex (org.neo4j.graphdb.index.BatchInserterIndex)4 TransactionManager (javax.transaction.TransactionManager)3 Before (org.junit.Before)3 DynamicRelationshipType (org.neo4j.graphdb.DynamicRelationshipType)3 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)3 BatchInserterIndexProvider (org.neo4j.graphdb.index.BatchInserterIndexProvider)3 IndexManager (org.neo4j.graphdb.index.IndexManager)3 Transaction (javax.transaction.Transaction)2