josh-mckenzie commented on a change in pull request #1205:
URL: https://github.com/apache/cassandra/pull/1205#discussion_r783422714
##########
File path: test/unit/org/apache/cassandra/auth/AuthCacheTest.java
##########
@@ -226,11 +213,80 @@ public void
testCassandraExceptionPassThroughWhenCacheRefreshed() throws Interru
}
}
+@Test
+ public void warmCacheUsingEntryProvider()
+ {
+ AtomicBoolean provided = new AtomicBoolean(false);
+ Supplier<Map<String, Integer>> bulkLoader = () -> {
+ provided.set(true);
+ return Collections.singletonMap("0", 0);
+ };
+ TestCache cache = newCache(bulkLoader);
+ cache.warm();
+ assertEquals(1, cache.getEstimatedSize());
+ assertEquals(0, (int)cache.get("0")); // warmed entry
+ assertEquals(0, loadCounter);
+ assertEquals(10, (int)cache.get("10")); // cold entry
+ assertEquals(1, loadCounter);
+ assertTrue(provided.get());
+ }
+
+ @Test
+ public void warmCacheIsSafeIfCachingIsDisabled()
+ {
+ isCacheEnabled = false;
+ TestCache cache = newCache(() -> Collections.singletonMap("0", 0));
+ cache.warm();
+ assertEquals(0, cache.getEstimatedSize());
+ }
+
+ @Test
+ public void providerSuppliesMoreEntriesThanCapacity()
+ {
+ final int maxEntries = 10;
Review comment:
Forklifted to a class level final int constant. :+1:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]