@Test public void testRollNewVersion() 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); KeyProvider cache = new CachingKeyProvider(mockProv, 100, 100); Assert.assertEquals(mockKey, cache.getCurrentKey("k1")); Mockito.verify(mockProv, Mockito.times(1)).getCurrentKey(Mockito.eq("k1")); cache.rollNewVersion("k1"); Assert.assertEquals(mockKey, cache.getCurrentKey("k1")); Mockito.verify(mockProv, Mockito.times(2)).getCurrentKey(Mockito.eq("k1")); cache.rollNewVersion("k1", new byte[0]); Assert.assertEquals(mockKey, cache.getCurrentKey("k1")); Mockito.verify(mockProv, Mockito.times(3)).getCurrentKey(Mockito.eq("k1")); }
@Override public KeyVersion rollNewVersion(String name, byte[] material) throws IOException { KeyVersion key = getKeyProvider().rollNewVersion(name, material); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); return key; }
CachingKeyProvider extends
    KeyProviderExtension<CachingKeyProvider.CacheExtension> { @Override public KeyVersion rollNewVersion(String name, byte[] material) throws IOException { KeyVersion key = getKeyProvider().rollNewVersion(name, material); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); return key; } }
CachingKeyProvider extends
    KeyProviderExtension<CachingKeyProvider.CacheExtension> { @Override public KeyVersion rollNewVersion(String name, byte[] material) throws IOException { KeyVersion key = getKeyProvider().rollNewVersion(name, material); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); return key; } CachingKeyProvider(KeyProvider keyProvider, long keyTimeoutMillis,
      long currKeyTimeoutMillis); }
CachingKeyProvider extends
    KeyProviderExtension<CachingKeyProvider.CacheExtension> { @Override public KeyVersion rollNewVersion(String name, byte[] material) throws IOException { KeyVersion key = getKeyProvider().rollNewVersion(name, material); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); return key; } 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 KeyVersion rollNewVersion(String name, byte[] material) throws IOException { KeyVersion key = getKeyProvider().rollNewVersion(name, material); getExtension().currentKeyCache.invalidate(name); getExtension().keyMetadataCache.invalidate(name); return key; } 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);  }