diff options
author | jonmv <venstad@gmail.com> | 2022-10-26 11:31:42 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-10-26 11:31:42 +0200 |
commit | 5246967ce8b8ac4a95c944be21a0f473175c4b2a (patch) | |
tree | 50ad2cbec35ab32d725f94473020d2a578ab5f0f /vespajlib/src/test | |
parent | 73ca78767d08828859f112bc6f23997c113617cf (diff) |
Test caching negative results, and invoke callback for those too
Diffstat (limited to 'vespajlib/src/test')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/collections/MethodCacheTest.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/collections/MethodCacheTest.java b/vespajlib/src/test/java/com/yahoo/collections/MethodCacheTest.java index 7b3d3e98cec..02efd10e91d 100644 --- a/vespajlib/src/test/java/com/yahoo/collections/MethodCacheTest.java +++ b/vespajlib/src/test/java/com/yahoo/collections/MethodCacheTest.java @@ -9,6 +9,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -60,11 +61,21 @@ class MethodCacheTest { cachedCustomMethod.invoke(customDummy); assertThrows(IllegalArgumentException.class, () -> applicationMethod.invoke(customDummy)); assertThrows(IllegalArgumentException.class, () -> customMethod.invoke(applicationDummy)); + + Object noDummy = new NoDummy(); + Method noMethod = methods.get(noDummy, __ -> updatedCache.set(true)); + assertTrue(updatedCache.getAndSet(false), "cache was updated"); + assertNull(noMethod); + + Method cachedNoMethod = methods.get(noDummy, __ -> updatedCache.set(true)); + assertFalse(updatedCache.getAndSet(false), "cache was updated"); + assertNull(cachedNoMethod); } } + public static class NoDummy implements Cloneable { } + public static class Dummy implements Cloneable { - public Dummy() { } public Object clone() throws CloneNotSupportedException { return super.clone(); } } |