Search in sources :

Example 16 with GraphDatabaseFacade

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();
}
Also used : GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) Config(org.neo4j.kernel.configuration.Config) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) GraphDatabaseFacadeFactory(org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TransactionFailureException(org.neo4j.graphdb.TransactionFailureException) Mockito.when(org.mockito.Mockito.when) NullLogProvider(org.neo4j.logging.NullLogProvider) Mockito.mock(org.mockito.Mockito.mock) TransactionFailureException(org.neo4j.graphdb.TransactionFailureException) Config(org.neo4j.kernel.configuration.Config) GraphDatabaseFacadeFactory(org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) Test(org.junit.Test)

Aggregations

GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)16 Test (org.junit.Test)11 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)6 Config (org.neo4j.kernel.configuration.Config)5 GraphDatabaseFacadeFactory (org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory)5 File (java.io.File)4 Result (org.neo4j.graphdb.Result)4 PlatformModule (org.neo4j.kernel.impl.factory.PlatformModule)4 EnterpriseSecurityContext (org.neo4j.kernel.enterprise.api.security.EnterpriseSecurityContext)3 Map (java.util.Map)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Transaction (org.neo4j.graphdb.Transaction)2 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)2 SecurityContext (org.neo4j.kernel.api.security.SecurityContext)2 EditionModule (org.neo4j.kernel.impl.factory.EditionModule)2 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1