use of org.neo4j.server.NeoServer 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();
}
use of org.neo4j.server.NeoServer in project neo4j-documentation by neo4j.
the class HTTPLoggingDocIT method givenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess.
@Test
public void givenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess() throws Exception {
// given
String directoryPrefix = testName.getMethodName();
File logDirectory = testDirectory.directory(directoryPrefix + "-logdir");
final String query = "?explicitlyEnabled=" + randomString();
NeoServer server = CommunityServerBuilder.server().withDefaultDatabaseTuning().persistent().withProperty(ServerSettings.http_logging_enabled.name(), "true").withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.getAbsolutePath()).usingDataDir(testDirectory.directory(directoryPrefix + "-dbdir").getAbsolutePath()).build();
try {
server.start();
FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server);
// when
JaxRsResponse response = new RestRequest().get(functionalTestHelper.managementUri() + query);
assertThat(response.getStatus(), is(HttpStatus.SC_OK));
response.close();
// then
File httpLog = new File(logDirectory, "http.log");
assertEventually("request appears in log", fileContentSupplier(httpLog), containsString(query), 5, TimeUnit.SECONDS);
} finally {
server.stop();
}
}
use of org.neo4j.server.NeoServer in project neo4j-documentation by neo4j.
the class HTTPLoggingDocIT method givenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses.
@Test
public void givenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses() throws Exception {
// given
String directoryPrefix = testName.getMethodName();
File logDirectory = testDirectory.directory(directoryPrefix + "-logdir");
FileUtils.forceMkdir(logDirectory);
final File confDir = testDirectory.directory(directoryPrefix + "-confdir");
FileUtils.forceMkdir(confDir);
NeoServer server = CommunityServerBuilder.server().withDefaultDatabaseTuning().withProperty(ServerSettings.http_logging_enabled.name(), "false").withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.toString()).usingDataDir(testDirectory.directory(directoryPrefix + "-dbdir").getAbsolutePath()).build();
try {
server.start();
FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server);
// when
String query = "?implicitlyDisabled" + randomString();
JaxRsResponse response = new RestRequest().get(functionalTestHelper.managementUri() + query);
assertThat(response.getStatus(), is(200));
response.close();
// then
File httpLog = new File(logDirectory, "http.log");
assertThat(httpLog.exists(), is(false));
} finally {
server.stop();
}
}
Aggregations