Search in sources :

Example 6 with JaxRsResponse

use of org.neo4j.doc.server.rest.JaxRsResponse 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();
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 7 with JaxRsResponse

use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.

the class PagedTraverserDocIT 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));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 8 with JaxRsResponse

use of org.neo4j.doc.server.rest.JaxRsResponse 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());
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 9 with JaxRsResponse

use of org.neo4j.doc.server.rest.JaxRsResponse 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());
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 10 with JaxRsResponse

use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.

the class PagedTraverserDocIT method shouldRespondWith400OnNegativePageSize.

@Test
public void shouldRespondWith400OnNegativePageSize() {
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    int negativePageSize = -99;
    JaxRsResponse response = RestRequest.req().post(functionalTestHelper.nodeUri(theStartNode.getId()) + "/paged/traverse/node?pageSize=" + String.valueOf(negativePageSize), traverserDescription());
    assertEquals(400, response.getStatus());
}
Also used : JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)38 JaxRsResponse (org.neo4j.doc.server.rest.JaxRsResponse)38 RestRequest (org.neo4j.doc.server.rest.RestRequest)17 Matchers.containsString (org.hamcrest.Matchers.containsString)16 FunctionalTestHelper (org.neo4j.doc.server.helpers.FunctionalTestHelper)9 PrettyJSON (org.neo4j.doc.server.rest.PrettyJSON)8 Documented (org.neo4j.kernel.impl.annotations.Documented)6 URI (java.net.URI)4 Map (java.util.Map)4 Title (org.neo4j.test.TestData.Title)3 File (java.io.File)2 FileUtils.readTextFile (org.neo4j.io.fs.FileUtils.readTextFile)2 NeoServer (org.neo4j.server.NeoServer)2 Client (com.sun.jersey.api.client.Client)1 CommunityWebContainerBuilder (org.neo4j.doc.server.helpers.CommunityWebContainerBuilder)1 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)1 BadInputException (org.neo4j.server.rest.repr.BadInputException)1