use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class UdcExtensionImplTest method shouldRecordSuccessesWhenThereIsAServer.
@Test
public void shouldRecordSuccessesWhenThereIsAServer() throws Exception {
// first, set up the test server
LocalTestServer server = new LocalTestServer(null, null);
PingerHandler handler = new PingerHandler();
server.register("/*", handler);
server.start();
final String hostname = server.getServiceHostName();
final String serverAddress = hostname + ":" + server.getServicePort();
Map<String, String> config = new HashMap<String, String>();
config.put(UdcExtensionImpl.FIRST_DELAY_CONFIG_KEY, "100");
config.put(UdcExtensionImpl.UDC_HOST_ADDRESS_KEY, serverAddress);
EmbeddedGraphDatabase graphdb = createTempDatabase(config);
assertGotSuccessWithRetry(IS_GREATER_THAN_ZERO);
assertGotFailureWithRetry(IS_ZERO);
destroy(graphdb);
}
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();
}
}
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();
}
}
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestRecovery method testAsLittleAsPossibleRecoveryScenario.
@Test
public void testAsLittleAsPossibleRecoveryScenario() throws Exception {
GraphDatabaseService db = newGraphDbService();
Index<Node> index = db.index().forNodes("my-index");
db.beginTx();
Node node = db.createNode();
index.add(node, "key", "value");
db.shutdown();
// This doesn't seem to trigger recovery... it really should
new EmbeddedGraphDatabase(getDbPath()).shutdown();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestRecovery method testHardCoreRecovery.
@Ignore
@Test
public void testHardCoreRecovery() throws Exception {
String path = "target/hcdb";
Neo4jTestCase.deleteFileOrDirectory(new File(path));
Process process = Runtime.getRuntime().exec(new String[] { "java", "-cp", System.getProperty("java.class.path"), Inserter.class.getName(), path });
// Let it run for a while and then kill it, and wait for it to die
Thread.sleep(6000);
process.destroy();
process.waitFor();
GraphDatabaseService db = new EmbeddedGraphDatabase(path);
assertTrue(db.index().existsForNodes("myIndex"));
Index<Node> index = db.index().forNodes("myIndex");
for (Node node : db.getAllNodes()) {
for (String key : node.getPropertyKeys()) {
String value = (String) node.getProperty(key);
boolean found = false;
for (Node indexedNode : index.get(key, value)) {
if (indexedNode.equals(node)) {
found = true;
break;
}
}
if (!found) {
throw new IllegalStateException(node + " has property '" + key + "'='" + value + "', but not in index");
}
}
}
db.shutdown();
}
Aggregations