Search in sources :

Example 6 with Unmarshaller

use of com.amazonaws.transform.Unmarshaller in project aws-sdk-android by aws-amplify.

the class DefaultErrorResponseHandlerTest method testDefaultErrorResponseHandlerCannotGetContent.

@Test
public void testDefaultErrorResponseHandlerCannotGetContent() throws Exception {
    List<Unmarshaller<AmazonServiceException, Node>> unmarshallerList = new ArrayList<Unmarshaller<AmazonServiceException, Node>>();
    HttpResponse errorResponse = new HttpResponse.Builder().statusCode(400).statusText("Error").content(new InputStream() {

        @Override
        public int read() throws IOException {
            throw new IOException("Test IOException");
        }
    }).build();
    DefaultErrorResponseHandler handler = new DefaultErrorResponseHandler(unmarshallerList);
    AmazonServiceException e = handler.handle(errorResponse);
    assertEquals(e.getErrorCode(), errorResponse.getStatusCode() + " " + errorResponse.getStatusText());
    assertEquals(e.getStatusCode(), 400);
    assertEquals(e.getErrorType(), ErrorType.Unknown);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) AmazonServiceException(com.amazonaws.AmazonServiceException) IOException(java.io.IOException) Unmarshaller(com.amazonaws.transform.Unmarshaller) Test(org.junit.Test)

Aggregations

Unmarshaller (com.amazonaws.transform.Unmarshaller)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Test (org.junit.Test)6 JsonUnmarshallerContext (com.amazonaws.transform.JsonUnmarshallerContext)3 ArrayList (java.util.ArrayList)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2 InputStream (java.io.InputStream)2 CRC32 (java.util.zip.CRC32)2 Node (org.w3c.dom.Node)2 StaxUnmarshallerContext (com.amazonaws.transform.StaxUnmarshallerContext)1 IOException (java.io.IOException)1