Search in sources :

Example 26 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class TestGraphProperties method testEquals.

@Test
public void testEquals() {
    GraphDatabaseAPI db = (GraphDatabaseAPI) factory.newImpermanentDatabase();
    PropertyContainer graphProperties = properties(db);
    try (Transaction tx = db.beginTx()) {
        graphProperties.setProperty("test", "test");
        tx.success();
    }
    assertEquals(graphProperties, properties(db));
    db.shutdown();
    db = (GraphDatabaseAPI) factory.newImpermanentDatabase();
    assertFalse(graphProperties.equals(properties(db)));
    db.shutdown();
}
Also used : PropertyContainer(org.neo4j.graphdb.PropertyContainer) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Transaction(org.neo4j.graphdb.Transaction) Test(org.junit.Test)

Example 27 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class TestGraphProperties method produceUncleanStore.

private EphemeralFileSystemAbstraction produceUncleanStore(EphemeralFileSystemAbstraction fileSystem, File storeDir) {
    GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(fileSystem).newImpermanentDatabase(storeDir);
    Transaction tx = db.beginTx();
    Node node = db.createNode();
    node.setProperty("name", "Something");
    properties((GraphDatabaseAPI) db).setProperty("prop", "Some value");
    tx.success();
    tx.close();
    EphemeralFileSystemAbstraction snapshot = fileSystem.snapshot();
    db.shutdown();
    return snapshot;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 28 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class TestGraphProperties method twoUncleanInARow.

@Test
public void twoUncleanInARow() throws Exception {
    File storeDir = new File("dir");
    try (EphemeralFileSystemAbstraction snapshot = produceUncleanStore(fs.get(), storeDir)) {
        try (EphemeralFileSystemAbstraction snapshot2 = produceUncleanStore(snapshot, storeDir)) {
            GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setFileSystem(produceUncleanStore(snapshot2, storeDir)).newImpermanentDatabase(storeDir);
            assertThat(properties(db), inTx(db, hasProperty("prop").withValue("Some value")));
            db.shutdown();
        }
    }
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) Test(org.junit.Test)

Example 29 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class FullCheckIntegrationTest method statementOn.

private static KernelStatement statementOn(GraphDatabaseService db) {
    DependencyResolver resolver = ((GraphDatabaseAPI) db).getDependencyResolver();
    ThreadToStatementContextBridge bridge = resolver.resolveDependency(ThreadToStatementContextBridge.class);
    return (KernelStatement) bridge.get();
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 30 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class TestKernelExtension method shouldBeShutdown.

/**
     * Check that lifecycle status of extension is SHUTDOWN
     */
@Test
public void shouldBeShutdown() throws Exception {
    GraphDatabaseAPI graphdb = graphdb(0);
    graphdb.shutdown();
    assertEquals(LifecycleStatus.SHUTDOWN, graphdb.getDependencyResolver().resolveDependency(KernelExtensions.class).resolveDependency(DummyExtension.class).getStatus());
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) KernelExtensions(org.neo4j.kernel.extension.KernelExtensions) KernelExtensionFactoryContractTest(org.neo4j.kernel.extension.KernelExtensionFactoryContractTest) Test(org.junit.Test)

Aggregations

GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)133 Test (org.junit.Test)96 Transaction (org.neo4j.graphdb.Transaction)50 File (java.io.File)25 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)25 Node (org.neo4j.graphdb.Node)20 DependencyResolver (org.neo4j.graphdb.DependencyResolver)19 Config (org.neo4j.kernel.configuration.Config)15 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)12 IOException (java.io.IOException)8 PageCache (org.neo4j.io.pagecache.PageCache)8 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)8 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)8 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)7 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)6 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)6 Before (org.junit.Before)5 Label (org.neo4j.graphdb.Label)5 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)5 GuardTimeoutException (org.neo4j.kernel.guard.GuardTimeoutException)5