### Question:
CachingAccessTokenResolver implements AccessTokenResolver { @Override public AccessToken resolve(final Context context, final String token) throws OAuth2TokenException { try { return cache.getValue(token, new Callable<AccessToken>() { @Override public AccessToken call() throws Exception { return resolver.resolve(context, token); } }); } catch (InterruptedException e) { throw new OAuth2TokenException("Timed out retrieving OAuth2 access token information", e); } catch (ExecutionException e) { throw new OAuth2TokenException("Initial token resolution has failed", e); } } CachingAccessTokenResolver(final AccessTokenResolver resolver,
                                      final ThreadSafeCache<String, AccessToken> cache); @Override AccessToken resolve(final Context context, final String token);  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldUseCache() throws Exception { CachingAccessTokenResolver caching = new CachingAccessTokenResolver(resolver, cache); AccessToken token = caching.resolve(new RootContext(), "TOKEN"); AccessToken token2 = caching.resolve(new RootContext(), "TOKEN"); assertThat(token).isSameAs(token2); verify(cache, times(2)).getValue(eq("TOKEN"), any(Callable.class)); }