use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService_NoErrorOnEmpty_NoKeyValue.
@Test
public void testDoService_NoErrorOnEmpty_NoKeyValue() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
CacheEntryEvaluator eval = service.getCacheEntryEvaluators().get(0);
eval.setErrorOnEmptyKey(false);
eval.setKeyTranslator(new MetadataCacheValueTranslator(SRC_KEY));
try {
service.setConnection(new CacheConnection(cache));
start(service);
service.doService(msg);
assertNull(cache.get(SRC_VALUE));
} finally {
stop(service);
}
}
use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService_ErrorOnEmpty.
@Test
public void testDoService_ErrorOnEmpty() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
CacheEntryEvaluator eval = service.getCacheEntryEvaluators().get(0);
eval.setValueTranslator(new MetadataCacheValueTranslator(SRC_KEY));
eval.setKeyTranslator(new MetadataCacheValueTranslator(SRC_KEY));
try {
service.setConnection(new CacheConnection(cache));
start(service);
service.doService(msg);
fail();
} catch (ServiceException expected) {
} finally {
stop(service);
}
}
use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService_NoErrorOnEmpty_NoValue.
@Test
public void testDoService_NoErrorOnEmpty_NoValue() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
CacheEntryEvaluator eval = service.getCacheEntryEvaluators().get(0);
eval.setErrorOnEmptyValue(false);
eval.setValueTranslator(new MetadataCacheValueTranslator(SRC_KEY));
try {
service.setConnection(new CacheConnection(cache));
start(service);
service.doService(msg);
assertNull(cache.get(SRC_VALUE));
} finally {
stop(service);
}
}
use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.
the class AddToCacheServiceTest method createServiceForTests.
private AddToCacheService createServiceForTests() {
AddToCacheService service = createService();
CacheEntryEvaluator eval = new CacheEntryEvaluator();
eval.setKeyTranslator(new MetadataCacheValueTranslator("JMSCorrelationID"));
eval.setValueTranslator(new JmsReplyToCacheValueTranslator());
service.addCacheEntryEvaluator(eval);
return service;
}
use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.
the class RetrieveFromCacheServiceTest method createServiceForTests.
protected RetrieveFromCacheService createServiceForTests() {
RetrieveFromCacheService service = createService();
CacheEntryEvaluator eval = new CacheEntryEvaluator();
eval.setKeyTranslator(new MetadataCacheValueTranslator(SRC_METADATA_KEY));
eval.setValueTranslator(new MetadataCacheValueTranslator(TARGET_METADATA_KEY));
service.addCacheEntryEvaluator(eval);
return service;
}
Aggregations