Package javax.ws.rs.client

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


  public void shouldCheckForH2G2WithInvocation() {

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    Invocation invocation = target.request(MediaType.TEXT_PLAIN).buildGet();
    Response response = invocation.invoke();
    String entity = response.readEntity(String.class);

    assertEquals("H2G2", entity);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertEquals("H2G2 is 4 characters", 4, entity.length());
View Full Code Here


            invocation = builder.build(method);
        } else {
            invocation = builder.build(method,
                    Entity.entity(request.getEntity(), request.getMediaType()));
        }
        Response nextResponse = invocation.invoke();


        if (nextResponse.hasEntity()) {
            response.setEntityStream(nextResponse.readEntity(InputStream.class));
        }
View Full Code Here

                //Invoke
                Metrix.event("doRestCommand() - about to invoke");
                Response response;
                try {
                    response = invoc.invoke();
                } catch (ClientException ex) {
                    //Rethrow original execaption (not Throwable) for future processing
                    if (ex.getCause() != null && ex.getCause() instanceof Exception) {
                        throw (Exception) ex.getCause();
                    } else {
View Full Code Here

    } else if (expectedMediaTypeString != null) {
      invocationBuilder = invocationBuilder.accept(expectedMediaTypeString);
    }
    final Invocation invocation = getInvocationBuildInvoker(command,
        commandMetaData).invoke(invocationBuilder, method);
    final Response restResponse = invocation.invoke();
    final String serverTransactionId = restResponse
        .getHeaderString(DNSAPIClientHeaders.SERVER_TRANSACTION_ID);
    commandMetaData.put(DNSAPIClientCommandMetaData.SERVER_TRANSACTION_ID,
        serverTransactionId);
    if (restResponse.getStatus() != expectedStatusCode) {
View Full Code Here

                //Invoke
                Metrix.event("doRestCommand() - about to invoke");
                Response response;
                try {
                    response = invoc.invoke();
                } catch (ProcessingException ex) {
                    //Rethrow original execaption (not Throwable) for future processing
                    if (ex.getCause() != null && ex.getCause() instanceof Exception) {
                        throw (Exception) ex.getCause();
                    } else {
View Full Code Here

            } catch (final IllegalArgumentException iae) {
                // OK.
            }

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

    @Test
    // JERSEY-1412
    public void testAbortSyncRequest() throws Exception {
        Invocation invocation = abortingTarget().request().buildPost(text("entity"));
        String response = invocation.invoke(String.class);
        assertEquals("aborted", response);
    }

    protected WebTarget abortingTarget() {
        Client client = ClientBuilder.newClient();
View Full Code Here

        };

        WebTarget target = target().path("test");
        target.register(outFilter).register(inFilter);
        Invocation i = target.request().buildGet();
        Response r = i.invoke();

        assertEquals("head1", r.getHeaderString("head1"));
        assertEquals("cookie1", r.getCookies().get("cookie1").getValue());
        assertEquals("cookie2", r.getCookies().get("cookie2").getValue());
        assertEquals(date.getTime(), r.getDate().getTime());
View Full Code Here

        ib = target.request("*/*");
        ib.header("custom-header", "custom-value");
        ib.header("content-encoding", "deflate");
        i = ib.build("POST", Entity.entity("aaa", MediaType.WILDCARD_TYPE));
        r = i.invoke();

        reqHeaders = r.readEntity(String.class).toLowerCase();
        for (final String expected : new String[] {"custom-header:[custom-value]", "custom-header:custom-value"}) {
            assertTrue(String.format("Request headers do not contain expected '%s' entry:\n%s", expected, reqHeaders),
                    reqHeaders.contains(expected));
View Full Code Here

                reqHeaders.contains(unexpected));

        ib = target.request("*/*");
        i = ib.build("POST",
                Entity.entity("aaa", Variant.mediaTypes(MediaType.WILDCARD_TYPE).encodings("deflate").build().get(0)));
        r = i.invoke();

        final String expected = "content-encoding:[deflate]";
        reqHeaders = r.readEntity(String.class).toLowerCase();
        assertTrue(String.format("Request headers do not contain expected '%s' entry:\n%s", expected, reqHeaders),
                reqHeaders.contains(expected));
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.