Package javax.ws.rs.client

Examples of javax.ws.rs.client.Client


    public void testStartupShutdownHooks() {
        final StartStopListener listener = new StartStopListener();

        startServer(new ResourceConfig(One.class).register(listener));

        Client client = ClientBuilder.newClient();
        WebTarget r = client.target(getUri().path("/").build());

        assertThat(r.path("one").request().get(String.class), equalTo("one"));
        assertThat(r.path("two").request().get(Response.class).getStatus(), equalTo(404));

        stopServer();
View Full Code Here


    }

    @Test
    public void testFooBarOptions() {
        startServer(HelloWorldResource.class);
        Client client = ClientBuilder.newClient();
        Response response = client.target(getUri()).path("helloworld").request().header("Accept", "foo/bar").options();
        assertEquals(200, response.getStatus());
        final String allowHeader = response.getHeaderString("Allow");
        _checkAllowContent(allowHeader);
        assertEquals(0, response.getLength());
        assertEquals("foo/bar", response.getMediaType().toString());
View Full Code Here

    }

    @Test
    public void test400StatusCode() throws IOException {
        startServer(ExceptionResource.class);
        Client client = ClientBuilder.newClient();
        WebTarget r = client.target(getUri().path("400").build());
        assertEquals(400, r.request().get(Response.class).getStatus());
    }
View Full Code Here

    }

    @Test
    public void test500StatusCode() {
        startServer(ExceptionResource.class);
        Client client = ClientBuilder.newClient();
        WebTarget r = client.target(getUri().path("500").build());

        assertEquals(500, r.request().get(Response.class).getStatus());
    }
View Full Code Here

        ClientConfig config = new ClientConfig();
        config.property(JettyClientProperties.SSL_CONFIG, sslConfig);
        config.connectorProvider(new JettyConnectorProvider());

        Client client = ClientBuilder.newClient(config);

        // client basic auth demonstration
        client.register(HttpAuthenticationFeature.basic("user", "password"));

        System.out.println("Client: GET " + Server.BASE_URI);

        WebTarget target = client.target(Server.BASE_URI);
        target.register(new LoggingFilter());

        final Response response = target.path("/").request().get(Response.class);

        assertEquals(200, response.getStatus());

        client.close();
    }
View Full Code Here

    @Test
    public void testPostChunked() {
        ClientConfig cc = new ClientConfig()
                .property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024)
                .connectorProvider(new ApacheConnectorProvider());
        Client client = ClientBuilder.newClient(cc);
        WebTarget r = getWebTarget(client);

        assertEquals("POST", r.request().post(Entity.text("POST"), String.class));

        Response cr = r.request().post(Entity.text("POST"));
View Full Code Here

        ClientConfig cc = new ClientConfig();
        cc.property(ApacheClientProperties.SSL_CONFIG, sslConfig);
        cc.connectorProvider(new ApacheConnectorProvider());

        Client client = ClientBuilder.newClient(cc);
        // client basic auth demonstration
        client.register(HttpAuthenticationFeature.basic("user", "password"));

        WebTarget target = client.target(Server.BASE_URI);
        target.register(new LoggingFilter());

        final Response response = target.path("/").request().get(Response.class);

        assertEquals(200, response.getStatus());
View Full Code Here

        ClientConfig cc = new ClientConfig();
        cc.property(ApacheClientProperties.SSL_CONFIG, sslConfig);
        cc.connectorProvider(new ApacheConnectorProvider());

        Client client = ClientBuilder.newClient(cc);

        System.out.println("Client: GET " + Server.BASE_URI);

        WebTarget target = client.target(Server.BASE_URI);
        target.register(new LoggingFilter());

        Response response;

        response = target.path("/").request().get(Response.class);
View Full Code Here

        ClientConfig cc = new ClientConfig();
        cc.property(ApacheClientProperties.SSL_CONFIG, sslConfig);
        cc.connectorProvider(new ApacheConnectorProvider());

        Client client = ClientBuilder.newClient(cc);

        System.out.println("Client: GET " + Server.BASE_URI);

        WebTarget target = client.target(Server.BASE_URI);
        target.register(new LoggingFilter());

        boolean caught = false;

        try {
View Full Code Here

        return client;
    }

    @Override
    public Client client(final Client client) {
        final Client old = this.client;
        this.client = client;
        return old;
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.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.