Package javax.ws.rs.client

Examples of javax.ws.rs.client.Client


        testTarget(target, false);
    }

    @Test
    public void testFromClientExecutor() throws Exception {
        final Client client = ClientBuilder.newClient();
        final RxWebTarget<RxFutureInvoker> target = Rx.from(client, RxFutureInvoker.class, executor)
                .target("http://jersey.java.net");

        testTarget(target, true);
    }
View Full Code Here


        return App.createProgrammaticClipboardApp();
    }

    @Test
    public void testClipboard() throws Exception {
        final Client client = client();
        final WebTarget clipboard = client.target(getBaseUri()).path(App.ROOT_PATH);

        Response response;

        response = clipboard.request("text/plain").get();
        assertEquals(204, response.getStatus());
View Full Code Here

        assertEquals(404, response.getStatus());
    }

    @Test
    public void testLoggingFilterClientClass() {
        Client client = client();
        client.register(CustomLoggingFilter.class).property("foo", "bar");
        CustomLoggingFilter.preFilterCalled = CustomLoggingFilter.postFilterCalled = 0;
        String s = target().path(App.ROOT_PATH).request().get(String.class);
        assertEquals(HelloWorldResource.CLICHED_MESSAGE, s);
        assertEquals(1, CustomLoggingFilter.preFilterCalled);
        assertEquals(1, CustomLoggingFilter.postFilterCalled);
View Full Code Here

        assertEquals(1, CustomLoggingFilter.postFilterCalled);
    }

    @Test
    public void testLoggingFilterClientInstance() {
        Client client = client();
        client.register(new CustomLoggingFilter()).property("foo", "bar");
        CustomLoggingFilter.preFilterCalled = CustomLoggingFilter.postFilterCalled = 0;
        String s = target().path(App.ROOT_PATH).request().get(String.class);
        assertEquals(HelloWorldResource.CLICHED_MESSAGE, s);
        assertEquals(1, CustomLoggingFilter.preFilterCalled);
        assertEquals(1, CustomLoggingFilter.postFilterCalled);
View Full Code Here

        assertEquals(1, CustomLoggingFilter.postFilterCalled);
    }

    @Test
    public void testConfigurationUpdate() {
        Client client1 = client();
        client1.register(CustomLoggingFilter.class).property("foo", "bar");

        Client client = ClientBuilder.newClient(client1.getConfiguration());
        CustomLoggingFilter.preFilterCalled = CustomLoggingFilter.postFilterCalled = 0;
        String s = target().path(App.ROOT_PATH).request().get(String.class);
        assertEquals(HelloWorldResource.CLICHED_MESSAGE, s);
        assertEquals(1, CustomLoggingFilter.preFilterCalled);
        assertEquals(1, CustomLoggingFilter.postFilterCalled);
View Full Code Here

        }
        if (clientDisable != null) {
            config.property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, clientDisable);
        }

        final Client client = ClientBuilder.newClient(config);
        final Invocation.Builder request = client.target("").request();

        assertEquals(response, request.get().readEntity(String.class));
    }
View Full Code Here

            // redirect user to Google Authorization URI.
            return Response.seeOther(UriBuilder.fromUri(googleAuthURI).build()).build();
        }
        // We have already an access token. Query the data from Google API.
        final Client client = SimpleOAuthService.getFlow().getAuthorizedClient();
        final AllTaskListsModel allTaskListsModel = getTasks(client);
        return Response.ok(allTaskListsModel).type(MediaType.TEXT_HTML_TYPE).build();
    }
View Full Code Here

        }


        // create a new Jersey client and register filter feature that will add OAuth signatures and
        // JacksonFeature that will process returned JSON data.
        final Client client = ClientBuilder.newBuilder()
                .register(filterFeature)
                .register(JacksonFeature.class)
                .build();

        // make requests to protected resources
        // (no need to care about the OAuth signatures)
        final Response response = client.target(FRIENDS_TIMELINE_URI).request().get();
        if (response.getStatus() != 200) {
            String errorEntity = null;
            if (response.hasEntity()) {
                errorEntity = response.readEntity(String.class);
            }
View Full Code Here

        return App.create();
    }

    @Test
    public void testHelloWorld() throws Exception {
        Client client = ClientBuilder.newClient();

        assertFalse(App.getMethodCalled);
        Response response = client.target(UriBuilder.fromUri(getBaseUri()).path(App.ROOT_PATH).build().toString()).request("text/plain").get();
        assertTrue(App.getMethodCalled);
        assertEquals(200, response.getStatus());
        assertTrue(response.hasEntity());
        assertTrue("Hello World!".equals(response.readEntity(String.class)));

        String s = client.target(getBaseUri()).path("helloworld").request().get(String.class);
        assertTrue(s.equals("Hello World!"));
    }
View Full Code Here

        assertTrue(s.equals("Hello World!"));
    }

    @Test
    public void testHelloWorldOtherMethods() throws Exception {
        Client client = ClientBuilder.newClient();
        assertFalse(App.headMethodCalled);
        Response response = client.target(UriBuilder.fromUri(getBaseUri()).path(App.ROOT_PATH).build().toString()).request("text/plain").head();
        assertTrue(App.headMethodCalled);
        assertEquals(204, response.getStatus());

        response = client.target(UriBuilder.fromUri(getBaseUri()).path(App.ROOT_PATH).build().toString()).request("text/plain").options();
        assertEquals(204, response.getStatus());
    }
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.