Search in sources :

Example 21 with JaxRsResponse

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

the class ServerConfigDocIT method shouldGenerateWADLWhenExplicitlyEnabledInConfig.

@Test
public void shouldGenerateWADLWhenExplicitlyEnabledInConfig() throws IOException {
    server = server().withProperty(ServerSettings.wadl_enabled.name(), "true").usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
    server.start();
    JaxRsResponse response = new RestRequest().get("http://localhost:7474/application.wadl", MediaType.WILDCARD_TYPE);
    assertEquals(200, response.getStatus());
    assertEquals("application/vnd.sun.wadl+xml", response.getHeaders().get("Content-Type").iterator().next());
    assertThat(response.getEntity(), containsString("<application xmlns=\"http://wadl.dev.java" + ".net/2009/02\">"));
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 22 with JaxRsResponse

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

the class PagedTraverserDocIT method shouldAcceptJsonAndStreamingFlagAndProduceStreamedJson.

@Test
public void shouldAcceptJsonAndStreamingFlagAndProduceStreamedJson() {
    // given
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    // when
    JaxRsResponse pagedTraverserResponse = createStreamingPagedTraverserWithTimeoutInMinutesAndPageSize(60, 1);
    System.out.println(pagedTraverserResponse.getHeaders().getFirst("Content-Type"));
    // then
    assertNotNull(pagedTraverserResponse.getHeaders().getFirst("Content-Type"));
    assertThat(pagedTraverserResponse.getHeaders().getFirst("Content-Type"), containsString("application/json; charset=UTF-8; stream=true"));
}
Also used : JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 23 with JaxRsResponse

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

the class PagedTraverserDocIT 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());
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) URI(java.net.URI) Test(org.junit.Test)

Example 24 with JaxRsResponse

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

the class PagedTraverserDocIT method nodeRepresentationShouldHaveLinkToPagedTraverser.

@Test
public void nodeRepresentationShouldHaveLinkToPagedTraverser() throws Exception {
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    JaxRsResponse response = RestRequest.req().get(functionalTestHelper.nodeUri(theStartNode.getId()));
    Map<String, Object> jsonMap = JsonHelper.jsonToMap(response.getEntity());
    assertNotNull(jsonMap.containsKey(PAGED_TRAVERSE_LINK_REL));
    assertThat(String.valueOf(jsonMap.get(PAGED_TRAVERSE_LINK_REL)), containsString("/db/data/node/" + String.valueOf(theStartNode.getId()) + "/paged/traverse/{returnType}{?pageSize,leaseTime}"));
}
Also used : JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 25 with JaxRsResponse

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

the class PagedTraverserDocIT method should201WithAcceptHtmlHeader.

@Test
public void should201WithAcceptHtmlHeader() {
    // given
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    String uri = functionalTestHelper.nodeUri(theStartNode.getId()) + "/paged/traverse/node";
    // when
    JaxRsResponse response = RestRequest.req().accept(MediaType.TEXT_HTML_TYPE).post(uri, traverserDescription());
    // then
    assertEquals(201, response.getStatus());
    assertNotNull(response.getHeaders().getFirst("Content-Type"));
    assertThat(response.getType().toString(), containsString(MediaType.TEXT_HTML));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) 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