Package org.apache.wink.client

Examples of org.apache.wink.client.ClientResponse


        return response.getEntity(responseEntity);
    }

    @SuppressWarnings("unchecked")
    public <T> T invoke(String method, EntityType<T> responseEntity, Object requestEntity) {
        ClientResponse response =
            invoke(method, responseEntity.getRawClass(), responseEntity.getType(), requestEntity);
        if (responseEntity == null) {
            return null;
        }
        if (ClientResponse.class.equals(responseEntity.getRawClass())) {
            return (T)response;
        }
        return response.getEntity(responseEntity);
    }
View Full Code Here


        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);

        try {
            ClientResponse response = context.doChain(request);
            int statusCode = response.getStatusCode();
            if (ClientUtils.isErrorCode(statusCode)) {
                logger.info(Messages.getMessage("clientResponseIsErrorCode"), statusCode);
                throw new ClientWebException(request, response);
            }
            return response;
View Full Code Here

    }

    private ClientResponse processResponse(ClientRequest request,
                                           HandlerContext context,
                                           HttpURLConnection connection) throws IOException {
        ClientResponse response = createResponse(request, connection);
        InputStream is = null;
        if (ClientUtils.isErrorCode(response.getStatusCode())) {
            is = connection.getErrorStream();
        } else {
            is = connection.getInputStream();
        }
        is = adaptInputStream(is, response, context.getInputStreamAdapters());
        response.setEntity(is);
        return response;
    }
View Full Code Here

        return response;
    }

    private ClientResponse createResponse(ClientRequest request, HttpURLConnection connection)
        throws IOException {
        ClientResponse response = new ClientResponseImpl();
        response.setStatusCode(connection.getResponseCode());
        response.setMessage(connection.getResponseMessage());
        response.getAttributes().putAll(request.getAttributes());
        processResponseHeaders(response, connection);
        return response;
    }
View Full Code Here

        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
        for (int c = 0; c < 5000000; ++c) {
            originalContent.write(c);
        }
        byte[] entity = originalContent.toByteArray();
        ClientResponse response =
            client.resource(new URI(getBaseURI() + "/large")).contentType(MediaType.TEXT_XML_TYPE)
                .post(entity);
        assertEquals(277, response.getStatusCode());

        InputStream respStream = response.getEntity(InputStream.class);
        for (int c = 0; c < entity.length; ++c) {
            int respByte = respStream.read();
            assertEquals(entity[c] % 256, (byte)respByte);
        }

        StringBuffer sb = new StringBuffer();
        for (int c = 0; c < 50; ++c) {
            sb.append("abcdefghijklmnopqrstuvwxyz");
        }
        assertEquals(sb.toString(), response.getHeaders().getFirst("appendStringsHeader"));
    }
View Full Code Here

     * Tests sending a JAR file.
     *
     * @throws Exception
     */
    public void testSendJAR() throws Exception {
        ClientResponse response =
            client
                .resource(getBaseURI() + "/large/zip")
                .contentType("application/jar")
                .post(new File(
                               ServerEnvironmentInfo.getWorkDir() + "/wink-itest-targeting-1.1-incubating-SNAPSHOT.war"));
        assertEquals(290, response.getStatusCode());
        assertEquals("META-INF/DEPENDENCIES", response.getEntity(String.class));
    }
View Full Code Here

        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
        for (int c = 0; c < 5000000; ++c) {
            originalContent.write(c);
        }
        byte[] entity = originalContent.toByteArray();
        ClientResponse response =
            client.resource(new URI(getBaseURI() + "/large")).contentType(MediaType.TEXT_XML_TYPE)
                .post(entity);
        assertEquals(277, response.getStatusCode());

        InputStream respStream = response.getEntity(InputStream.class);
        for (int c = 0; c < entity.length; ++c) {
            int respByte = respStream.read();
            assertEquals(entity[c] % 256, (byte)respByte);
        }

        StringBuffer sb = new StringBuffer();
        for (int c = 0; c < 50; ++c) {
            sb.append("abcdefghijklmnopqrstuvwxyz");
        }
        assertEquals(sb.toString(), response.getHeaders().getFirst("appendStringsHeader"));
    }
View Full Code Here

     * Tests sending a JAR file.
     *
     * @throws Exception
     */
    public void testSendJAR() throws Exception {
        ClientResponse response =
            client
                .resource(getBaseURI() + "/large/zip")
                .contentType("application/jar")
                .post(new File(
                               ServerEnvironmentInfo.getWorkDir() + "/wink-itest-targeting-1.1.2-incubating-SNAPSHOT.war"));
        assertEquals(290, response.getStatusCode());
        assertEquals("META-INF/DEPENDENCIES", response.getEntity(String.class));
    }
View Full Code Here

        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
        for (int c = 0; c < 5000000; ++c) {
            originalContent.write(c);
        }
        byte[] entity = originalContent.toByteArray();
        ClientResponse response =
            client.resource(new URI(getBaseURI() + "/large")).contentType(MediaType.TEXT_XML_TYPE)
                .post(entity);
        assertEquals(277, response.getStatusCode());

        InputStream respStream = response.getEntity(InputStream.class);
        for (int c = 0; c < entity.length; ++c) {
            int respByte = respStream.read();
            assertEquals(entity[c] % 256, (byte)respByte);
        }

        StringBuffer sb = new StringBuffer();
        for (int c = 0; c < 50; ++c) {
            sb.append("abcdefghijklmnopqrstuvwxyz");
        }
        assertEquals(sb.toString(), response.getHeaders().getFirst("appendStringsHeader"));
    }
View Full Code Here

     * Tests sending a JAR file.
     *
     * @throws Exception
     */
    public void testSendJAR() throws Exception {
        ClientResponse response =
            client
                .resource(getBaseURI() + "/large/zip")
                .contentType("application/jar")
                .post(new File(
                               ServerEnvironmentInfo.getWorkDir() + "/wink-itest-targeting-1.4.war"));
        assertEquals(290, response.getStatusCode());
        assertEquals("META-INF/DEPENDENCIES", response.getEntity(String.class));
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.client.ClientResponse

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.