Search in sources :

Example 16 with JaxRsResponse

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

the class StreamingBatchOperationDocIT method shouldRollbackAllOnSingle404.

@Test
public void shouldRollbackAllOnSingle404() throws JsonParseException, ClientHandlerException, UniformInterfaceException, JSONException {
    String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/node").key("body").object().key("age").value(1).endObject().endObject().object().key("method").value("POST").key("to").value("www.google.com").endObject().endArray().toString();
    long originalNodeCount = countNodes();
    JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(StreamingFormat.STREAM_HEADER, "true").post(batchUri(), jsonString);
    assertEquals(200, response.getStatus());
    assertEquals(404, singleResult(response, 1).get("status"));
    assertEquals(originalNodeCount, countNodes());
}
Also used : PrettyJSON(org.neo4j.doc.server.rest.PrettyJSON) Matchers.containsString(org.hamcrest.Matchers.containsString) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 17 with JaxRsResponse

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

the class StreamingBatchOperationDocIT method shouldBeAbleToReferToUniquelyCreatedEntities.

@Test
public void shouldBeAbleToReferToUniquelyCreatedEntities() throws Exception {
    String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/index/node/Cultures?unique").key("body").object().key("key").value("ID").key("value").value("fra").key("properties").object().key("ID").value("fra").endObject().endObject().key("id").value(0).endObject().object().key("method").value("POST").key("to").value("/node").key("id").value(1).endObject().object().key("method").value("POST").key("to").value("{1}/relationships").key("body").object().key("to").value("{0}").key("type").value("has").endObject().key("id").value(2).endObject().endArray().toString();
    JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(StreamingFormat.STREAM_HEADER, "true").post(batchUri(), jsonString);
    assertEquals(200, response.getStatus());
}
Also used : PrettyJSON(org.neo4j.doc.server.rest.PrettyJSON) Matchers.containsString(org.hamcrest.Matchers.containsString) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 18 with JaxRsResponse

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

the class NeoServerJAXRSDocIT method shouldMakeJAXRSClassesAvailableViaHTTP.

@Test
public void shouldMakeJAXRSClassesAvailableViaHTTP() throws Exception {
    CommunityWebContainerBuilder builder = CommunityWebContainerBuilder.builder();
    webContainer = WebContainerHelper.createContainer(builder, folder, true);
    FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(webContainer);
    JaxRsResponse response = new RestRequest().get(functionalTestHelper.baseUri().toASCIIString());
    assertEquals(200, response.getStatus());
}
Also used : CommunityWebContainerBuilder(org.neo4j.doc.server.helpers.CommunityWebContainerBuilder) RestRequest(org.neo4j.doc.server.rest.RestRequest) FunctionalTestHelper(org.neo4j.doc.server.helpers.FunctionalTestHelper) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 19 with JaxRsResponse

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

the class BatchOperationHeaderDocIT method shouldPassHeaders.

@Test
public void shouldPassHeaders() throws Exception {
    String jsonData = new PrettyJSON().array().object().key("method").value("GET").key("to").value("../.." + DUMMY_WEB_SERVICE_MOUNT_POINT + "/needs-auth-header").key("body").object().endObject().endObject().endArray().toString();
    JaxRsResponse response = new RestRequest(null, "user", "pass").post("http://localhost:7474/db/data/batch", jsonData);
    assertEquals(200, response.getStatus());
    final List<Map<String, Object>> responseData = jsonToList(response.getEntity());
    Map<String, Object> res = (Map<String, Object>) responseData.get(0).get("body");
    /*
         * {
         *   Accept=[application/json],
         *   Content-Type=[application/json],
         *   Authorization=[Basic dXNlcjpwYXNz],
         *   User-Agent=[Java/1.6.0_27] <-- ignore that, it changes often
         *   Host=[localhost:7474],
         *   Connection=[keep-alive],
         *   Content-Length=[86]
         * }
         */
    assertEquals("Basic dXNlcjpwYXNz", res.get("Authorization"));
    assertEquals("application/json", res.get("Accept"));
    assertEquals("application/json", res.get("Content-Type"));
    assertEquals("localhost:7474", res.get("Host"));
    assertEquals("keep-alive", res.get("Connection"));
}
Also used : RestRequest(org.neo4j.doc.server.rest.RestRequest) PrettyJSON(org.neo4j.doc.server.rest.PrettyJSON) JaxRsResponse(org.neo4j.doc.server.rest.JaxRsResponse) Map(java.util.Map) Test(org.junit.Test)

Example 20 with JaxRsResponse

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

the class ServerConfigDocIT 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.doc.server.rest.RestRequest) 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