Package com.sun.jersey.api.client

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


        client.addFilter(filter);

        // make requests to protected resources
        // (no need to care about the authorization flow)
        do {
            List<Status> statuses = client.resource(FRIENDS_TIMELINE_URI)
                    .get(new GenericType<List<Status>>() {});
            for (Status s : statuses) {
                System.out.println(s.getText());
                System.out.println("[posted by " + s.getUser().getName() + " at " + s.getCreatedAt() + "]");
            }
View Full Code Here


    }

    @Test
    public void testCustomerResourceJersey() throws Exception {
        Client c = new Client();
        WebResource wr = c.resource("http://localhost:" + getJettyPort() + "/customers");

        System.out.println("*** Create a new Customer ***");
        Customer cust = new Customer();
        cust.setFirstName("Bill");
        cust.setLastName("Burke");
View Full Code Here

    }

    @Test
    public void testCustomerResourceJersey() throws Exception {
        Client c = new Client();
        WebResource wr = c.resource("http://localhost:" + getJettyPort() + "/customers/1");

        // Show the update
        System.out.println("**** Get Unknown Customer ***");
        ClientResponse response = wr.get(ClientResponse.class);

View Full Code Here


    @Test
    public void testCustomerResourceJersey() throws Exception {
        Client c = new Client();
        WebResource wr = c.resource("http://localhost:" + getJettyPort() + "/customers");

        System.out.println("*** Create a new Customer ***");
        // Create a new customer
        String newCustomer = "<customer>"
                + "<first-name>Pavel</first-name>"
View Full Code Here

    @Test
    public void testCreateCancelPurge() throws Exception {
        Client c = new Client();
        String url = "http://localhost:" + getJettyPort() + "/shop";

        WebResource wr = c.resource(url);
        ClientResponse response = wr.head();
        Map<String, Link> shoppingLinks = processLinkHeaders(response);

        Link customers = shoppingLinks.get("customers");
        System.out.println("** Create a customer through this URL: " + customers.getHref());
View Full Code Here

        customer.setCity("Westford");
        customer.setState("MA");
        customer.setZip("01711");
        customer.setCountry("USA");

        wr = c.resource(customers.getHref());
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, customer);
        Assert.assertEquals(201, response.getStatus());

        Link orders = shoppingLinks.get("orders");
View Full Code Here

        order.setLineItems(new ArrayList<LineItem>());
        order.getLineItems().add(item);

        System.out.println();
        System.out.println("** Create an order through this URL: " + orders.getHref());
        wr = c.resource(orders.getHref());
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, order);
        Assert.assertEquals(201, response.getStatus());
        String createdOrderUrl = (String) response.getHeaders().getFirst("Location");

        System.out.println();
View Full Code Here

        Assert.assertEquals(201, response.getStatus());
        String createdOrderUrl = (String) response.getHeaders().getFirst("Location");

        System.out.println();
        System.out.println("** New list of orders");
        wr = c.resource(orders.getHref());
        response = wr.get(ClientResponse.class);
        System.out.println(response.getEntity(String.class));
        Map<String, Link> ordersLinks = processLinkHeaders(response);

        wr = c.resource(createdOrderUrl);
View Full Code Here

        wr = c.resource(orders.getHref());
        response = wr.get(ClientResponse.class);
        System.out.println(response.getEntity(String.class));
        Map<String, Link> ordersLinks = processLinkHeaders(response);

        wr = c.resource(createdOrderUrl);
        response = wr.head();
        Map<String, Link> orderLinks = processLinkHeaders(response);

        Link cancel = orderLinks.get("cancel");
        if (cancel != null) {
View Full Code Here

        Map<String, Link> orderLinks = processLinkHeaders(response);

        Link cancel = orderLinks.get("cancel");
        if (cancel != null) {
            System.out.println("** Canceling the order at URL: " + cancel.getHref());
            wr = c.resource(cancel.getHref());
            response = wr.post(ClientResponse.class);
            Assert.assertEquals(204, response.getStatus());
        }

        System.out.println();
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.