Package com.sun.jersey.api.client

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


  }

  @Test
  public void testShow() {
    WebResource webResource = resource();
    String responseMsg = webResource.path("helloworld").get(String.class);
    assertEquals("Hello, World!", responseMsg);
  }

}
View Full Code Here


     * "application.wadl".
     */
    @Test
    public void testApplicationWadl() {
        WebResource webResource = resource();
        String serviceWadl = webResource.path("application.wadl").
                accept(MediaTypes.WADL).get(String.class);
        assertTrue(serviceWadl.length() > 0);
    }

    /**
 
View Full Code Here

     * property.
     */
    @Test
    public void testPropertiesResource() throws IOException {
        WebResource webResource = resource();
        String sProperties = webResource.path("properties")
                .accept(MediaType.TEXT_PLAIN)
                .get(String.class);
        Properties properties = new Properties();
        properties.load(new ByteArrayInputStream(sProperties.getBytes()));
        assertNotNull("Properties does not contain 'java.class.path' property",
View Full Code Here

     * with status "OK".
     */
    @Test
    public void testGetOnDataResource() {
        WebResource webResource = resource();
        ClientResponse response = webResource.path("data")
                .accept(MediaType.TEXT_HTML)
                .get(ClientResponse.class);
        assertEquals("Request for data doesn't give expected response.",
                Response.Status.OK, response.getResponseStatus());
    }
View Full Code Here

    public void testPostOnDataResource() {
        Form formData = new Form();
        formData.add("name", "testName");
        formData.add("value", "testValue");
        WebResource webResource = resource();
        ClientResponse response = webResource.path("data")
                .type(MediaType.APPLICATION_FORM_URLENCODED)
                .post(ClientResponse.class, formData);
        assertEquals(Response.Status.OK, response.getResponseStatus());
        String responseMsg = webResource.path("data").type(MediaType.TEXT_HTML).get(String.class);
        assertTrue("Submitted data did not get added to the list...",
View Full Code Here

        WebResource webResource = resource();
        ClientResponse response = webResource.path("data")
                .type(MediaType.APPLICATION_FORM_URLENCODED)
                .post(ClientResponse.class, formData);
        assertEquals(Response.Status.OK, response.getResponseStatus());
        String responseMsg = webResource.path("data").type(MediaType.TEXT_HTML).get(String.class);
        assertTrue("Submitted data did not get added to the list...",
                responseMsg.contains("testName") && responseMsg.contains("testValue"));

    }
}
View Full Code Here

    public void signUp() {
        when(userService.createUser(any(CreateUserRequest.class), any(Role.class))).thenReturn(
                new AuthenticatedUserToken(TEST_USER.getUuid().toString(), AUTH_TOKEN.getToken()));
        WebResource webResource = resource();
        CreateUserRequest request = createSignupRequest();
        ClientResponse response = webResource.path("user").entity(request, APPLICATION_JSON).accept(APPLICATION_JSON).post(ClientResponse.class);
        assertThat(response.getStatus(), is(201));
        AuthenticatedUserToken token = response.getEntity(AuthenticatedUserToken.class);
        assertThat(token.getToken(), is(not(nullValue())));
        assertThat(token.getUserId(), is(not(nullValue())));
    }
View Full Code Here

  }

  @Test
  public void testInfoXML() throws JSONException, Exception {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("cluster")
        .path("info").accept("application/xml").get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
    String xml = response.getEntity(String.class);
    verifyClusterInfoXML(xml);
  }
View Full Code Here

  @Test
  public void testInvalidUri() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
      responseStr = r.path("ws").path("v1").path("cluster").path("bogus")
          .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());
View Full Code Here

  @Test
  public void testInvalidAccept() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
      responseStr = r.path("ws").path("v1").path("cluster")
          .accept(MediaType.TEXT_PLAIN).get(String.class);
      fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
      ClientResponse response = ue.getResponse();
      assertEquals(Status.INTERNAL_SERVER_ERROR,
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.