Search in sources :

Example 21 with RestRequest

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

the class PluginFunctionalTestHelper method makePostList.

protected static List<Map<String, Object>> makePostList(String url) throws JsonParseException {
    JaxRsResponse response = new RestRequest().post(url, null);
    String body = getResponseText(response);
    response.close();
    return deserializeList(body);
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse)

Example 22 with RestRequest

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

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

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

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

the class ServerConfigIT method shouldEnablConsoleServiceByDefault.

@Test
public void shouldEnablConsoleServiceByDefault() throws IOException {
    // Given
    server = server().usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
    server.start();
    // When & then
    assertEquals(200, new RestRequest().get("http://localhost:7474/db/manage/server/console").getStatus());
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) 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