Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.WebResource.accept()


        Assert.assertEquals(200, response.getStatus()); // 200 = ok
       

        // Get plaintext
        System.out.println("*** GET Customer as plain text **");
        response = wr.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
        System.out.println("Content-Type: " + response.getHeaders().get("Content-Type"));

        System.out.println(response.getEntity(String.class));

        Assert.assertEquals(200, response.getStatus()); // 200 = ok
View Full Code Here


            JSONObject bookmark = new JSONObject();
            bookmark.put("uri", "http://java.sun.com").put("sdesc", "test desc").put("ldesc", "long test description");
            webResource.type("application/json").post(bookmark);
           
            JSONArray bookmarks = webResource.accept("application/json").get(JSONArray.class);
            assertTrue(bookmarks != null);
            int bookmarksSize = bookmarks.length();

            String testBookmarkUrl = bookmarks.getString(0);
            WebResource bookmarkResource = client().resource(testBookmarkUrl);
View Full Code Here

            int bookmarksSize = bookmarks.length();

            String testBookmarkUrl = bookmarks.getString(0);
            WebResource bookmarkResource = client().resource(testBookmarkUrl);

            bookmark = bookmarkResource.accept("application/json").get(JSONObject.class);
            assertTrue(bookmark != null);

            bookmarkResource.delete();

            bookmarks = resource().path("resources/users/testuid/bookmarks").accept("application/json").get(JSONArray.class);
View Full Code Here

  @Test
  public void testInvalidUri2() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
      responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class);
      fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
      ClientResponse response = ue.getResponse();
      assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
      WebServicesTestUtils.checkStringMatch(
View Full Code Here

  @Test
  public void testInvalidUri2() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
      responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class);
      fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
      ClientResponse response = ue.getResponse();
      assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
      WebServicesTestUtils.checkStringMatch(
View Full Code Here

  @Test
  public void testInvalidUri2() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
      responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class);
      fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
      ClientResponse response = ue.getResponse();
      assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
      WebServicesTestUtils.checkStringMatch(
View Full Code Here

  @Test
  public void testInvalidUri2() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
      responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class);
      fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
      ClientResponse response = ue.getResponse();
      assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
      WebServicesTestUtils.checkStringMatch(
View Full Code Here

        WebResource wr = r.path(path).queryParam("dataformat", encoding);
        if (data == null) {
            wr = wr.queryParam("null", "true");
        }

        Builder builder = wr.accept(accept)
            .type(MediaType.APPLICATION_OCTET_STREAM);

        ClientResponse cr;
        if (data == null) {
            cr = builder.put(ClientResponse.class);
View Full Code Here

        String name = "roottest-create";
        byte[] data = "foo".getBytes();

        WebResource wr = r.path(path).queryParam("dataformat", "utf8")
            .queryParam("name", name);
        Builder builder = wr.accept(MediaType.APPLICATION_JSON);

        ClientResponse cr;
        cr = builder.post(ClientResponse.class, data);
        assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
View Full Code Here

        }
        if (sequence) {
            wr = wr.queryParam("sequence", "true");
        }

        Builder builder = wr.accept(accept);

        ClientResponse cr;
        if (data == null) {
            cr = builder.post(ClientResponse.class);
        } else {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.