use of com.adaptris.core.AdaptrisMessageFactory in project interlok by adaptris.
the class MimeAggregatorCase method testAggregate_WithFilter.
@Test
public void testAggregate_WithFilter() throws Exception {
MimeAggregator aggr = createAggregatorForTests();
aggr.setOverwriteMetadata(false);
aggr.setFilterCondition(new EvenOddCondition());
AdaptrisMessageFactory fac = AdaptrisMessageFactory.getDefaultInstance();
AdaptrisMessage original = fac.newMessage("<envelope/>");
AdaptrisMessage splitMsg1 = fac.newMessage("<document>hello</document>");
AdaptrisMessage splitMsg2 = fac.newMessage("<document>world</document>");
aggr.aggregate(original, Arrays.asList(new AdaptrisMessage[] { splitMsg1, splitMsg2 }));
String payload = original.getContent();
assertFalse(payload.contains("hello"));
assertTrue(payload.contains("world"));
}
use of com.adaptris.core.AdaptrisMessageFactory in project interlok by adaptris.
the class ZipAggregatorTest method testAggregate_BrokenOutput.
@Test(expected = CoreException.class)
public void testAggregate_BrokenOutput() throws Exception {
ZipAggregator aggr = new ZipAggregator();
AdaptrisMessage original = new DefectiveMessageFactory(WhenToBreak.OUTPUT).newMessage();
AdaptrisMessageFactory fac = AdaptrisMessageFactory.getDefaultInstance();
AdaptrisMessage splitMsg1 = fac.newMessage("<document>hello</document>");
splitMsg1.addMetadata(DEFAULT_FILENAME_METADATA, "xfile1.xml");
AdaptrisMessage splitMsg2 = fac.newMessage("<document>world2</document>");
splitMsg2.addMetadata(DEFAULT_FILENAME_METADATA, "file2.xml");
AdaptrisMessage splitMsg3 = fac.newMessage("<document>world3</document>");
splitMsg3.addMetadata(DEFAULT_FILENAME_METADATA, "xfile3.xml");
AdaptrisMessage splitMsg4 = fac.newMessage("<document>world4</document>");
splitMsg4.addMetadata(DEFAULT_FILENAME_METADATA, "file4.xml");
AdaptrisMessage willBeIgnoredMsg = fac.newMessage("<document>world4</document>");
aggr.joinMessage(original, Arrays.asList(splitMsg1, splitMsg2, splitMsg3, splitMsg4, willBeIgnoredMsg));
}
use of com.adaptris.core.AdaptrisMessageFactory in project interlok by adaptris.
the class ReplaceFirstAggregatorTest method testAggregate_BrokenOutput.
@Test(expected = CoreException.class)
public void testAggregate_BrokenOutput() throws Exception {
ReplaceWithFirstMessage aggr = createAggregatorForTests();
aggr.setOverwriteMetadata(true);
AdaptrisMessageFactory fac = AdaptrisMessageFactory.getDefaultInstance();
AdaptrisMessage original = new DefectiveMessageFactory(WhenToBreak.OUTPUT).newMessage("Goodbye");
AdaptrisMessage splitMsg1 = fac.newMessage("short");
AdaptrisMessage splitMsg2 = fac.newMessage("justShort");
AdaptrisMessage splitMsg3 = fac.newMessage("ofSufficientLength");
AdaptrisMessage splitMsg4 = fac.newMessage("tooSmall");
aggr.joinMessage(original, Arrays.asList(splitMsg1, splitMsg2, splitMsg3, splitMsg4));
}
use of com.adaptris.core.AdaptrisMessageFactory in project interlok by adaptris.
the class JmxNotificationConsumer method createMessage.
private AdaptrisMessage createMessage(Notification n) throws CoreException, IOException {
AdaptrisMessageFactory fac = AdaptrisMessageFactory.defaultIfNull(getMessageFactory());
AdaptrisMessage msg = getSerializer().serialize(n, fac.newMessage());
msg.addMessageHeader(JMX_NOTIF_SOURCE, n.getSource().toString());
return msg;
}
Aggregations