@Test
public void testLookupAccessTokenResponseInCache() throws InterruptedException {

    final String cacheKey = "accesstestkey1";
    Principal principal = SimplePrincipal.create("user_domain", "user",
            "auth_creds", PRINCIPAL_AUTHORITY);
    ZTSClient client = new ZTSClient("http://localhost:4080", principal);
    assertNull(client.lookupAccessTokenResponseInCache(cacheKey, 3600));
    AccessTokenResponse response1 = new AccessTokenResponse();
    response1.setExpires_in(3600);
    client.ACCESS_TOKEN_CACHE.put(cacheKey, new AccessTokenResponseCacheEntry(response1));
    // with standard 1 hour check, our entry is not expired
    assertNotNull(client.lookupAccessTokenResponseInCache(cacheKey, 3600));
    // with a 60 hour check, our entry is expired, however our entry
    // will not be removed from the cache
    assertNull(client.lookupAccessTokenResponseInCache(cacheKey, 36000));
    assertNotNull(client.ACCESS_TOKEN_CACHE.get(cacheKey));
    // add a second entry with 1 second timeout
    AccessTokenResponse response2 = new AccessTokenResponse();
    response2.setExpires_in(1);
    client.ACCESS_TOKEN_CACHE.put(cacheKey, new AccessTokenResponseCacheEntry(response2));
    // sleep a second and then ask for a cache entry
    Thread.sleep(1000);
    // entry is not returned from lookup and also removed from the cache
    assertNull(client.lookupAccessTokenResponseInCache(cacheKey, 3600));
    assertNull(client.ACCESS_TOKEN_CACHE.get(cacheKey));
    client.close();
}