@Test public void removeAll() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); service.removeAll(); assertTrue(isEmpty(cache)); }
@Test public void remove() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); cache.put(key, value); service.remove(keyItem); assertNull(cache.get(key)); }
@Test public void earlyRemoveAll() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); service.earlyRemoveAll(); assertTrue(isEmpty(cache)); }
@Test public void earlyRemove() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); cache.put(key, value); service.earlyRemove(keyItem); assertNull(cache.get(key)); }
@Test public void cacheWithCustomKeyGenerator() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); service.cacheWithCustomKeyGenerator(keyItem, "ignored"); assertNull(cache.get(key)); }
@Test public void cacheWithCustomCacheResolver() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); service.cacheWithCustomCacheResolver(keyItem); assertNull(cache.get(key)); // Cache in mock cache }
@Test public void removeAllWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); try { service.removeAllWithException(true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } assertTrue(isEmpty(cache)); }
@Test public void removeAllWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); try { service.removeAllWithException(false); fail("Should have thrown an exception"); } catch (NullPointerException e) { // This is what we expect } assertNotNull(cache.get(key)); }
@Test public void earlyRemoveAllWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); try { service.earlyRemoveAllWithException(true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } assertTrue(isEmpty(cache)); }
@Test public void earlyRemoveAllWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); try { service.earlyRemoveAllWithException(false); fail("Should have thrown an exception"); } catch (NullPointerException e) { // This is what we expect } // This will be remove anyway as the earlyRemove has removed the cache before assertTrue(isEmpty(cache)); }
@Test public void removeWithException() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); cache.put(key, value); try { service.removeWithException(keyItem, true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } assertNull(cache.get(key)); }
@Test public void earlyRemoveWithException() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); cache.put(key, value); try { service.earlyRemoveWithException(keyItem, true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } assertNull(cache.get(key)); }
@Test public void earlyRemoveWithExceptionVetoRemove() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); cache.put(key, value); try { service.earlyRemoveWithException(keyItem, false); fail("Should have thrown an exception"); } catch (NullPointerException e) { // This is what we expect } // This will be remove anyway as the earlyRemove has removed the cache before assertNull(cache.get(key)); }
@Test public void earlyPut() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); assertNull(cache.get(key)); service.earlyPut(keyItem, value); Cache.ValueWrapper result = cache.get(key); assertNotNull(result); assertEquals(value, result.get()); }
@Test public void put() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); assertNull(cache.get(key)); service.put(keyItem, value); Cache.ValueWrapper result = cache.get(key); assertNotNull(result); assertEquals(value, result.get()); }
@Test public void putWithExceptionVetoPut() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); assertNull(cache.get(key)); try { service.putWithException(keyItem, value, false); fail("Should have thrown an exception"); } catch (NullPointerException e) { // This is what we expect } assertNull(cache.get(key)); }
@Test public void cacheException() { String keyItem = name.getMethodName(); Cache cache = getCache(EXCEPTION_CACHE); Object key = createKey(keyItem); assertNull(cache.get(key)); try { service.cacheWithException(keyItem, true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } Cache.ValueWrapper result = cache.get(key); assertNotNull(result); assertEquals(UnsupportedOperationException.class, result.get().getClass()); }
@Test public void putWithException() { String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(keyItem); Object value = new Object(); assertNull(cache.get(key)); try { service.putWithException(keyItem, value, true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } Cache.ValueWrapper result = cache.get(key); assertNotNull(result); assertEquals(value, result.get()); }
@Test public void cacheCheckedException() { String keyItem = name.getMethodName(); Cache cache = getCache(EXCEPTION_CACHE); Object key = createKey(keyItem); assertNull(cache.get(key)); try { service.cacheWithCheckedException(keyItem, true); fail("Should have thrown an exception"); } catch (IOException e) { // This is what we expect } Cache.ValueWrapper result = cache.get(key); assertNotNull(result); assertEquals(IOException.class, result.get().getClass()); }
@Test public void cacheExceptionVetoed() { String keyItem = name.getMethodName(); Cache cache = getCache(EXCEPTION_CACHE); Object key = createKey(keyItem); assertNull(cache.get(key)); try { service.cacheWithException(keyItem, false); fail("Should have thrown an exception"); } catch (NullPointerException e) { // This is what we expect } assertNull(cache.get(key)); }