GetValueFromCache extends SingleKeyValueCacheImpl { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { Cache cache = retrieveCache(); String key = msg.resolve(getKey()); Object value = cache.get(key); if (value != null || !exceptionIfNotFound()) { getValueTranslator().addValueToMessage(msg, value); } else { throw new ServiceException(String.format("%s not found in cache", key)); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } }  @Override void doService(AdaptrisMessage msg); Boolean getExceptionIfNotFound(); void setExceptionIfNotFound(Boolean b); GetValueFromCache withExceptionIfNotFound(Boolean b);  }
@Test public void testDoService() throws Exception { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World"); Cache cache = createCacheInstanceForTests(); GetValueFromCache service = new GetValueFromCache().withValueTranslator(new StringPayloadCacheTranslator()) .withKey("%message{%uniqueId}").withConnection(new CacheConnection().withCacheInstance(cache)); try { start(service); cache.put(msg.getUniqueId(), "Goodbye Cruel World"); service.doService(msg); assertNotEquals("Hello World", msg.getContent()); assertEquals("Goodbye Cruel World", msg.getContent()); } finally { stop(service); } }