Search in sources :

Example 6 with RestRequest

use of org.neo4j.server.rest.RestRequest in project neo4j by neo4j.

the class PagedTraverserIT method shouldBeAbleToTraverseAllThePagesWithDefaultPageSize.

@Documented("Paging through the results of a paged traverser.\n\n" + "Paged traversers holdstate on the server, and allow clients to page through\n" + "the results of a traversal. To progress to the next page of traversal results,\n" + "the client issues a HTTP GET request on the paged traversal URI which causes the\n" + "traversal to fill the next page (or partially fill it if insufficient\n" + "results are available).\n" + " \n" + "Note that if a traverser expires through inactivity it will cause a 404\n" + "response on the next +GET+ request. Traversers' leases are renewed on\n" + "every successful access for the same amount of time as originally\n" + "specified.\n" + " \n" + "When the paged traverser reaches the end of its results, the client can\n" + "expect a 404 response as the traverser is disposed by the server.")
@Test
public void shouldBeAbleToTraverseAllThePagesWithDefaultPageSize() {
    theStartNode = createLinkedList(LONG_LIST_LENGTH, server.getDatabase());
    URI traverserLocation = createPagedTraverser().getLocation();
    int enoughPagesToExpireTheTraverser = 3;
    for (int i = 0; i < enoughPagesToExpireTheTraverser; i++) {
        gen.get().expectedType(MediaType.APPLICATION_JSON_TYPE).expectedStatus(200).payload(traverserDescription()).get(traverserLocation.toString());
    }
    JaxRsResponse response = new RestRequest(traverserLocation).get();
    assertEquals(404, response.getStatus());
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) URI(java.net.URI) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 7 with RestRequest

use of org.neo4j.server.rest.RestRequest in project neo4j by neo4j.

the class PagedTraverserIT method shouldExpireTraverserWithNonDefaultTimeout.

@Documented("Paged traverser timeout.\n\n" + "The default timeout for a paged traverser is 60\n" + "seconds, but depending on the application larger or smaller timeouts\n" + "might be appropriate. This can be set by adding a +leaseTime+ query\n" + "parameter with the number of seconds the paged traverser should last.")
@Test
public void shouldExpireTraverserWithNonDefaultTimeout() {
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    URI traverserLocation = createPagedTraverserWithTimeoutInMinutes(10).getLocation();
    clock.forward(11, TimeUnit.MINUTES);
    JaxRsResponse response = new RestRequest(traverserLocation).get();
    assertEquals(404, response.getStatus());
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) URI(java.net.URI) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 8 with RestRequest

use of org.neo4j.server.rest.RestRequest in project neo4j by neo4j.

the class NeoServerJAXRSIT method shouldMakeJAXRSClassesAvailableViaHTTP.

@Test
public void shouldMakeJAXRSClassesAvailableViaHTTP() throws Exception {
    CommunityServerBuilder builder = CommunityServerBuilder.server();
    server = ServerHelper.createNonPersistentServer(builder);
    FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server);
    JaxRsResponse response = new RestRequest().get(functionalTestHelper.managementUri());
    assertEquals(200, response.getStatus());
    response.close();
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) CommunityServerBuilder(org.neo4j.server.helpers.CommunityServerBuilder) FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 9 with RestRequest

use of org.neo4j.server.rest.RestRequest in project neo4j by neo4j.

the class NeoServerStartupLoggingIT method shouldLogStartup.

@Test
public void shouldLogStartup() throws Exception {
    // Check the logs
    assertThat(out.toString().length(), is(greaterThan(0)));
    // Check the server is alive
    Client nonRedirectingClient = Client.create();
    nonRedirectingClient.setFollowRedirects(false);
    final JaxRsResponse response = new RestRequest(server.baseUri(), nonRedirectingClient).get();
    assertThat(response.getStatus(), is(greaterThan(199)));
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Client(com.sun.jersey.api.client.Client) Test(org.junit.Test)

Example 10 with RestRequest

use of org.neo4j.server.rest.RestRequest in project neo4j by neo4j.

the class RedirectToBrowserTest method shouldRedirectToBrowserUsingXForwardedHeaders.

@Test
public void shouldRedirectToBrowserUsingXForwardedHeaders() throws Exception {
    Client nonRedirectingClient = Client.create();
    nonRedirectingClient.setFollowRedirects(false);
    final JaxRsResponse response = new RestRequest(server.baseUri(), nonRedirectingClient).accept(MediaType.TEXT_HTML_TYPE).header("X-Forwarded-Host", "foo.bar:8734").header("X-Forwarded-Proto", "https").get(server.baseUri().toString());
    assertEquals(303, response.getStatus());
    assertEquals(new URI("https://foo.bar:8734/browser/"), response.getLocation());
    response.close();
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Client(com.sun.jersey.api.client.Client) URI(java.net.URI) Test(org.junit.Test)

Aggregations

RestRequest (org.neo4j.server.rest.RestRequest)31 JaxRsResponse (org.neo4j.server.rest.JaxRsResponse)29 Test (org.junit.Test)26 Matchers.containsString (org.hamcrest.Matchers.containsString)7 URI (java.net.URI)6 Client (com.sun.jersey.api.client.Client)3 Documented (org.neo4j.kernel.impl.annotations.Documented)3 FunctionalTestHelper (org.neo4j.server.helpers.FunctionalTestHelper)3 File (java.io.File)2 FileUtils.readTextFile (org.neo4j.io.fs.FileUtils.readTextFile)2 NeoServer (org.neo4j.server.NeoServer)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)1 CommunityServerBuilder (org.neo4j.server.helpers.CommunityServerBuilder)1 PrettyJSON (org.neo4j.server.rest.PrettyJSON)1 NodeRepresentationTest (org.neo4j.server.rest.repr.NodeRepresentationTest)1 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)1