@Test
    public void refreshCredentialFailureUsesCachedCredentials() throws IOException {
        mockServer.setResponseContent(responseWithExpiration(DateTime.now().plusMinutes(5)));
        mockServer.setAvailableSecurityCredentials("test-credentials");

        InstanceProfileCredentialsProvider credentialsProvider = InstanceProfileCredentialsProvider.createAsyncRefreshingProvider(false);
        AWSCredentials firstCredentials = credentialsProvider.getCredentials();

        mockServer.stop();

        AWSCredentials secondCredentials = credentialsProvider.getCredentials();

        assertSame(firstCredentials, secondCredentials);
    }
Tests by initiating a refresh thread in parallel which refreshes the
credentials. Next call to credentials provider will result in refreshing
and getting new credentials.
aws-java-sdk-core/src/test/java/com/amazonaws/auth/InstanceProfileCredentialsProviderIntegrationTest.java