Package org.apache.wink.client

Examples of org.apache.wink.client.ClientResponse


     *
     * @throws IOException
     * @throws HttpException
     */
    public void testCookiesNone() throws HttpException, IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/context/httpheaders/cookies")
                .contentType("text/plain").header(HttpHeaders.CONTENT_LANGUAGE, "zh")
                .post("Hello world!");
        assertEquals(200, response.getStatusCode());
        String responseBody = response.getEntity(String.class);
        assertEquals("cookies:", responseBody);
    }
View Full Code Here


     *
     * @throws IOException
     * @throws HttpException
     */
    public void testCookiesOneGiven() throws HttpException, IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/context/httpheaders/cookies")
                .cookie(new Cookie("foo", "bar")).post(null);
        assertEquals(200, response.getStatusCode());
        String responseBody = response.getEntity(String.class);
        assertEquals("cookies:foo=bar:", responseBody);

        response =
            client.resource(getBaseURI() + "/context/httpheaders/cookies").cookie("foo=bar")
                .post(null);
        assertEquals(200, response.getStatusCode());
        responseBody = response.getEntity(String.class);
        assertEquals("cookies:foo=bar:", responseBody);
    }
View Full Code Here

        throws IOException {
        /*
         * with Wink client, content type is set to applcation/octet-stream if
         * no content type specified
         */
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes")
                .post("calledWithString");
        assertEquals(200, response.getStatusCode());
        assertEquals("calledWithString", response.getEntity(String.class));
        String contentType =
            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
                .getFirst("Content-Type");
        assertNotNull(contentType, contentType);
    }
View Full Code Here

     *
     * @throws IOException
     */
    public void testContentTypeWithRequestEntityIncomingRequestWithNoConsumesMethod()
        throws IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes")
                .contentType("custom/type").post("myString");
        assertEquals(200, response.getStatusCode());
        assertEquals("myString", response.getEntity(String.class));
        String contentType =
            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
                .getFirst("Content-Type");
        assertNotNull(contentType, contentType);
    }
View Full Code Here

     *
     * @throws IOException
     */
    public void testContentTypeWithNoRequestEntityIncomingRequestWithNoConsumesMethod()
        throws IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes")
                .contentType("text/plain").post(null);
        assertEquals(200, response.getStatusCode());
        assertEquals("", response.getEntity(String.class));
        String contentType =
            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
                .getFirst("Content-Type");
        assertNotNull(contentType, contentType);
    }
View Full Code Here

     *
     * @throws IOException
     */
    public void testNoContentTypeWithNoRequestEntityIncomingRequestWithNoConsumesMethod()
        throws IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes").post(null);
        assertEquals(200, response.getStatusCode());
        assertEquals("userReader", response.getEntity(String.class));
        String contentType =
            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
                .getFirst("Content-Type");
        assertNotNull(contentType, contentType);
    }
View Full Code Here

     *
     * @throws IOException
     */
    public void testContentTypeWithNoRequestEntityIncomingRequestWithConsumesMethod()
        throws IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withconsumes")
                .contentType("text/plain").post(null);
        assertEquals(200, response.getStatusCode());
        assertEquals("", response.getEntity(String.class));
        String contentType =
            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
                .getFirst("Content-Type");
        assertNotNull(contentType, contentType);
    }
View Full Code Here

     *
     * @throws IOException
     */
    public void testContentTypeWithRequestEntityIncomingRequestWithConsumesMethod()
        throws IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withconsumes")
                .contentType("text/plain").post("mystring");
        assertEquals(200, response.getStatusCode());
        assertEquals("mystring", response.getEntity(String.class));
        String contentType =
            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
                .getFirst("Content-Type");
        assertNotNull(contentType, contentType);
    }
View Full Code Here

     * {@link Produces} method results in 200 successful method invocation.
     *
     * @throws IOException
     */
    public void testAcceptHeaderIncomingRequestWithProducesMethod() throws IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withproduces")
                .accept("custom/type; q=0.8").post(null);
        assertEquals(200, response.getStatusCode());
        assertEquals("calledWithProduces", response.getEntity(String.class));
        assertEquals("custom/type;q=0.8", response.getHeaders().getFirst("Content-Type"));
    }
View Full Code Here

     * {@link Produces} method results in 200 successful method invocation.
     *
     * @throws IOException
     */
    public void testAcceptHeaderIncomingRequestWithNoProducesMethod() throws IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/targeting/nullresource/withoutproduces")
                .accept("custom/type2; q=0.8").post(null);
        assertEquals(200, response.getStatusCode());
        assertEquals("calledWithoutProduces", response.getEntity(String.class));
        assertEquals("custom/type2;q=0.8", response.getHeaders().getFirst("Content-Type"));
    }
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.