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();
}
Aggregations