@Test
    public void canBeConfiguredToOnlyRefreshCredentialsAfterFirstCallToGetCredentialsWithoutAccountId() throws InterruptedException {
        mockServer.setResponseContent(expiredResponse());
        mockServer.setAvailableSecurityCredentials("test-credentials");

        InstanceProfileCredentialsProvider credentialsProvider = InstanceProfileCredentialsProvider.createAsyncRefreshingProvider(false);
        Thread.sleep(1000);

        //Hacky assert but we know that this mockServer will create an exception that will be logged, if there's no log entry
        //then there's no exception, which means that getCredentials didn't get called on the fetcher
        assertThat(loggedEvents(), is(empty()));

        BasicSessionCredentials credentials = (BasicSessionCredentials) credentialsProvider.getCredentials();
        assertEquals("ACCESS_KEY_ID", credentials.getAWSAccessKeyId());
        assertEquals("SECRET_ACCESS_KEY", credentials.getAWSSecretKey());
        assertNull(credentials.getAccountId());
    }
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