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();
}
}
}
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();
}
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());
}
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));
}
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();
}
Aggregations