Search in sources :

Example 1 with ServerBootstrapper

use of org.neo4j.server.ServerBootstrapper in project open-kilda by telstra.

the class TestConfig method graphDatabaseService.

/**
 * Neo4j Server bean.
 * Runs Neo4j server for integration tests and returns {@link GraphDatabaseService} instance.
 *
 * @return {@link GraphDatabaseService}
 */
@Bean(destroyMethod = "shutdown")
public GraphDatabaseService graphDatabaseService() {
    String homeDir = "./target";
    String configFile = "./src/test/resources/neo4j.conf";
    ServerBootstrapper serverBootstrapper = new CommunityBootstrapper();
    int i = serverBootstrapper.start(new File(homeDir), Optional.of(new File(configFile)));
    switch(i) {
        case ServerBootstrapper.OK:
            logger.debug("Server started");
            break;
        case ServerBootstrapper.GRAPH_DATABASE_STARTUP_ERROR_CODE:
            logger.error("Server failed to start: graph database startup error");
            break;
        case ServerBootstrapper.WEB_SERVER_STARTUP_ERROR_CODE:
            logger.error("Server failed to start: web server startup error");
            break;
        default:
            logger.error("Server failed to start: unknown error");
            break;
    }
    NeoServer neoServer = serverBootstrapper.getServer();
    return neoServer.getDatabase().getGraph();
}
Also used : NeoServer(org.neo4j.server.NeoServer) ServerBootstrapper(org.neo4j.server.ServerBootstrapper) File(java.io.File) CommunityBootstrapper(org.neo4j.server.CommunityBootstrapper) Bean(org.springframework.context.annotation.Bean)

Aggregations

File (java.io.File)1 CommunityBootstrapper (org.neo4j.server.CommunityBootstrapper)1 NeoServer (org.neo4j.server.NeoServer)1 ServerBootstrapper (org.neo4j.server.ServerBootstrapper)1 Bean (org.springframework.context.annotation.Bean)1