public void testResponseError() {
    startServer(HttpMethodResponseErrorResource.class);
    WebResource r = createClient().resource(getUri().path("test").build());

    testResponseError(r.get(ClientResponse.class));
    testResponseError(r.post(ClientResponse.class));
    testResponseError(r.put(ClientResponse.class));
    testResponseError(r.delete(ClientResponse.class));
  }
 @Test
 public void testQueryEndpointMultipleColumns() throws Exception {
   Node andres = createNode("name", "Andres");
   cypherRsPath.put(ClientResponse.class, MULTI_COLUMN_QUERY);
   ClientResponse response =
       cypherRsPath.queryParam("ids", String.valueOf(andres.getId())).get(ClientResponse.class);
   String result = response.getEntity(String.class);
   assertEquals(result, 200, response.getStatus());
   assertEquals("{\"l\":6,\"name\":\"Andres\"}", result);
 }
 @Test
 public void testQueryEndpoint() throws Exception {
   Node node = createNode("foo", "bar");
   cypherRsPath.put(ClientResponse.class, QUERY);
   ClientResponse response =
       cypherRsPath.queryParam("id", String.valueOf(node.getId())).get(ClientResponse.class);
   String result = response.getEntity(String.class);
   assertEquals(result, 200, response.getStatus());
   assertEquals("{\"foo\":\"bar\"}", result);
 }
  @Test
  public void testQueryEndpointNoResults() throws Exception {
    cypherRsPath.put(ClientResponse.class, MULTI_COLUMN_QUERY);
    ClientResponse response =
        cypherRsPath
            .queryParam("ids", String.valueOf(-234))
            .queryParam("ids", String.valueOf(-567))
            .get(ClientResponse.class);

    assertEquals(204, response.getStatus());
  }
  public void testAll() {
    startServer(HttpMethodResource.class);
    WebResource r = createClient().resource(getUri().path("test").build());
    assertEquals("GET", r.get(String.class));

    assertEquals("POST", r.post(String.class, "POST"));

    assertEquals("PUT", r.put(String.class, "PUT"));

    assertEquals("DELETE", r.delete(String.class));
  }
Example #6
0
  /** @param args */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    Message msg = new Message();
    msg.from = "*****@*****.**";
    msg.message = "World Domination now.. or never..";
    msg.targets.add(new Target("Email", "*****@*****.**"));
    msg.targets.add(new Target("Email", "*****@*****.**"));

    Client client = new Client();
    WebResource r = client.resource("http://localhost:9998/messages");

    r.accept(MediaType.APPLICATION_JSON);
    r.put(msg);
  }
 @Test
 public void testQueryEndpointMultipleResults() throws Exception {
   Node andres = createNode("name", "Andres");
   Node peter = createNode("name", "Peter");
   cypherRsPath.put(ClientResponse.class, "match n where id(n) in {ids} return n");
   ClientResponse response =
       cypherRsPath
           .queryParam("ids", String.valueOf(andres.getId()))
           .queryParam("ids", String.valueOf(peter.getId()))
           .get(ClientResponse.class);
   String result = response.getEntity(String.class);
   assertEquals(result, 200, response.getStatus());
   assertEquals("[{\"name\":\"Andres\"},{\"name\":\"Peter\"}]", result);
 }
 @Test
 public void testGetQueryWriteQueryShouldReturnInvalidMethod() throws Exception {
   cypherRsPath.put(ClientResponse.class, WRITE_QUERY);
   ClientResponse response = cypherRsPath.queryParam("name", "foobar").get(ClientResponse.class);
   assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatus());
 }
 public void testPut() {
   startServer(HttpMethodResource.class);
   WebResource r = createClient().resource(getUri().path("test").build());
   assertEquals("PUT", r.put(String.class, "PUT"));
 }