use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.
the class StreamingBatchOperationDocIT method shouldRollbackAllWhenGivenIncorrectRequest.
@Test
public void shouldRollbackAllWhenGivenIncorrectRequest() throws JsonParseException, ClientHandlerException, UniformInterfaceException, JSONException {
String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/node").key("body").object().key("age").value("1").endObject().endObject().object().key("method").value("POST").key("to").value("/node").key("body").array().value("a_list").value("this_makes_no_sense").endArray().endObject().endArray().toString();
long originalNodeCount = countNodes();
JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(StreamingFormat.STREAM_HEADER, "true").post(batchUri(), jsonString);
assertEquals(200, response.getStatus());
// Message of the ClassCastException differs in Oracle JDK [typeX cannot be cast to typeY]
// and IBM JDK [typeX incompatible with typeY]. That is why we check parts of the message and exception class.
Map<String, String> body = (Map) singleResult(response, 1).get("body");
assertEquals(BadInputException.class.getSimpleName(), body.get("exception"));
assertThat(body.get("message"), containsString("java.util.ArrayList"));
assertThat(body.get("message"), containsString("java.util.Map"));
assertEquals(400, singleResult(response, 1).get("status"));
assertEquals(originalNodeCount, countNodes());
}
use of org.neo4j.doc.server.rest.JaxRsResponse 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.doc.server.rest.JaxRsResponse 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