use of org.neo4j.kernel.impl.factory.GraphDatabaseFacade in project neo4j by neo4j.
the class LifecycleManagingDatabaseTest method mustIgnoreExceptionsFromPreLoadingCypherQuery.
@Test
public void mustIgnoreExceptionsFromPreLoadingCypherQuery() throws Throwable {
// Given a lifecycled database that'll try to warm up Cypher when it starts
final GraphDatabaseFacade mockDb = mock(GraphDatabaseFacade.class);
Config config = Config.empty();
GraphDatabaseFacadeFactory.Dependencies deps = GraphDatabaseDependencies.newDependencies().userLogProvider(NullLogProvider.getInstance());
LifecycleManagingDatabase.GraphFactory factory = (conf, dependencies) -> mockDb;
LifecycleManagingDatabase db = new LifecycleManagingDatabase(config, factory, deps) {
@Override
protected boolean isInTestMode() {
return false;
}
};
// When the execution of the query fails (for instance when this is a slave that just joined a cluster and is
// working on catching up to the master)
when(mockDb.execute(LifecycleManagingDatabase.CYPHER_WARMUP_QUERY)).thenThrow(new TransactionFailureException("Boo"));
// Then the database should still start up as normal, without bubbling the exception up
db.init();
db.start();
assertTrue("the database should be running", db.isRunning());
db.stop();
db.shutdown();
}
Aggregations