public void testContainsKey() { Cache<String, String> cache = initialize(); assertTrue(cache.containsKey("first key")); assertTrue(cache.containsKey("second key")); assertTrue(cache.containsKey("third key")); assertFalse(cache.containsKey("fourth key")); assertFalse(cache.containsKey("fifth key")); }
public void testRemove() { Cache<String, String> cache = initialize(); assertEquals("third value", cache.remove("third key")); assertTrue(cache.containsKey("first key")); assertTrue(cache.containsKey("second key")); assertFalse(cache.containsKey("third key")); assertFalse(cache.containsKey("fourth key")); assertFalse(cache.containsKey("fifth key")); }
public void testPut() { Cache<String, String> cache = initialize(); assertEquals("third value", cache.put("third key", "alternate third value")); assertNull(cache.put("fourth key", "forth value")); assertTrue(cache.containsKey("first key")); assertTrue(cache.containsKey("second key")); assertTrue(cache.containsKey("third key")); assertTrue(cache.containsKey("fourth key")); assertFalse(cache.containsKey("fifth key")); }
public void testPutAll() { Cache<String, String> cache = initialize(); HashMap<String, String> map = new HashMap<String, String>(); map.put("fourth key", "forth value"); map.put("fifth key", "fifth value"); cache.putAll(map); assertTrue(cache.containsKey("first key")); assertTrue(cache.containsKey("second key")); assertTrue(cache.containsKey("third key")); assertTrue(cache.containsKey("fourth key")); assertTrue(cache.containsKey("fifth key")); }
public void testBasics() { assertEquals("unlimited", Unlimited.TYPE); Cache<String, String> cache = new Unlimited<String, String>(); assertTrue(cache instanceof Unlimited); assertEquals("unlimited", cache.getType()); assertFalse(cache.containsKey("first key")); assertFalse(cache.containsKey("second key")); assertNull(cache.put("first key", "first value")); assertTrue(cache.containsKey("first key")); assertFalse(cache.containsKey("second key")); assertNull(cache.put("second key", "second value")); assertTrue(cache.containsKey("first key")); assertTrue(cache.containsKey("second key")); }