use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.
the class AggregatingJmsConsumeServiceTest method testService_MultipleMessages.
@Test
public void testService_MultipleMessages() throws Exception {
AggregatingQueueConsumer consumer = new AggregatingQueueConsumer();
consumer.setMessageAggregator(new IgnoreOriginalMimeAggregator());
AggregatingJmsConsumeService service = createService(activeMqBroker, consumer, getName());
try {
sendDataMessage(activeMqBroker, getName());
sendDataMessage(activeMqBroker, getName());
start(service);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(PAYLOAD);
msg.addMetadata(DEFAULT_FILTER_KEY, "JMSCorrelationID = '0001'");
service.doService(msg);
BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
assertEquals(2, input.size());
} finally {
stop(service);
}
}
use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.
the class MimeAggregatorTest method testService_ContentEncoding.
@Test
public void testService_ContentEncoding() throws Exception {
// This is a 100 line message, so we expect to get 11 parts.
AdaptrisMessage msg = SplitterCase.createLineCountMessageInput();
PooledSplitJoinService service = new PooledSplitJoinService();
// The service doesn't actually matter right now.
service.setService(new NullService());
service.setTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
service.setSplitter(new LineCountSplitter());
MimeAggregator aggr = createAggregatorForTests().withEncoding("base64");
service.setAggregator(aggr);
execute(service, msg);
BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
assertEquals(11, input.size());
}
use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.
the class MimeAggregatorTest method testService_ContentIdProvided.
@Test
public void testService_ContentIdProvided() throws Exception {
// This is a 100 line message, so we expect to get 11 parts.
AdaptrisMessage msg = SplitterCase.createLineCountMessageInput();
msg.addMetadata(getName(), msg.getUniqueId());
PooledSplitJoinService service = new PooledSplitJoinService();
// The service doesn't actually matter right now.
service.setService(createAddMetadataService(getName()));
service.setTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
service.setSplitter(new LineCountSplitter());
MimeAggregator aggr = createAggregatorForTests();
aggr.setPartContentId("%message{" + getName() + "}");
service.setAggregator(aggr);
execute(service, msg);
BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
assertEquals(11, input.size());
}
use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.
the class IgnoreOriginalMimeAggregatorTest method testService_MimeSplitter.
@Test
public void testService_MimeSplitter() throws Exception {
// This is a 3 part message, so that should generate 3 split messages; which should generate 3 parts at the end.
AdaptrisMessage msg = MimeJunitHelper.create();
PooledSplitJoinService service = new PooledSplitJoinService();
// The service doesn't actually matter right now.
service.setService(new NullService());
service.setTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
service.setSplitter(new MimePartSplitter());
MimeAggregator aggr = createAggregatorForTests();
aggr.setEncoding("base64");
service.setAggregator(aggr);
execute(service, msg);
BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
assertEquals(3, input.size());
}
use of com.adaptris.util.text.mime.BodyPartIterator 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());
}
}
Aggregations