Package javax.ws.rs.client

Examples of javax.ws.rs.client.Invocation.submit()


            final Invocation build = "PUT".equals(method) ? request.build(method, Entity.entity("",
                    MediaType.TEXT_PLAIN_TYPE)) : request.build(method);

            try {
                build.submit(responseType);
                fail("IllegalArgumentException expected.");
            } catch (final IllegalArgumentException iae) {
                // OK.
            }
View Full Code Here


                    }
                }
            };

            final Invocation invocation = builder.buildGet();
            final Future<String> future = invocation.submit(callback);
            try {
                future.get();
                fail("future.get() should have failed.");
            } catch (final ExecutionException e) {
                final Throwable pe = e.getCause();
View Full Code Here

    public void failedUnboundGenericCallback() throws InterruptedException {
        final Invocation invocation = ClientBuilder.newClient().target("http://localhost:888/").request().buildGet();
        final CountDownLatch latch = new CountDownLatch(1);

        final MyUnboundCallback<String> callback = new MyUnboundCallback<String>(latch);
        invocation.submit(callback);

        latch.await(1, TimeUnit.SECONDS);

        assertThat(callback.getThrowable(), CoreMatchers.instanceOf(ProcessingException.class));
        assertThat(callback.getThrowable().getCause(), CoreMatchers.instanceOf(IllegalArgumentException.class));
View Full Code Here

    @Test
    // JERSEY-1412
    public void testAbortAsyncRequest() throws Exception {
        Invocation invocation = abortingTarget().request().buildPost(text("entity"));
        Future<String> future = invocation.submit(String.class);
        assertEquals("aborted", future.get());
    }

    @Test
    // JERSEY-1412
View Full Code Here

        map.add("age", "17");
        Invocation i2 = target.request().buildPost(Entity.form(map));
        out.print("POSTed request ready...<br>");

        Future<Response> f1 = i1.submit();
        Future<String> f2 = i2.submit(String.class);
        try {
            Response r1 = f1.get();
            out.println("Response from r1: " + r1.readEntity(String.class) + "<br>");
            String r2 = f2.get();
            out.println("Response from r2: " + r2 + "<br>");
View Full Code Here

        map.add("age", "17");
        Invocation i2 = target.request().buildPost(Entity.form(map));
        out.print("POSTed request ready...<br>");

        Future<Response> f1 = i1.submit();
        Future<String> f2 = i2.submit(String.class);
        try {
            Response r1 = f1.get();
            out.println("Response from r1: " + r1.readEntity(String.class) + "<br>");
            String r2 = f2.get();
            out.println("Response from r2: " + r2 + "<br>");
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.