Search in sources :

Example 1 with JaxRsResponse

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

the class NeoServerDefaultPortAndHostnameDocIT method shouldDefaultToSensiblePortIfNoneSpecifiedInConfig.

@Test
public void shouldDefaultToSensiblePortIfNoneSpecifiedInConfig() throws Exception {
    FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server());
    JaxRsResponse response = functionalTestHelper.get(functionalTestHelper.managementUri());
    assertThat(response.getStatus(), is(200));
}
Also used : FunctionalTestHelper(org.neo4j.doc.server.helpers.FunctionalTestHelper) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 2 with JaxRsResponse

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

the class NeoServerStartupLoggingDocIT 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.doc.server.rest.RestRequest) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Client(com.sun.jersey.api.client.Client) Test(org.junit.Test)

Example 3 with JaxRsResponse

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

the class ServerConfigDocIT 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.doc.server.rest.RestRequest) Matchers.containsString(org.hamcrest.Matchers.containsString) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 4 with JaxRsResponse

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

the class ServerConfigDocIT method shouldNotGenerateWADLWhenNotExplicitlyEnabledInConfig.

@Test
public void shouldNotGenerateWADLWhenNotExplicitlyEnabledInConfig() throws IOException {
    server = server().usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
    server.start();
    JaxRsResponse response = new RestRequest().get("http://localhost:7474/application.wadl", MediaType.WILDCARD_TYPE);
    assertEquals(404, response.getStatus());
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 5 with JaxRsResponse

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

the class ServerConfigDocIT method shouldHaveSandboxingEnabledByDefault.

@Test
public void shouldHaveSandboxingEnabledByDefault() throws Exception {
    // Given
    server = server().usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
    server.start();
    String node = POST(server.baseUri().toASCIIString() + "db/data/node").location();
    // When
    JaxRsResponse response = new RestRequest().post(node + "/traverse/node", "{\n" + "  \"order\" : \"breadth_first\",\n" + "  \"return_filter\" : {\n" + "    \"body\" : \"position.getClass().getClassLoader()\",\n" + "    \"language\" : \"javascript\"\n" + "  },\n" + "  \"prune_evaluator\" : {\n" + "    \"body\" : \"position.getClass().getClassLoader()\",\n" + "    \"language\" : \"javascript\"\n" + "  },\n" + "  \"uniqueness\" : \"node_global\",\n" + "  \"relationships\" : [ {\n" + "    \"direction\" : \"all\",\n" + "    \"type\" : \"knows\"\n" + "  }, {\n" + "    \"direction\" : \"all\",\n" + "    \"type\" : \"loves\"\n" + "  } ],\n" + "  \"max_depth\" : 3\n" + "}", MediaType.APPLICATION_JSON_TYPE);
    // Then
    assertEquals(400, response.getStatus());
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) 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