Search in sources :

Example 41 with JaxRsResponse

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

the class BoltIT method boltAddressShouldComeFromConfigWhenTheListenConfigIsNotLocalhost.

@Test
public void boltAddressShouldComeFromConfigWhenTheListenConfigIsNotLocalhost() throws Throwable {
    // Given
    String host = "neo4j.com";
    startServerWithBoltEnabled(host, 9999, "localhost", 7687);
    RestRequest request = new RestRequest(server.baseUri()).host(host);
    // When
    JaxRsResponse response = request.get();
    // Then
    Map<String, Object> map = JsonHelper.jsonToMap(response.getEntity());
    assertThat(String.valueOf(map.get("bolt")), containsString("bolt://" + host + ":" + 9999));
}
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 42 with JaxRsResponse

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

the class BoltIT method boltAddressShouldAppearToComeFromTheSameOriginAsTheHttpAddressEvenThoughThisIsMorallyHazardous.

@Test
public void boltAddressShouldAppearToComeFromTheSameOriginAsTheHttpAddressEvenThoughThisIsMorallyHazardous() throws Throwable {
    // Given
    String host = "neo4j.com";
    startServerWithBoltEnabled();
    RestRequest request = new RestRequest(server.baseUri()).host(host);
    // When
    JaxRsResponse response = request.get();
    // Then
    Map<String, Object> map = JsonHelper.jsonToMap(response.getEntity());
    assertThat(String.valueOf(map.get("bolt")), containsString("bolt://" + host));
    assertFalse(String.valueOf(map.get("bolt")).contains("bolt://bolt://"));
}
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 43 with JaxRsResponse

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

the class ServerConfigIT method shouldNotGenerateWADLWhenExplicitlyDisabledInConfig.

@Test
public void shouldNotGenerateWADLWhenExplicitlyDisabledInConfig() throws IOException {
    server = server().withProperty(ServerSettings.wadl_enabled.name(), "false").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.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 44 with JaxRsResponse

use of org.neo4j.server.rest.JaxRsResponse 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 45 with JaxRsResponse

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

the class PagedTraverserIT 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.server.rest.JaxRsResponse) Test(org.junit.Test)

Aggregations

JaxRsResponse (org.neo4j.server.rest.JaxRsResponse)58 Test (org.junit.Test)52 RestRequest (org.neo4j.server.rest.RestRequest)29 Matchers.containsString (org.hamcrest.Matchers.containsString)19 FunctionalTestHelper (org.neo4j.server.helpers.FunctionalTestHelper)13 PrettyJSON (org.neo4j.server.rest.PrettyJSON)8 URI (java.net.URI)7 Documented (org.neo4j.kernel.impl.annotations.Documented)6 Map (java.util.Map)4 Client (com.sun.jersey.api.client.Client)3 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 HashMap (java.util.HashMap)1 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)1 CommunityServerBuilder (org.neo4j.server.helpers.CommunityServerBuilder)1 BadInputException (org.neo4j.server.rest.repr.BadInputException)1 NodeRepresentationTest (org.neo4j.server.rest.repr.NodeRepresentationTest)1 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)1