use of com.adaptris.core.services.cache.translators.StringPayloadCacheTranslator in project interlok by adaptris.
the class GetValueFromCacheTest method testDoService_NotFoundWithError.
@Test
public void testDoService_NotFoundWithError() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
Cache cache = createCacheInstanceForTests();
GetValueFromCache service = new GetValueFromCache().withExceptionIfNotFound(false).withValueTranslator(new StringPayloadCacheTranslator()).withKey("%message{%uniqueId}").withConnection(new CacheConnection().withCacheInstance(cache));
try {
start(service);
service.doService(msg);
assertNotEquals("Hello World", msg.getContent());
} catch (ServiceException expected) {
} finally {
stop(service);
}
}
use of com.adaptris.core.services.cache.translators.StringPayloadCacheTranslator in project interlok by adaptris.
the class BasicCacheExampleGenerator method createAddToCacheService.
public static AddToCacheService createAddToCacheService() {
AddToCacheService service = new AddToCacheService();
CacheEntryEvaluator eval1 = new CacheEntryEvaluator();
CacheEntryEvaluator eval2 = new CacheEntryEvaluator();
CacheEntryEvaluator eval3 = new CacheEntryEvaluator();
CacheEntryEvaluator eval4 = new CacheEntryEvaluator();
CacheEntryEvaluator eval5 = new CacheEntryEvaluator();
eval1.setKeyTranslator(new MetadataCacheValueTranslator("A_MetadataKey_Whose_Value_Makes_The_Cache_Key"));
eval1.setValueTranslator(new MetadataCacheValueTranslator("Another_MetadataKey_Whose_Value_Makes_The_Cache_CacheValue"));
eval2.setKeyTranslator(new MetadataCacheValueTranslator("A_MetadataKey_Whose_Value_Makes_The_Cache_Key"));
eval2.setValueTranslator(new StringPayloadCacheTranslator());
eval3.setKeyTranslator(new MetadataCacheValueTranslator("A_MetadataKey_Whose_Value_Makes_The_Cache_Key"));
eval3.setValueTranslator(new XpathCacheValueTranslator("/some/xpath/value"));
eval4.setKeyTranslator(new MetadataCacheValueTranslator("JMSCorrelationID"));
eval4.setValueTranslator(new JmsReplyToCacheValueTranslator());
eval5.setKeyTranslator(new MetadataCacheValueTranslator("A_MetadataKey_Whose_Value_Makes_The_Cache_Key"));
eval5.setValueTranslator(new ObjectMetadataCacheValueTranslator(JmsConstants.OBJ_JMS_REPLY_TO_KEY));
service.setCacheEntryEvaluators(new ArrayList(Arrays.asList(new CacheEntryEvaluator[] { eval1, eval2, eval3, eval4, eval5 })));
return service;
}
Aggregations