Package com.proofpoint.http.client.testing

Examples of com.proofpoint.http.client.testing.TestingResponse


    @Test
    public void testMissingContentType()
    {
        SmileResponse<User> response = handler.handle(null,
                new TestingResponse(OK, ImmutableListMultimap.<String, String>of(), "hello".getBytes(UTF_8)));

        assertFalse(response.hasValue());
        assertNull(response.getException());
        assertTrue(response.getHeaders().isEmpty());
    }
View Full Code Here


        when(inputStream.read()).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class))).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class), anyInt(), anyInt())).thenThrow(expectedException);

        try {
            handler.handle(null, new TestingResponse(OK, contentType(MEDIA_TYPE_SMILE), inputStream));
            fail("expected exception");
        }
        catch (RuntimeException e) {
            assertEquals(e.getMessage(), "Error reading SMILE response from server");
            assertSame(e.getCause(), expectedException);
View Full Code Here

            new ObjectMapper(new SmileFactory()).writeValue(outputStream, value);
        }
        catch (IOException e) {
            throw propagate(e);
        }
        return new TestingResponse(status, contentType(MEDIA_TYPE_SMILE), outputStream.toByteArray());
    }
View Full Code Here

    @Test
    public void testMissingContentType()
    {
        JsonResponse<User> response = handler.handle(null,
                new TestingResponse(OK, ImmutableListMultimap.<String, String>of(), "hello".getBytes(UTF_8)));

        assertFalse(response.hasValue());
        assertNull(response.getException());
        assertNull(response.getJson());
        assertNull(response.getJsonBytes());
View Full Code Here

        when(inputStream.read()).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class))).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class), anyInt(), anyInt())).thenThrow(expectedException);

        try {
            handler.handle(null, new TestingResponse(OK, contentType(JSON_UTF_8), inputStream));
            fail("expected exception");
        }
        catch (RuntimeException e) {
            assertEquals(e.getMessage(), "Error reading response from server");
            assertSame(e.getCause(), expectedException);
View Full Code Here

        IOException expectedException = new IOException("test exception");
        when(inputStream.read()).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class))).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class), anyInt(), anyInt())).thenThrow(expectedException);

        User response = handler.handle(null, new TestingResponse(OK, contentType(JSON_UTF_8), inputStream));

        assertSame(response, DEFAULT_VALUE);
    }
View Full Code Here

    }

    @Test(expectedExceptions = UnexpectedResponseException.class, expectedExceptionsMessageRegExp = "Content-Type is not set for response")
    public void testMissingContentType()
    {
        handler.handle(null, new TestingResponse(OK, ImmutableListMultimap.<String, String>of(), "hello".getBytes(UTF_8)));
    }
View Full Code Here

        when(inputStream.read()).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class))).thenThrow(expectedException);
        when(inputStream.read(any(byte[].class), anyInt(), anyInt())).thenThrow(expectedException);

        try {
            handler.handle(null, new TestingResponse(OK, contentType(MEDIA_TYPE_SMILE), inputStream));
            fail("expected exception");
        }
        catch (RuntimeException e) {
            assertEquals(e.getMessage(), "Error reading SMILE response from server");
            assertSame(e.getCause(), expectedException);
View Full Code Here

            new ObjectMapper(new SmileFactory()).writeValue(outputStream, value);
        }
        catch (IOException e) {
            throw propagate(e);
        }
        return new TestingResponse(status, contentType(MEDIA_TYPE_SMILE), outputStream.toByteArray());
    }
View Full Code Here

    }

    @Test(expectedExceptions = UnexpectedResponseException.class, expectedExceptionsMessageRegExp = "Content-Type is not set for response")
    public void testMissingContentType()
    {
        handler.handle(null, new TestingResponse(OK, ImmutableListMultimap.<String, String>of(), "hello".getBytes(UTF_8)));
    }
View Full Code Here

TOP

Related Classes of com.proofpoint.http.client.testing.TestingResponse

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.