Search in sources :

Example 16 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 17 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 18 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)

Example 19 with GraphDatabaseAPI

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

the class GraphDatabaseShutdownTest method transactionShouldReleaseLocksWhenGraphDbIsBeingShutdown.

@Test
public void transactionShouldReleaseLocksWhenGraphDbIsBeingShutdown() throws Exception {
    // GIVEN
    final GraphDatabaseAPI db = newDb();
    final Locks locks = db.getDependencyResolver().resolveDependency(Locks.class);
    assertEquals(0, lockCount(locks));
    Exception exceptionThrownByTxClose = null;
    // WHEN
    try (Transaction tx = db.beginTx()) {
        Node node = db.createNode();
        tx.acquireWriteLock(node);
        assertEquals(1, lockCount(locks));
        db.shutdown();
        db.createNode();
        tx.success();
    } catch (Exception e) {
        exceptionThrownByTxClose = e;
    }
    // THEN
    assertThat(exceptionThrownByTxClose, instanceOf(DatabaseShutdownException.class));
    assertFalse(db.isAvailable(1));
    assertEquals(0, lockCount(locks));
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Locks(org.neo4j.kernel.impl.locking.Locks) Test(org.junit.Test)

Example 20 with GraphDatabaseAPI

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

the class ReadTransactionLogWritingTest method createDataset.

@Before
public void createDataset() throws IOException {
    GraphDatabaseAPI db = dbr.getGraphDatabaseAPI();
    try (Transaction tx = db.beginTx()) {
        node = db.createNode(label);
        node.setProperty("short", 123);
        node.setProperty("long", longString(300));
        relationship = node.createRelationshipTo(db.createNode(), MyRelTypes.TEST);
        relationship.setProperty("short", 123);
        relationship.setProperty("long", longString(300));
        tx.success();
    }
    logEntriesWrittenBeforeReadOperations = countLogEntries();
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Transaction(org.neo4j.graphdb.Transaction) Before(org.junit.Before)

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