Package com.sun.jersey.api.client

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


  @Test
  public void testHeadURL() throws Exception {
    Client client = createTestClient();
    WebResource webResource = client.resource(base_url);
    ClientResponse response = webResource.type(MediaType.APPLICATION_JSON)
                                         .head();
    assertEquals(200, response.getStatus());
  }

//  @Test
View Full Code Here


    if ( logger.isLoggable( Level.FINE ) ) {
      logger.fine( "PUT " + path.toString() );
    }

    ClientResponse response = path
      .type( JSON_TYPE ).accept( JSON_TYPE ).put( ClientResponse.class, content );
    return ActionResponse.create( response );
  }

  /**
 
View Full Code Here

    if ( logger.isLoggable( Level.FINE ) ) {
      logger.fine( "PUT " + path.toString() );
    }

    ClientResponse clientResponse = path.type( JSON_TYPE ).accept( JSON_TYPE ).put( ClientResponse.class, couchDocSerializer.serialize( doc, serializer ) );
    ActionResponse actionResponse = ActionResponse.create( clientResponse );

    //Update the rev
    doc.setRev( actionResponse.getRev() );
View Full Code Here

    if ( logger.isLoggable( Level.FINE ) ) {
      logger.fine( "HEAD " + resource.toString() );
    }

    WebResource.Builder path = resource.type( mediaType ).accept( JSON_TYPE );

    ClientResponse clientResponse = path.put( ClientResponse.class, content );
    return ActionResponse.create( clientResponse );
  }
View Full Code Here

    if ( logger.isLoggable( Level.FINE ) ) {
      logger.fine( "PUT " + resource.toString() );
    }

    ClientResponse clientResponse = resource.type( mediaType ).accept( JSON_TYPE ).put( ClientResponse.class, attachment );
    return ActionResponse.create( clientResponse );
  }

  /**
   * Posts the given stream to the db
View Full Code Here

   
    // attach the inputstream as upload info to the form
    form.bodyPart(fdp);
   
    // now post the form via the Internet/Intranet
    ClientResponse response = resource.type(MediaType.MULTIPART_FORM_DATA)
        .post(ClientResponse.class, form);
    // in debug mode show the response status
    if (debug)
      LOGGER.log(Level.INFO, "response status for '"+url+"'=" + response.getStatus());
    // if the http Status is ok
View Full Code Here

            server.start();
           
            URI u = UriBuilder.fromUri("http://localhost/").port(port).build();
            WebResource r = c.resource(u);

            String s = r.type("text/plain").post(String.class, "CONTENT");
            assertEquals("CONTENT", s);
        } finally {
            if (server != null)
                server.stop(getEnvVariable("JERSEY_HTTP_STOPSEC", 0));
        }
View Full Code Here

    }, progressMonitor);
  }

  private void postFileMultiPart(MultiPart multiPartInput, URI attachmentsUri) {
    final WebResource attachmentsResource = client.resource(attachmentsUri);
    final WebResource.Builder builder = attachmentsResource.type(MultiPartMediaTypes.createFormData());
    builder.header("X-Atlassian-Token", "nocheck"); // this is required by server side REST API
    builder.post(multiPartInput);
  }

View Full Code Here

            webResource = client().resource(user.getString("bookmarks"));

            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();
View Full Code Here

    RegistrationResponse response;
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    WebResource webResource = client.resource("http://localhost:9998/register/dummyhost");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(RegistrationResponse.class, createDummyJSONRegister());
    LOG.info("Returned from Server responce=" + response);
    Assert.assertEquals(response.getResponseStatus(), RegistrationStatus.OK);
  }
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.