@Test
public void testAssertCredentialCachingBehavior() throws Exception
{

    AutoRefreshCredentialProvider autoRefreshCredentialProvider = new AutoRefreshCredentialProvider()
    {
        @Override
        public AwsCredential getNewAwsCredential() throws Exception
        {
            AwsCredential awsCredential = new AwsCredential();
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTimeInMillis(System.currentTimeMillis() + 1000);
            awsCredential.setAwsSessionExpirationTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));
            return awsCredential;
        }
    };
    AwsCredential firstAwsCredential = autoRefreshCredentialProvider.getAwsCredential();
    AwsCredential secondAwsCredential = autoRefreshCredentialProvider.getAwsCredential();
    assertEquals(firstAwsCredential, secondAwsCredential);
    Thread.sleep(1000);
    secondAwsCredential = autoRefreshCredentialProvider.getAwsCredential();
    assertNotEquals(firstAwsCredential, secondAwsCredential);
}