}
@Test
public void testStateModifyExpiresCache() throws InterruptedException {
StateRepository repository = new CachingStateRepository(delegate, 10000);
// do some lookups
for (int i = 0; i < 5; i++) {
assertTrue(repository.getFeatureState(DummyFeature.TEST).isEnabled());
Thread.sleep(10);
}
// now modify the feature state
repository.setFeatureState(new FeatureState(DummyFeature.TEST, true));
// do some lookups
for (int i = 0; i < 5; i++) {
assertTrue(repository.getFeatureState(DummyFeature.TEST).isEnabled());
Thread.sleep(10);
}
// Check for the correct number of invocations
Mockito.verify(delegate, Mockito.times(2)).getFeatureState(DummyFeature.TEST);