Package com.sun.jersey.api.client

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


                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


                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

                singletons.add(serviceInstancesMarshaller);
                return singletons;
            }
        };
        Client          client = Client.create(config);
        WebResource     resource = client.resource("http://localhost:8080");
        ServiceNames names = resource.path("/v1/service").get(ServiceNames.class);
        Assert.assertEquals(names.getNames(), Lists.<String>newArrayList());
    }
}
View Full Code Here

    }

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

        System.out.println("**** CarResource Via @MatrixParam ***");
        ClientResponse response = wr.path("matrix/mercedes/e55;color=black/2006").get(ClientResponse.class);
        Assert.assertEquals(200, response.getStatus()); // 200 = ok

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("**** CustomerResource No Query params ***");
        ClientResponse response = wr.get(ClientResponse.class);
        Assert.assertEquals(200, response.getStatus()); // 200 = ok

View Full Code Here

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

        System.out.println("**** CustomerResource With UriInfo and Query params ***");
        // TODO there is probably some better way how to construct that url..
        response = c.resource("http://localhost:" + getJettyPort() + "/customers/uriinfo?start=2&size=2").get(ClientResponse.class);
        Assert.assertEquals(200, response.getStatus());

        System.out.println(response.getEntity(String.class));
    }
}
View Full Code Here

    }

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

        // Get customer
        System.out.println("*** GET Customer (default) **");
        ClientResponse response = wr.get(ClientResponse.class);
        System.out.println("Content-Type: " + response.getHeaders().get("Content-Type"));
View Full Code Here

    }

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

        // Get customer
        System.out.println("*** GET Customer as TXT **");
        ClientResponse response = wr.get(ClientResponse.class);
        System.out.println("Content-Type: " + response.getHeaders().get("Content-Type"));
View Full Code Here

    }

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

        // Get customer
        System.out.println("*** GET Customer as TXT **");
        ClientResponse response = wr.get(ClientResponse.class);
        System.out.println("Content-Type: " + response.getHeaders().get("Content-Type"));
View Full Code Here

            .append(escapeString(value));
      }
    }
    String querystring = b.toString();

    Builder builder = client.resource(host + path + querystring).accept("application/json");
   
    // add basic header if not present
    String user = null;
    String password = null;
    if (headerParams.containsKey("BASIC"))
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.