@Test public void shouldAllowCacheablePutAndGet() { final Cache cache = newCache(); final CacheableObj cacheable = new CacheableObj(); cache.set(cacheable); MatcherAssert.assertThat(cache.get(cacheable.getKey()), Matchers.is(cacheable.getInstance())); }
@Test public void shouldAllowRawPutAndGet() { final Cache cache = newCache(); Object obj1 = new SerializableObj(); cache.set("Key", obj1); MatcherAssert.assertThat(cache.get("Key"), Matchers.is(obj1)); }
@Test public void shouldOverwriteValueOnRawPut() { final Cache cache = newCache(); Object obj1 = new SerializableObj(); Object obj2 = new SerializableObj(); cache.set("Key", obj1); cache.set("Key", obj2); MatcherAssert.assertThat(cache.get("Key"), Matchers.is(obj2)); }
@Test(expected = NullPointerException.class) public void shouldNotAllowCacheableGetWithNullCacheKey() { final Cache cache = newCache(); CacheKey key = null; cache.get(key); }
@Test(expected = NullPointerException.class) public void shouldNotAllowGetWithNullString() { final Cache cache = newCache(); final String s = null; cache.get(s); }