Start Neo4j Impermanent Database + REST Server on random port for test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db = new TestGraphDatabaseFactory().newImpermanentDatabase(); | |
boolean available = db.isAvailable(5000); | |
assert available; | |
int start = -1; | |
Random random = new Random(); | |
while (start != 0) { | |
port = RANDOM_PORTS_LOWER_BOUND + random.nextInt(RANDOM_PORTS_COUNT); | |
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("dbms.security.auth_enabled", 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