@Test(timeout = 5000) public void testSigningInfoReads() throws Exception { CachingKeyConfImpl.invalidateCaches(); AtomicInteger callsToGetInfo = new AtomicInteger(0); ClientId client1 = ClientId.create("FI", "GOV", "1"); ClientId client2 = ClientId.create("FI", "GOV", "1", "SS"); ClientId client3 = ClientId.create("FI", "GOV", "2"); List<ClientId> clients = Arrays.asList(client1, client2, client3); int expectedCacheHits = 0; doConcurrentSigningInfoReads(callsToGetInfo, clients, UNCHANGED_KEY_CONF, VALID_AUTH_KEY, VALID_SIGNING_INFO, 5, 5, NO_DELAY); expectedCacheHits = expectedCacheHits + 3; assertEquals(expectedCacheHits, callsToGetInfo.get()); CachingKeyConfImpl.invalidateCaches(); BooleanSupplier suddenlyInvalid = new BooleanSupplier() { AtomicInteger counter = new AtomicInteger(0); @Override public boolean getAsBoolean() { int number = counter.getAndIncrement(); if (number == 10) { return false; } else { return true; } } }; doConcurrentSigningInfoReads(callsToGetInfo, clients, UNCHANGED_KEY_CONF, VALID_AUTH_KEY, suddenlyInvalid, 5, 5, NO_DELAY); expectedCacheHits = expectedCacheHits + 4; assertEquals(expectedCacheHits, callsToGetInfo.get()); doConcurrentAuthKeyReads(callsToGetInfo, CHANGED_KEY_CONF, VALID_AUTH_KEY, VALID_SIGNING_INFO, 5, NO_LOOPING, 500); int expectedMinimumCacheHits = expectedCacheHits + 1; int expectedMaximumCacheHits = expectedCacheHits + 5; assertThat(callsToGetInfo.get(), allOf( greaterThanOrEqualTo(expectedMinimumCacheHits), lessThanOrEqualTo(expectedMaximumCacheHits))); log.debug("total cache hits: {}", callsToGetInfo.get()); }
protected static void invalidateCaches() { AUTH_KEY_CACHE.invalidateAll(); SIGNING_INFO_CACHE.invalidateAll(); }
CachingKeyConfImpl extends KeyConfImpl { protected static void invalidateCaches() { AUTH_KEY_CACHE.invalidateAll(); SIGNING_INFO_CACHE.invalidateAll(); } }
CachingKeyConfImpl extends KeyConfImpl { protected static void invalidateCaches() { AUTH_KEY_CACHE.invalidateAll(); SIGNING_INFO_CACHE.invalidateAll(); } CachingKeyConfImpl(); }
CachingKeyConfImpl extends KeyConfImpl { protected static void invalidateCaches() { AUTH_KEY_CACHE.invalidateAll(); SIGNING_INFO_CACHE.invalidateAll(); } CachingKeyConfImpl(); @Override SigningCtx getSigningCtx(ClientId clientId); @Override AuthKey getAuthKey(); }
CachingKeyConfImpl extends KeyConfImpl { protected static void invalidateCaches() { AUTH_KEY_CACHE.invalidateAll(); SIGNING_INFO_CACHE.invalidateAll(); } CachingKeyConfImpl(); @Override SigningCtx getSigningCtx(ClientId clientId); @Override AuthKey getAuthKey();  }