Package javax.ws.rs.client

Examples of javax.ws.rs.client.WebTarget.path()


        final CountDownLatch latch = new CountDownLatch(REQUESTS);
        final long tic = System.currentTimeMillis();
        final Map<Integer, String> results = new ConcurrentHashMap<Integer, String>();
        for (int i = 0; i < REQUESTS; i++) {
            final int id = i;
            target.path(ROOT_PATH).request().async().get(new InvocationCallback<Response>() {
                @Override
                public void completed(Response response) {
                    try {
                        final String result = response.readEntity(String.class);
                        results.put(id, result);
View Full Code Here


        final Client client = ClientBuilder.newClient(config);
        final WebTarget rootTarget = client.target(getBaseUri()).path(ROOT_PATH);

        // Test that connection is getting closed properly for error responses.
        try {
            final String response = rootTarget.path("error").request().get(String.class);
            fail("Exception expected. Received: " + response);
        } catch (InternalServerErrorException isee) {
            // do nothing - connection should be closed properly by now
        }
View Full Code Here

        // Fail if the previous connection has not been closed automatically.
        assertEquals(0, connectionCounter.get());

        try {
            final String response = rootTarget.path("error2").request().get(String.class);
            fail("Exception expected. Received: " + response);
        } catch (InternalServerErrorException isee) {
            assertEquals("Received unexpected data.", "Error2.", isee.getResponse().readEntity(String.class));
            // Test buffering:
            // second read would fail if entity was not buffered
View Full Code Here

        final URI u = target().getUri();
        ClientConfig config = new ClientConfig().property(ClientProperties.FOLLOW_REDIRECTS, true);
        config.connectorProvider(new JettyConnectorProvider());
        Client c = ClientBuilder.newClient(config);
        WebTarget t = c.target(u);
        Response r = t.path("test/redirect")
                .register(RedirectTestFilter.class)
                .request().get();
        assertEquals(200, r.getStatus());
        assertEquals("GET", r.readEntity(String.class));
// TODO uncomment as part of JERSEY-2388 fix.
View Full Code Here

        ClientConfig config = new ClientConfig().property(ClientProperties.FOLLOW_REDIRECTS, true);
        config.connectorProvider(new JettyConnectorProvider());
        Client client = ClientBuilder.newClient(config);
        WebTarget t = client.target(u);
        t.property(ClientProperties.FOLLOW_REDIRECTS, false);
        Response r = t.path("test/redirect").request().get();
        assertEquals(303, r.getStatus());
        client.close();
    }
}
View Full Code Here

        startServer(rc);

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

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

        // add Two resource
        reloader.reload(new ResourceConfig(One.class, Two.class));
View Full Code Here

        startServer(rc);

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

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

        // add Two resource
        reloader.reload(new ResourceConfig(One.class, Two.class));

        assertEquals("one", r.path("one").request().get(String.class));
View Full Code Here

        assertEquals(404, r.path("two").request().get(Response.class).getStatus());

        // add Two resource
        reloader.reload(new ResourceConfig(One.class, Two.class));

        assertEquals("one", r.path("one").request().get(String.class));
        assertEquals("two", r.path("two").request().get(String.class));
    }

    static class StartStopListener extends AbstractContainerLifecycleListener {
        volatile boolean started;
View Full Code Here

        // add Two resource
        reloader.reload(new ResourceConfig(One.class, Two.class));

        assertEquals("one", r.path("one").request().get(String.class));
        assertEquals("two", r.path("two").request().get(String.class));
    }

    static class StartStopListener extends AbstractContainerLifecycleListener {
        volatile boolean started;
        volatile boolean stopped;
View Full Code Here

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

        WebTarget r = ClientBuilder.newClient().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();

        assertTrue("ContainerLifecycleListener.onStartup has not been called.", listener.started);
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.