Examples of TestingResponse


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

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

        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

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

            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

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

    @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

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

        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

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

        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

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

    }

    @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

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

        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

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

            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

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

    }

    @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
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.