Package javax.ws.rs.client

Examples of javax.ws.rs.client.Client.target()


    System.out.println(client.target(bookURI).request(MediaType.APPLICATION_JSON).get(String.class));

    System.out.println("-- PUT updated book");
    System.out.println("--------------------------");
    book.setTitle("Updated title");
    response = client.target(rootURI).request().put(Entity.entity(book, MediaType.APPLICATION_XML));
    System.out.println("\tStatus : " + response.getStatus());

    System.out.println("--- GET the created book in XML");
    System.out.println(client.target(bookURI).request(MediaType.APPLICATION_XML).get(String.class));
View Full Code Here


    book.setTitle("Updated title");
    response = client.target(rootURI).request().put(Entity.entity(book, MediaType.APPLICATION_XML));
    System.out.println("\tStatus : " + response.getStatus());

    System.out.println("--- GET the created book in XML");
    System.out.println(client.target(bookURI).request(MediaType.APPLICATION_XML).get(String.class));

    System.out.println("--- DELETE the book");
    response = client.target(rootURI).path(book.getId()).request().delete();
    System.out.println("\tStatus : " + response.getStatus());
View Full Code Here

    System.out.println("--- GET the created book in XML");
    System.out.println(client.target(bookURI).request(MediaType.APPLICATION_XML).get(String.class));

    System.out.println("--- DELETE the book");
    response = client.target(rootURI).path(book.getId()).request().delete();
    System.out.println("\tStatus : " + response.getStatus());

    System.out.println("--- GET the deted book (404-Not Found)");
    response = client.target(bookURI).request(MediaType.APPLICATION_XML).get();
    System.out.println("\tStatus : " + response.getStatus());
View Full Code Here

    System.out.println("--- DELETE the book");
    response = client.target(rootURI).path(book.getId()).request().delete();
    System.out.println("\tStatus : " + response.getStatus());

    System.out.println("--- GET the deted book (404-Not Found)");
    response = client.target(bookURI).request(MediaType.APPLICATION_XML).get();
    System.out.println("\tStatus : " + response.getStatus());
  }
}
View Full Code Here

  @Test
  public void shouldCheckForH2G2Verbose() throws URISyntaxException {

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.TEXT_PLAIN).get().getStatus());
    URI uri = new URI("http://localhost:8282/03/book");
    target = client.target(uri);
    assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.TEXT_PLAIN).get().getStatus());
  }
View Full Code Here

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.TEXT_PLAIN).get().getStatus());
    URI uri = new URI("http://localhost:8282/03/book");
    target = client.target(uri);
    assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.TEXT_PLAIN).get().getStatus());
  }

  @Test
  public void shouldCheckForH2G2WithWebTarget() {
View Full Code Here

  @Test
  public void shouldCheckForH2G2WithWebTarget() {

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    Invocation.Builder builder = target.request(MediaType.TEXT_PLAIN);
    Response response = builder.get();
    String entity = response.readEntity(String.class);

    assertEquals("H2G2", entity);
View Full Code Here

  @Test
  public void shouldCheckForH2G2WithInvocation() {

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    Invocation invocation = target.request(MediaType.TEXT_PLAIN).buildGet();
    Response response = invocation.invoke();
    String entity = response.readEntity(String.class);

    assertEquals("H2G2", entity);
View Full Code Here

    @Override
    protected Object enrichByType(Class<?> clazz, Method method, ArquillianResteasyResource annotation, Consumes consumes, Produces produces)
    {
        Object value;
        Client client = JerseyClientBuilder.newClient();
        WebTarget webTarget = client.target(getBaseURL() + annotation.value());
        final Map<String, String> headers = getHeaders(clazz, method);
        if (!headers.isEmpty()) {
            webTarget.register(new HeaderFilter(headers));
        }
        JerseyWebTarget jerseyWebTarget = (JerseyWebTarget) webTarget;
View Full Code Here

        // Make REST Request

        Client client2 = ClientFactory.newClient();
        RestUtil.initialize(client2);
        WebTarget target = client2.target(restURL);
        target.register(new HttpBasicAuthFilter(username, password));
        MultivaluedMap payLoad = new MultivaluedHashMap();
        payLoad.putSingle("remoteHostName", request.getRemoteHost());

        Response resp = target.request(RESPONSE_TYPE).post(Entity.entity(payLoad, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
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.