use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class PagedTraverserIT 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());
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class PagedTraverserIT method shouldHaveTransportEncodingChunkedOnResponseHeader.
@Test
public void shouldHaveTransportEncodingChunkedOnResponseHeader() {
// given
theStartNode = createLinkedList(VERY_LONG_LIST_LENGTH, server.getDatabase());
// when
JaxRsResponse response = createStreamingPagedTraverserWithTimeoutInMinutesAndPageSize(60, 1000);
// then
assertEquals(201, response.getStatus());
assertEquals("application/json; charset=UTF-8; stream=true", response.getHeaders().getFirst("Content-Type"));
assertThat(response.getHeaders().getFirst("Transfer-Encoding"), containsString("chunked"));
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class PagedTraverserIT 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.server.rest.JaxRsResponse in project neo4j by neo4j.
the class PagedTraverserIT method shouldTraverseAllPagesWithANonDefaultTimeoutAndNonDefaultPageSize.
@Test
public void shouldTraverseAllPagesWithANonDefaultTimeoutAndNonDefaultPageSize() {
theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
URI traverserLocation = createPagedTraverserWithTimeoutInMinutesAndPageSize(10, 2).getLocation();
int enoughPagesToExpireTheTraverser = 6;
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());
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class PagedTraverserIT method should201WithAcceptJsonHeader.
@Test
public void should201WithAcceptJsonHeader() {
// given
theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
String uri = functionalTestHelper.nodeUri(theStartNode.getId()) + "/paged/traverse/node";
// when
JaxRsResponse response = RestRequest.req().accept(MediaType.APPLICATION_JSON_TYPE).post(uri, traverserDescription());
// then
assertEquals(201, response.getStatus());
assertNotNull(response.getHeaders().getFirst("Content-Type"));
assertThat(response.getType().toString(), containsString(MediaType.APPLICATION_JSON));
}
Aggregations