Package javax.ws.rs.client

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


    public void retrieveSessionToken() {
        //TODO: support authentication with JAX-RS 2.0
        //authenticator.get().addAuthenticator(client, username.get(), password.get());
        WebTarget managementResource = this.client.target(getSessionsUri());
        JsonObject result = managementResource
                .path("sessions")
                .request(MediaType.APPLICATION_JSON)
                .header("X-Requested-By", "")
                .post(Entity.entity(Json.createObjectBuilder().build(), MediaType.APPLICATION_JSON), JsonObject.class);
        JsonObject extraProps = result.getJsonObject("extraProperties");
View Full Code Here


        Post newPost = response.readEntity(Post.class);
        assertNotNull(newPost);

        // Update Post
        newPost.setTitle("Updated");
        response = target.path("id").path(newPost.getId().toString()).request().put(Entity.entity(newPost, MediaType.APPLICATION_JSON));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());

        // Delete Post
        response = target.path("id").path(newPost.getId().toString()).request().delete();
        assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
View Full Code Here

        newPost.setTitle("Updated");
        response = target.path("id").path(newPost.getId().toString()).request().put(Entity.entity(newPost, MediaType.APPLICATION_JSON));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());

        // Delete Post
        response = target.path("id").path(newPost.getId().toString()).request().delete();
        assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    }
}
View Full Code Here

    };

    private WebTarget prepareTarget(String path) {
        final WebTarget target = target();
        target.register(LoggingFilter.class);
        return target.path(path);
    }

    @Test
    public void testProgrammaticApp() throws Exception {
        Response response = prepareTarget(ROOT_PATH_PROGRAMMATIC).request("text/plain").method(TRACE.NAME);
View Full Code Here

    }

    private void _testTraceWithEntity(final boolean isAsync, final boolean useApacheConnection) throws Exception {
        try {
            WebTarget target = useApacheConnection ? getApacheClient().target(target().getUri()) : target();
            target = target.path(ROOT_PATH_ANNOTATED);

            final Entity<String> entity = Entity.entity("trace", MediaType.WILDCARD_TYPE);

            Response response;
            if (!isAsync) {
View Full Code Here

        ClientConfig config = new ClientConfig().property(ClientProperties.READ_TIMEOUT, 1000);
        config.connectorProvider(new JettyConnectorProvider());
        Client c = ClientBuilder.newClient(config);
        WebTarget t = c.target(u);
        try {
            t.path("test/timeout").request().get();
        } catch (ProcessingException e) {
            assertThat("Unexpected processing exception cause",
                    e.getCause(), instanceOf(TimeoutException.class));
        } finally {
            c.close();
View Full Code Here

        startServer(rc);

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

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

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.