use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestUpgradeStore method makeSureStoreCantBeUpgradedIfNotExplicitlyToldTo2.
@Test
public void makeSureStoreCantBeUpgradedIfNotExplicitlyToldTo2() throws Exception {
String path = path(12);
new EmbeddedGraphDatabase(path).shutdown();
setOlderNeoStoreVersion(path);
try {
new EmbeddedGraphDatabase(path, stringMap(ALLOW_STORE_UPGRADE, "false"));
fail("Shouldn't be able to upgrade if not told to");
} catch (TransactionFailureException e) {
if (!(e.getCause() instanceof IllegalStoreVersionException)) {
throw e;
}
}
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestKernelEvents method testShutdownEvents.
@Test
public void testShutdownEvents() {
GraphDatabaseService graphDb = new EmbeddedGraphDatabase("target/var/neodb");
DummyKernelEventHandler handler1 = new DummyKernelEventHandler(RESOURCE1) {
public ExecutionOrder orderComparedTo(KernelEventHandler other) {
if (((DummyKernelEventHandler) other).resource == RESOURCE2) {
return ExecutionOrder.AFTER;
}
return ExecutionOrder.DOESNT_MATTER;
}
};
DummyKernelEventHandler handler2 = new DummyKernelEventHandler(RESOURCE1) {
public ExecutionOrder orderComparedTo(KernelEventHandler other) {
if (((DummyKernelEventHandler) other).resource == RESOURCE1) {
return ExecutionOrder.BEFORE;
}
return ExecutionOrder.DOESNT_MATTER;
}
};
graphDb.registerKernelEventHandler(handler1);
graphDb.registerKernelEventHandler(handler2);
graphDb.shutdown();
assertEquals(Integer.valueOf(0), handler2.beforeShutdown);
assertEquals(Integer.valueOf(1), handler1.beforeShutdown);
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestReadOnlyNeo4j method testReadOnlyOperationsAndNoTransaction.
@Test
public void testReadOnlyOperationsAndNoTransaction() {
GraphDatabaseService db = new EmbeddedGraphDatabase(PATH);
Transaction tx = db.beginTx();
Node node1 = db.createNode();
Node node2 = db.createNode();
Relationship rel = node1.createRelationshipTo(node2, withName("TEST"));
node1.setProperty("key1", "value1");
rel.setProperty("key1", "value1");
tx.success();
tx.finish();
// make sure write operations still throw exception
try {
db.createNode();
fail("Write operation and no transaction should throw exception");
} catch (NotInTransactionException e) {
// good
}
try {
node1.createRelationshipTo(node2, withName("TEST2"));
fail("Write operation and no transaction should throw exception");
} catch (NotInTransactionException e) {
// good
}
try {
node1.setProperty("key1", "value2");
fail("Write operation and no transaction should throw exception");
} catch (NotInTransactionException e) {
// good
}
try {
rel.removeProperty("key1");
fail("Write operation and no transaction should throw exception");
} catch (NotInTransactionException e) {
// good
}
// clear caches and try reads
((AbstractGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().clearCache();
assertEquals(node1, db.getNodeById(node1.getId()));
assertEquals(node2, db.getNodeById(node2.getId()));
assertEquals(rel, db.getRelationshipById(rel.getId()));
((AbstractGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().clearCache();
assertEquals("value1", node1.getProperty("key1"));
Relationship loadedRel = node1.getSingleRelationship(DynamicRelationshipType.withName("TEST"), Direction.OUTGOING);
assertEquals(rel, loadedRel);
assertEquals("value1", loadedRel.getProperty("key1"));
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class UdcExtensionImplTest method shouldNotCrashNormalGraphdbCreation.
/**
* Sanity check to make sure a database can be created
* and destroyed.
*
* @throws java.io.IOException
*/
@Test
public void shouldNotCrashNormalGraphdbCreation() throws IOException {
EmbeddedGraphDatabase graphdb = createTempDatabase(null);
destroy(graphdb);
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class UdcExtensionImplTest method shouldRecordFailuresWhenThereIsNoServer.
@Test
public void shouldRecordFailuresWhenThereIsNoServer() throws Exception {
Map<String, String> config = new HashMap<String, String>();
// first delay must be long enough to allow class initialization to complete
config.put(UdcExtensionImpl.FIRST_DELAY_CONFIG_KEY, "100");
config.put(UdcExtensionImpl.UDC_HOST_ADDRESS_KEY, "127.0.0.1:1");
EmbeddedGraphDatabase graphdb = new EmbeddedGraphDatabase("should-record-failures", config);
assertGotFailureWithRetry(IS_GREATER_THAN_ZERO);
destroy(graphdb);
}
Aggregations