use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class RetrieveFromCacheServiceTest method testDoService_NoExceptionIfNotFound_NotFound.
@Test
public void testDoService_NoExceptionIfNotFound_NotFound() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(SRC_METADATA_KEY, LOOKUP_VALUE) }));
Cache cache = createCacheInstanceForTests();
RetrieveFromCacheService service = createServiceForTests();
service.setExceptionIfNotFound(false);
try {
service.setConnection(new CacheConnection(cache));
start(service);
service.doService(msg);
assertFalse(msg.headersContainsKey(TARGET_METADATA_KEY));
} finally {
stop(service);
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class RetrieveFromCacheServiceTest method testDoService.
@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();
RetrieveFromCacheService service = createServiceForTests();
try {
service.setConnection(new CacheConnection(cache));
start(service);
// Now add the TARGET DATA to the cache.
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));
} finally {
stop(service);
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MimeAggregatorCase method testJoinMessage_WithSubType.
@Test
public void testJoinMessage_WithSubType() throws Exception {
MimeAggregator aggr = createAggregatorForTests().withMimeContentSubType("form-data");
AdaptrisMessage original = AdaptrisMessageFactory.getDefaultInstance().newMessage("<envelope/>", null, new HashSet<>(Arrays.asList(new MetadataElement("X-Interlok-Test", "ZZLC-original"))));
AdaptrisMessage s1 = AdaptrisMessageFactory.getDefaultInstance().newMessage("<document>hello</document>", null, new HashSet<>(Arrays.asList(new MetadataElement("X-Interlok-Test", "ZZLC-split1"))));
AdaptrisMessage s2 = AdaptrisMessageFactory.getDefaultInstance().newMessage("<document>world</document>", null, new HashSet<>(Arrays.asList(new MetadataElement("X-Interlok-Test", "ZZLC-split2"))));
aggr.joinMessage(original, Arrays.asList(s1, s2));
String payload = original.getContent();
System.err.println(payload);
assertTrue(payload.contains("multipart/form-data"));
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MimeAggregatorCase method testJoinMessage_ContentType.
@Test
public void testJoinMessage_ContentType() throws Exception {
MimeAggregator aggr = createAggregatorForTests();
aggr.setPartContentType("%message{MyContentType}");
Set<MetadataElement> metadata = new HashSet<>();
metadata.add(new MetadataElement("MyContentType", "application/xml"));
AdaptrisMessage original = AdaptrisMessageFactory.getDefaultInstance().newMessage("<envelope/>", null, new HashSet<>(metadata));
AdaptrisMessage s1 = AdaptrisMessageFactory.getDefaultInstance().newMessage("<document>hello</document>", null, new HashSet<>(metadata));
AdaptrisMessage s2 = AdaptrisMessageFactory.getDefaultInstance().newMessage("<document>world</document>", null, new HashSet<>(metadata));
aggr.joinMessage(original, Arrays.asList(new AdaptrisMessage[] { s1, s2 }));
BodyPartIterator m = new BodyPartIterator(original.getInputStream());
for (int i = 0; i < m.size(); i++) {
MimeBodyPart part = m.getBodyPart(i);
assertEquals("application/xml", part.getContentType());
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class CacheEntryEvaluatorTest method testEvaluateValue_NoErrorOnEmpty_EmptyValue.
@Test
public void testEvaluateValue_NoErrorOnEmpty_EmptyValue() throws Exception {
CacheEntryEvaluator eval = new CacheEntryEvaluator();
CacheValueTranslator translator = new MetadataCacheValueTranslator(DEFAULT_METADATA_KEY);
eval.setValueTranslator(translator);
eval.setErrorOnEmptyValue(false);
AdaptrisMessage msg = createMessage(new ArrayList<MetadataElement>());
assertEquals(null, eval.getValue(msg));
}
Aggregations