Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.Client.resource()


            Assert.assertEquals(204, response.getStatus());
        }

        System.out.println();
        System.out.println("** New list of orders after cancel: ");
        wr = c.resource(orders.getHref());
        response = wr.get(ClientResponse.class);
        System.out.println(response.getEntity(String.class));

        System.out.println();
        Link purge = ordersLinks.get("purge");
View Full Code Here


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

        System.out.println();
        Link purge = ordersLinks.get("purge");
        System.out.println("** Purge cancelled orders at URL: " + purge.getHref());
        wr = c.resource(purge.getHref());
        response = wr.post(ClientResponse.class);
        Assert.assertEquals(204, response.getStatus());

        System.out.println();
        System.out.println("** New list of orders after purge: ");
View Full Code Here

        response = wr.post(ClientResponse.class);
        Assert.assertEquals(204, response.getStatus());

        System.out.println();
        System.out.println("** New list of orders after purge: ");
        wr = c.resource(orders.getHref());
        response = wr.get(ClientResponse.class);
        System.out.println(response.getEntity(String.class));
    }
}
View Full Code Here

  @Test
  public void testRegistration() throws Exception {
    RegistrationResponse response;
    Client client = createTestClient();
    WebResource webResource = client.resource(base_url + "test/register");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(RegistrationResponse.class, createDummyJSONRegister());
    Assert.assertEquals(RegistrationStatus.OK, response.getResponseStatus());
  }
View Full Code Here

  @Test
  public void testHeartbeat() throws Exception {
    HeartBeatResponse response;
    Client client = createTestClient();
    WebResource webResource = client.resource(base_url + "test/heartbeat");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(HeartBeatResponse.class, createDummyHeartBeat());
    assertEquals(response.getResponseId(), 0L);
  }
View Full Code Here

  }

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

            };
            server.createContext("/", handler);
            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)
View Full Code Here

     * @param location URL to the base of resources, e.g. http://localhost:8080/template-server/rest
     */
    public TalkClient(String location) {
        Client client = Client.create();
        client.addFilter(new LoggingFilter(System.out));
        webResource = client.resource(location + "/talk");
    }

    @Override
    public Sentence greeting() {
        Sentence s = webResource.accept(MediaType.APPLICATION_XML).get(Sentence.class);
View Full Code Here

        ClientConfig cc = new DefaultClientConfig();
        // use the following jaxb context resolver
        cc.getClasses().add(JAXBContextResolver.class);
        Client c = Client.create(cc);
        r = c.resource(Main.BASE_URI);
    }

    @After
    public void tearDown() throws Exception {
        httpServer.stop();
View Full Code Here

                singletons.add(serviceInstancesMarshaller);
                return singletons;
            }
        };
        Client          client = Client.create(config);
        WebResource     resource = client.resource("http://localhost:8080");
          resource.path("/v1/service/test/" + service.getId()).type(MediaType.APPLICATION_JSON_TYPE).put(service);

        ServiceNames names = resource.path("/v1/service").get(ServiceNames.class);
        Assert.assertEquals(names.getNames(), Lists.newArrayList("test"));
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.