@Test
    @SuppressWarnings("unchecked")
    public void readResourceWithCustomRetryPolicy_DoesRetry_ForIoException() throws IOException {
        when(mockConnection.connectToEndpoint(eq(endpoint), any(Map.class), eq("GET"))).thenThrow(new IOException());

        try {
            new DefaultEC2ResourceFetcher(mockConnection).readResource(endpoint, customRetryPolicy);
            fail("Expected an IOexception");
        } catch (Exception exception) {
             Mockito.verify(mockConnection, Mockito.times(CustomRetryPolicy.MAX_RETRIES + 1)).connectToEndpoint(eq(endpoint), any(Map.class), eq("GET"));
        }
    }
When readResource is called with custom retry policy and IOException occurs,
the request is retried and the number of retries is equal to the value
returned by getMaxRetries method of the custom retry policy.
aws-java-sdk-core/src/test/java/com/amazonaws/internal/EC2ResourceFetcherTest.java