Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.Client


     * Instantiate client.
     *
     * @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");
    }
View Full Code Here


        httpServer = Main.startServer();

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

                singletons.add(serviceInstanceMarshaller);
                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(serviceInstanceMarshaller);
                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(serviceInstanceMarshaller);
                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(serviceInstanceMarshaller);
                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

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

    @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

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

        System.out.println("**** CustomerResource With Query params ***");
        response = wr.queryParam("start", "1").queryParam("size", "3").get(ClientResponse.class);
        Assert.assertEquals(200, response.getStatus()); // 200 = ok

        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

        else return "9095"; // default
    }

    @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

        Assert.assertEquals(200, response.getStatus()); // 200 = ok
    }

    @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

TOP

Related Classes of com.sun.jersey.api.client.Client

Copyright © 2018 www.massapicom. 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.