use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class AbstractTestBase method beforeSuite.
@BeforeClass
public static final void beforeSuite() {
deleteFileOrDirectory(new File(TARGET_NEODB));
graphdb = new EmbeddedGraphDatabase(TARGET_NEODB);
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class Neo4jAlgoTestCase method setUpGraphDb.
@BeforeClass
public static void setUpGraphDb() throws Exception {
String storeDir = "target/var/algotest";
deleteFileOrDirectory(new File(storeDir));
graphDb = new EmbeddedGraphDatabase(storeDir);
graph = new SimpleGraphBuilder(graphDb, MyRelTypes.R1);
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class PathFindingExamplesTest method startDb.
@BeforeClass
public static void startDb() {
String storeDir = "target/var/examples";
Neo4jAlgoTestCase.deleteFileOrDirectory(new File(storeDir));
graphDb = new EmbeddedGraphDatabase(storeDir);
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestKernelEvents method testRegisterUnregisterHandlers.
@Test
public void testRegisterUnregisterHandlers() {
GraphDatabaseService graphDb = new EmbeddedGraphDatabase(PATH);
KernelEventHandler handler1 = new DummyKernelEventHandler(RESOURCE1) {
public ExecutionOrder orderComparedTo(KernelEventHandler other) {
return ExecutionOrder.DOESNT_MATTER;
}
};
KernelEventHandler handler2 = new DummyKernelEventHandler(RESOURCE2) {
public ExecutionOrder orderComparedTo(KernelEventHandler other) {
return ExecutionOrder.DOESNT_MATTER;
}
};
try {
graphDb.unregisterKernelEventHandler(handler1);
fail("Shouldn't be able to do unregister on a " + "unregistered handler");
} catch (IllegalStateException e) {
/* Good */
}
assertTrue(handler1 == graphDb.registerKernelEventHandler(handler1));
assertTrue(handler1 == graphDb.registerKernelEventHandler(handler1));
assertTrue(handler1 == graphDb.unregisterKernelEventHandler(handler1));
try {
graphDb.unregisterKernelEventHandler(handler1);
fail("Shouldn't be able to do unregister on a " + "unregistered handler");
} catch (IllegalStateException e) {
/* Good */
}
assertTrue(handler1 == graphDb.registerKernelEventHandler(handler1));
assertTrue(handler2 == graphDb.registerKernelEventHandler(handler2));
assertTrue(handler1 == graphDb.unregisterKernelEventHandler(handler1));
assertTrue(handler2 == graphDb.unregisterKernelEventHandler(handler2));
graphDb.shutdown();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestKernelPanic method panicTest.
@Test
public void panicTest() throws Exception {
String path = "target/var/testdb";
AbstractNeo4jTestCase.deleteFileOrDirectory(new File(path));
EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(path);
XaDataSourceManager xaDs = graphDb.getConfig().getTxModule().getXaDataSourceManager();
IllBehavingXaDataSource noob = new IllBehavingXaDataSource();
xaDs.registerDataSource("noob", noob, UTF8.encode("554342"));
Panic panic = new Panic();
graphDb.registerKernelEventHandler(panic);
org.neo4j.graphdb.Transaction gdbTx = graphDb.beginTx();
TransactionManager txMgr = graphDb.getConfig().getTxModule().getTxManager();
Transaction tx = txMgr.getTransaction();
graphDb.createNode();
tx.enlistResource(noob.getXaConnection().getXaResource());
try {
gdbTx.success();
gdbTx.finish();
fail("Should fail");
} catch (Throwable t) {
// ok
for (int i = 0; i < 10 && panic.panic == false; i++) {
Thread.sleep(1000);
}
} finally {
graphDb.unregisterKernelEventHandler(panic);
}
assertTrue(panic.panic);
graphDb.shutdown();
}
Aggregations