use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class ServerConfigDocIT method shouldHaveSandboxingEnabledByDefault.
@Test
public void shouldHaveSandboxingEnabledByDefault() throws Exception {
// Given
server = server().usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
String node = POST(server.baseUri().toASCIIString() + "db/data/node").location();
// When
JaxRsResponse response = new RestRequest().post(node + "/traverse/node", "{\n" + " \"order\" : \"breadth_first\",\n" + " \"return_filter\" : {\n" + " \"body\" : \"position.getClass().getClassLoader()\",\n" + " \"language\" : \"javascript\"\n" + " },\n" + " \"prune_evaluator\" : {\n" + " \"body\" : \"position.getClass().getClassLoader()\",\n" + " \"language\" : \"javascript\"\n" + " },\n" + " \"uniqueness\" : \"node_global\",\n" + " \"relationships\" : [ {\n" + " \"direction\" : \"all\",\n" + " \"type\" : \"knows\"\n" + " }, {\n" + " \"direction\" : \"all\",\n" + " \"type\" : \"loves\"\n" + " } ],\n" + " \"max_depth\" : 3\n" + "}", MediaType.APPLICATION_JSON_TYPE);
// Then
assertEquals(400, response.getStatus());
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class ServerConfigDocIT method shouldPickUpAddressFromConfig.
@Test
public void shouldPickUpAddressFromConfig() throws Exception {
ListenSocketAddress nonDefaultAddress = new ListenSocketAddress("0.0.0.0", 4321);
server = server().onAddress(nonDefaultAddress).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
assertEquals(nonDefaultAddress, server.getAddress());
JaxRsResponse response = new RestRequest(server.baseUri()).get();
assertThat(response.getStatus(), is(200));
response.close();
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldRespondWith200OnFirstDeletionOfTraversalAnd404Afterwards.
@Test
public void shouldRespondWith200OnFirstDeletionOfTraversalAnd404Afterwards() {
theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
JaxRsResponse response = createPagedTraverser();
final RestRequest request = RestRequest.req();
JaxRsResponse deleteResponse = request.delete(response.getLocation());
assertEquals(200, deleteResponse.getStatus());
deleteResponse = request.delete(response.getLocation());
assertEquals(404, deleteResponse.getStatus());
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldExpireTheTraverserAfterDefaultTimeoutAndGetA404Response.
@Test
public void shouldExpireTheTraverserAfterDefaultTimeoutAndGetA404Response() {
theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
JaxRsResponse postResponse = createPagedTraverser();
assertEquals(201, postResponse.getStatus());
final int TEN_MINUTES = 10;
clock.forward(TEN_MINUTES, TimeUnit.MINUTES);
JaxRsResponse getResponse = new RestRequest(postResponse.getLocation()).get();
assertEquals(404, getResponse.getStatus());
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldBeAbleToTraverseAllThePagesWithNonDefaultPageSize.
@Documented("Paged traverser page size.\n\n" + "The default page size is 50 items, but\n" + "depending on the application larger or smaller pages sizes might be\n" + "appropriate. This can be set by adding a +pageSize+ query parameter.")
@Test
public void shouldBeAbleToTraverseAllThePagesWithNonDefaultPageSize() {
theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
URI traverserLocation = createPagedTraverserWithPageSize(1).getLocation();
int enoughPagesToExpireTheTraverser = 12;
for (int i = 0; i < enoughPagesToExpireTheTraverser; i++) {
JaxRsResponse response = new RestRequest(traverserLocation).get();
assertEquals(200, response.getStatus());
}
JaxRsResponse response = new RestRequest(traverserLocation).get();
assertEquals(404, response.getStatus());
}
Aggregations