diff --git a/src/test/java/tools/jackson/databind/testutil/UnlimitedLookupCache.java b/src/test/java/tools/jackson/databind/testutil/UnlimitedLookupCache.java deleted file mode 100644 index c117a7f29c..0000000000 --- a/src/test/java/tools/jackson/databind/testutil/UnlimitedLookupCache.java +++ /dev/null @@ -1,66 +0,0 @@ -package tools.jackson.databind.testutil; - -import java.util.concurrent.ConcurrentHashMap; - -import tools.jackson.databind.util.LookupCache; - -/** - * A LookupCache implementation that has no synchronization (like SimpleLookupCache does) - * but that has the downside of not limiting the size of the cache. - */ -public class UnlimitedLookupCache implements LookupCache { - - private final int _initialEntries; - private final transient ConcurrentHashMap _map; - - public UnlimitedLookupCache(int initialEntries) - { - _initialEntries = initialEntries; - // We'll use concurrency level of 4, seems reasonable - _map = new ConcurrentHashMap(initialEntries, 0.8f, 4); - } - - @Override - public LookupCache snapshot() { - return new UnlimitedLookupCache(_initialEntries); - } - - @Override - public LookupCache emptyCopy() { - return snapshot(); - } - - /* - @Override - public void contents(BiConsumer consumer) { - for (Map.Entry entry : _map.entrySet()) { - consumer.accept(entry.getKey(), entry.getValue()); - } - } - */ - - @Override - public int size() { - return _map.size(); - } - - @Override - public V get(Object key) { - return _map.get(key); - } - - @Override - public V put(K key, V value) { - return _map.put(key, value); - } - - @Override - public V putIfAbsent(K key, V value) { - return _map.putIfAbsent(key, value); - } - - @Override - public void clear() { - _map.clear(); - } -} diff --git a/src/test/java/tools/jackson/databind/util/UnlimitedLookupCacheTest.java b/src/test/java/tools/jackson/databind/util/UnlimitedLookupCacheTest.java deleted file mode 100644 index 9b2f150e29..0000000000 --- a/src/test/java/tools/jackson/databind/util/UnlimitedLookupCacheTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package tools.jackson.databind.util; - -import org.junit.jupiter.api.Test; - -import tools.jackson.databind.JavaType; -import tools.jackson.databind.testutil.DatabindTestUtil; -import tools.jackson.databind.testutil.UnlimitedLookupCache; -import tools.jackson.databind.type.TypeFactory; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class UnlimitedLookupCacheTest - extends DatabindTestUtil -{ - @Test - public void testCache() { - UnlimitedLookupCache cache = new UnlimitedLookupCache<>(4); - assertNull(cache.get(1000L)); - assertNull(cache.put(1000L, "Thousand")); - assertEquals("Thousand", cache.get(1000L)); - assertEquals("Thousand", cache.putIfAbsent(1000L, "Míle")); - assertEquals("Thousand", cache.get(1000L)); - assertEquals("Thousand", cache.put(1000L, "Míle")); - assertEquals("Míle", cache.get(1000L)); - cache.clear(); - assertNull(cache.put(1000L, "Thousand")); - } - - @Test - public void testCompatibility() - { - UnlimitedLookupCache cache = new UnlimitedLookupCache<>(4); - TypeFactory tf = defaultTypeFactory().withCache(cache); - assertNotNull(tf); // just to get rid of warning - - //TODO find way to inject the `tf` instance into an ObjectMapper (via MapperBuilder?) - - //ObjectMapper mapper = new ObjectMapper(); - //mapper.setTypeFactory(tf); - //assertEquals("1000", mapper.writeValueAsString(1000)); - } -}