Java Code Examples for org.springframework.cache.interceptor.SimpleKeyGenerator#generateKey()
The following examples show how to use
org.springframework.cache.interceptor.SimpleKeyGenerator#generateKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JCacheErrorHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void getFailPutExceptionFail() { UnsupportedOperationException exceptionOnPut = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); given(this.cache.get(key)).willReturn(null); willThrow(exceptionOnPut).given(this.errorCache).put(key, SimpleService.TEST_EXCEPTION); try { this.simpleService.getFail(0L); } catch (IllegalStateException ex) { assertEquals("Test exception", ex.getMessage()); } verify(this.errorHandler).handleCachePutError( exceptionOnPut, this.errorCache, key, SimpleService.TEST_EXCEPTION); }
Example 2
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @CachePut(afterInvocation = false) public void earlyPut(String id, @CacheValue Object value) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper == null) { throw new AssertionError("Excepted value to be put in cache with key " + key); } Object actual = valueWrapper.get(); if (value != actual) { // instance check on purpose throw new AssertionError("Wrong value set in cache with key " + key + ". " + "Expected=" + value + ", but got=" + actual); } }
Example 3
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @CachePut(afterInvocation = false) public void earlyPut(String id, @CacheValue Object value) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper == null) { throw new AssertionError("Excepted value to be put in cache with key " + key); } Object actual = valueWrapper.get(); if (value != actual) { // instance check on purpose throw new AssertionError("Wrong value set in cache with key " + key + ". " + "Expected=" + value + ", but got=" + actual); } }
Example 4
Source File: JCacheErrorHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void evictFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict"); Object key = SimpleKeyGenerator.generateKey(0L); willThrow(exception).given(cache).evict(key); this.simpleService.evict(0L); verify(errorHandler).handleCacheEvictError(exception, cache, key); }
Example 5
Source File: AnnotatedJCacheableService.java From java-technology-stack with MIT License | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example 6
Source File: AnnotatedJCacheableService.java From java-technology-stack with MIT License | 5 votes |
@Override @CachePut(afterInvocation = false) public void earlyPut(String id, @CacheValue Object value) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper == null) { throw new AssertionError("Excepted value to be put in cache with key " + key); } Object actual = valueWrapper.get(); if (value != actual) { // instance check on purpose throw new AssertionError("Wrong value set in cache with key " + key + ". " + "Expected=" + value + ", but got=" + actual); } }
Example 7
Source File: JCacheErrorHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void evictFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict"); Object key = SimpleKeyGenerator.generateKey(0L); willThrow(exception).given(this.cache).evict(key); this.simpleService.evict(0L); verify(this.errorHandler).handleCacheEvictError(exception, this.cache, key); }
Example 8
Source File: JCacheErrorHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void putFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); willThrow(exception).given(this.cache).put(key, 234L); this.simpleService.put(0L, 234L); verify(this.errorHandler).handleCachePutError(exception, this.cache, key, 234L); }
Example 9
Source File: JCacheErrorHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void getPutNewElementFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); given(this.cache.get(key)).willReturn(null); willThrow(exception).given(this.cache).put(key, 0L); this.simpleService.get(0L); verify(this.errorHandler).handleCachePutError(exception, this.cache, key, 0L); }
Example 10
Source File: CachingConfig.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public Object generate(Object target, Method method, Object... params) { if (params.length == 1) { if (params[0] == null) { return SimpleKey.EMPTY; } CacheDefinition cacheDefinition = classCacheDefinitionMap.get(params[0].getClass()); if (cacheDefinition != null) { return cacheDefinition.generateKey(target, method, params); } } return SimpleKeyGenerator.generateKey(params); }
Example 11
Source File: AnnotatedJCacheableService.java From spring-analysis-note with MIT License | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example 12
Source File: AnnotatedJCacheableService.java From spring-analysis-note with MIT License | 5 votes |
@Override @CachePut(afterInvocation = false) public void earlyPut(String id, @CacheValue Object value) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper == null) { throw new AssertionError("Excepted value to be put in cache with key " + key); } Object actual = valueWrapper.get(); if (value != actual) { // instance check on purpose throw new AssertionError("Wrong value set in cache with key " + key + ". " + "Expected=" + value + ", but got=" + actual); } }
Example 13
Source File: AnnotatedJCacheableService.java From spring-analysis-note with MIT License | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example 14
Source File: AnnotatedJCacheableService.java From spring-analysis-note with MIT License | 5 votes |
@Override @CachePut(afterInvocation = false) public void earlyPut(String id, @CacheValue Object value) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper == null) { throw new AssertionError("Excepted value to be put in cache with key " + key); } Object actual = valueWrapper.get(); if (value != actual) { // instance check on purpose throw new AssertionError("Wrong value set in cache with key " + key + ". " + "Expected=" + value + ", but got=" + actual); } }
Example 15
Source File: CachingConfig.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public Object generate(Object target, Method method, Object... params) { if (params.length == 1) { if (params[0] == null) { return SimpleKey.EMPTY; } CacheDefinition cacheDefinition = classCacheDefinitionMap.get(params[0].getClass()); if (cacheDefinition != null) { return cacheDefinition.generateKey(target, method, params); } } return SimpleKeyGenerator.generateKey(params); }
Example 16
Source File: JCacheErrorHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void putFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); willThrow(exception).given(this.cache).put(key, 234L); this.simpleService.put(0L, 234L); verify(this.errorHandler).handleCachePutError(exception, this.cache, key, 234L); }
Example 17
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example 18
Source File: JCacheErrorHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void getPutNewElementFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); given(this.cache.get(key)).willReturn(null); willThrow(exception).given(this.cache).put(key, 0L); this.simpleService.get(0L); verify(this.errorHandler).handleCachePutError(exception, this.cache, key, 0L); }
Example 19
Source File: AbstractJCacheAnnotationTests.java From spring-analysis-note with MIT License | 4 votes |
private Object createKey(Object... params) { return SimpleKeyGenerator.generateKey(params); }
Example 20
Source File: AbstractJCacheAnnotationTests.java From java-technology-stack with MIT License | 4 votes |
private Object createKey(Object... params) { return SimpleKeyGenerator.generateKey(params); }