Skip to content

Instantly share code, notes, and snippets.

Created April 1, 2015 14:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Start Neo4j Impermanent Database + REST Server on random port for test
db = new TestGraphDatabaseFactory().newImpermanentDatabase();
boolean available = db.isAvailable(5000);
assert available;
int start = -1;
Random random = new Random();
while (start != 0) {
try {
GraphDatabaseAPI api = (GraphDatabaseAPI) db;
ServerConfigurator config = new ServerConfigurator(api);
config.configuration().addProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, NEO4J_EMBEDDED_HOST);
config.configuration().addProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, port);
config.configuration().addProperty("", false);
neoServerBootstrapper = new WrappingNeoServerBootstrapper(api, config);
start = neoServerBootstrapper.start();
} catch (Exception e) {
fail("Unable to start neo4j test server !", e);
this.graphFile = graphFile;
this.client = new Neo4jRestClient(NEO4J_EMBEDDED_HOST, port, NEO4J_EMBEDDED_PROTOCOL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment