@Override @Test public void testDoService() throws Exception { AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(SRC_METADATA_KEY, LOOKUP_VALUE) })); Cache cache = createCacheInstanceForTests(); CacheServiceBase service = createServiceForTests(); try { service.setConnection(new CacheConnection(cache)); start(service); cache.put(LOOKUP_VALUE, LOOKED_UP_VALUE); service.doService(msg); assertTrue(msg.headersContainsKey(TARGET_METADATA_KEY)); assertEquals(LOOKED_UP_VALUE, msg.getMetadataValue(TARGET_METADATA_KEY)); assertFalse(cache.getKeys().contains(LOOKUP_VALUE)); } finally { stop(service); } }
@Override public void doService(AdaptrisMessage msg) throws ServiceException { try { Cache cache = retrieveCache(); for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null values for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); cache.remove(key); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } }
RemoveFromCacheService extends RetrieveFromCacheService { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { Cache cache = retrieveCache(); for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null values for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); cache.remove(key); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } }
RemoveFromCacheService extends RetrieveFromCacheService { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { Cache cache = retrieveCache(); for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null values for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); cache.remove(key); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } }  }
RemoveFromCacheService extends RetrieveFromCacheService { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { Cache cache = retrieveCache(); for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null values for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); cache.remove(key); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } }  @Override void doService(AdaptrisMessage msg); }
RemoveFromCacheService extends RetrieveFromCacheService { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { Cache cache = retrieveCache(); for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null values for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); cache.remove(key); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } }  @Override void doService(AdaptrisMessage msg);  }