@Test
    public void testIOExceptioinHandling() {
        // A mock HttpClient that always throws the specified IOException object
        IOException simulatedIOException = new IOException("fake IOException");
        injectMockHttpClient(testedClient, new ThrowingExceptionHttpClient(simulatedIOException));
        
        // The ExecutionContext should collect the expected RequestCount
        ExecutionContext context = new ExecutionContext(true);
        
        Request<?> testedRepeatableRequest = getSampleRequestWithRepeatableContent(originalRequest);
        
        // It should keep retrying until it reaches the max retry limit and
        // throws the an ACE containing the simulated IOException.
        AmazonClientException expectedClientException = null;
        try {
            testedClient.requestExecutionBuilder()
                    .request(testedRepeatableRequest)
                    .errorResponseHandler(errorResponseHandler)
                    .executionContext(context)
                    .execute();
            Assert.fail("AmazonClientException is expected.");
        } catch (AmazonClientException ace) {
            Assert.assertTrue(simulatedIOException == ace.getCause());
            expectedClientException = ace;
        }

        // Verifies that the correct information was passed into the RetryCondition and BackoffStrategy
        verifyExpectedContextData(retryCondition,
                                  originalRequest,
                                  expectedClientException,
                                  EXPECTED_SHOULD_RETRY_CALL_COUNT); // shouldRetry is being called again to record MaxRetriesExceeded
        verifyExpectedContextData(backoffStrategy,
                                  originalRequest,
                                  expectedClientException,
                                  EXPECTED_RETRY_COUNT);
        
        // We also want to check the RequestCount metric is correctly captured.
        Assert.assertEquals(
                EXPECTED_RETRY_COUNT + 1, // request count = retries + 1
                context.getAwsRequestMetrics()
                        .getTimingInfo().getCounter(AWSRequestMetrics.Field.RequestCount.toString()).intValue());
    }
Tests AmazonHttpClient's behavior upon simulated IOException during
executing the http request when the request payload is repeatable.
aws-java-sdk-core/src/test/java/com/amazonaws/retry/AmazonHttpClientRetryPolicyTest.java