@Test public void testDeleteKey() throws Exception { KeyProvider.KeyVersion mockKey = Mockito.mock(KeyProvider.KeyVersion.class); KeyProvider mockProv = Mockito.mock(KeyProvider.class); Mockito.when(mockProv.getCurrentKey(Mockito.eq("k1"))).thenReturn(mockKey); Mockito.when(mockProv.getKeyVersion(Mockito.eq("k1@0"))) .thenReturn(mockKey); Mockito.when(mockProv.getMetadata(Mockito.eq("k1"))).thenReturn( new KMSClientProvider.KMSMetadata("c", 0, "l", null, new Date(), 1)); KeyProvider cache = new CachingKeyProvider(mockProv, 100, 100); Assert.assertEquals(mockKey, cache.getCurrentKey("k1")); Mockito.verify(mockProv, Mockito.times(1)).getCurrentKey(Mockito.eq("k1")); Assert.assertEquals(mockKey, cache.getKeyVersion("k1@0")); Mockito.verify(mockProv, Mockito.times(1)) .getKeyVersion(Mockito.eq("k1@0")); cache.deleteKey("k1"); Assert.assertEquals(mockKey, cache.getCurrentKey("k1")); Mockito.verify(mockProv, Mockito.times(2)).getCurrentKey(Mockito.eq("k1")); Assert.assertEquals(mockKey, cache.getKeyVersion("k1@0")); Mockito.verify(mockProv, Mockito.times(2)) .getKeyVersion(Mockito.eq("k1@0")); }
@Override public void deleteKey(String name) throws IOException { getKeyProvider().deleteKey(name); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); getExtension().keyVersionCache.invalidateAll(); }
CachingKeyProvider extends
    KeyProviderExtension<CachingKeyProvider.CacheExtension> { @Override public void deleteKey(String name) throws IOException { getKeyProvider().deleteKey(name); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); getExtension().keyVersionCache.invalidateAll(); } }
CachingKeyProvider extends
    KeyProviderExtension<CachingKeyProvider.CacheExtension> { @Override public void deleteKey(String name) throws IOException { getKeyProvider().deleteKey(name); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); getExtension().keyVersionCache.invalidateAll(); } CachingKeyProvider(KeyProvider keyProvider, long keyTimeoutMillis,
      long currKeyTimeoutMillis); }
CachingKeyProvider extends
    KeyProviderExtension<CachingKeyProvider.CacheExtension> { @Override public void deleteKey(String name) throws IOException { getKeyProvider().deleteKey(name); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); getExtension().keyVersionCache.invalidateAll(); } CachingKeyProvider(KeyProvider keyProvider, long keyTimeoutMillis,
      long currKeyTimeoutMillis); @Override KeyVersion getCurrentKey(String name); @Override KeyVersion getKeyVersion(String versionName); @Override void deleteKey(String name); @Override KeyVersion rollNewVersion(String name, byte[] material); @Override KeyVersion rollNewVersion(String name); @Override Metadata getMetadata(String name); }
CachingKeyProvider extends
    KeyProviderExtension<CachingKeyProvider.CacheExtension> { @Override public void deleteKey(String name) throws IOException { getKeyProvider().deleteKey(name); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); getExtension().keyVersionCache.invalidateAll(); } CachingKeyProvider(KeyProvider keyProvider, long keyTimeoutMillis,
      long currKeyTimeoutMillis); @Override KeyVersion getCurrentKey(String name); @Override KeyVersion getKeyVersion(String versionName); @Override void deleteKey(String name); @Override KeyVersion rollNewVersion(String name, byte[] material); @Override KeyVersion rollNewVersion(String name); @Override Metadata getMetadata(String name);  }