Search in sources :

Example 26 with RestRequest

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

the class ServerConfigIT method shouldDisableConsoleServiceWhenAskedTo.

@Test
public void shouldDisableConsoleServiceWhenAskedTo() throws IOException {
    // Given
    server = server().withProperty(ServerSettings.console_module_enabled.name(), "false").usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
    server.start();
    // When & then
    assertEquals(404, new RestRequest().get("http://localhost:7474/db/manage/server/console").getStatus());
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) Test(org.junit.Test)

Example 27 with RestRequest

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

the class ServerConfigIT method shouldPickupRelativeUrisForMangementApiAndRestApi.

@Test
public void shouldPickupRelativeUrisForMangementApiAndRestApi() throws IOException {
    String dataUri = "/a/different/data/uri/";
    String managementUri = "/a/different/management/uri/";
    server = server().withRelativeRestApiUriPath(dataUri).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).withRelativeManagementApiUriPath(managementUri).build();
    server.start();
    JaxRsResponse response = new RestRequest().get("http://localhost:7474" + dataUri, MediaType.TEXT_HTML_TYPE);
    assertEquals(200, response.getStatus());
    response = new RestRequest().get("http://localhost:7474" + managementUri);
    assertEquals(200, response.getStatus());
    response.close();
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) Matchers.containsString(org.hamcrest.Matchers.containsString) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 28 with RestRequest

use of org.neo4j.server.rest.RestRequest 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());
}
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 29 with RestRequest

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

Example 30 with RestRequest

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