use of com.google.common.testing.FakeTicker in project neo4j by neo4j.
the class LdapCachingTest method setup.
@Before
public void setup() throws Throwable {
SecurityLog securityLog = mock(SecurityLog.class);
InternalFlatFileRealm internalFlatFileRealm = new InternalFlatFileRealm(new InMemoryUserRepository(), new InMemoryRoleRepository(), new BasicPasswordPolicy(), new RateLimitedAuthenticationStrategy(Clock.systemUTC(), 3), mock(JobScheduler.class), new InMemoryUserRepository(), new InMemoryUserRepository());
testRealm = new TestRealm(getLdapConfig(), securityLog, new SecureHasher());
List<Realm> realms = listOf(internalFlatFileRealm, testRealm);
fakeTicker = new FakeTicker();
authManager = new MultiRealmAuthManager(internalFlatFileRealm, realms, new ShiroCaffeineCache.Manager(fakeTicker::read, 100, 10), securityLog, false);
authManager.init();
authManager.start();
authManager.getUserManager().newUser("mike", "123", false);
authManager.getUserManager().newUser("mats", "456", false);
}
use of com.google.common.testing.FakeTicker in project caffeine by ben-manes.
the class CacheBuilderGwtTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
fakeTicker = new FakeTicker();
}
use of com.google.common.testing.FakeTicker in project caffeine by ben-manes.
the class CacheExpirationTest method testRemovalScheduler_expireAfterWrite.
public void testRemovalScheduler_expireAfterWrite() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder().expireAfterWrite(EXPIRING_TIME, MILLISECONDS).executor(MoreExecutors.directExecutor()).removalListener(removalListener).ticker(ticker::read), loader);
runRemovalScheduler(cache, removalListener, loader, ticker, KEY_PREFIX, EXPIRING_TIME);
}
use of com.google.common.testing.FakeTicker in project caffeine by ben-manes.
the class CacheExpirationTest method testExpiration_expireAfterAccess.
public void testExpiration_expireAfterAccess() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder().expireAfterAccess(EXPIRING_TIME, MILLISECONDS).executor(MoreExecutors.directExecutor()).removalListener(removalListener).ticker(ticker::read), loader);
checkExpiration(cache, loader, ticker, removalListener);
}
use of com.google.common.testing.FakeTicker in project caffeine by ben-manes.
the class CacheExpirationTest method testRemovalScheduler_expireAfterAccess.
public void testRemovalScheduler_expireAfterAccess() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder().expireAfterAccess(EXPIRING_TIME, MILLISECONDS).executor(MoreExecutors.directExecutor()).removalListener(removalListener).ticker(ticker::read), loader);
runRemovalScheduler(cache, removalListener, loader, ticker, KEY_PREFIX, EXPIRING_TIME);
}
Aggregations