Search in sources :

Example 11 with PooledSplitJoinService

use of com.adaptris.core.services.splitter.PooledSplitJoinService in project interlok by adaptris.

the class MimeAggregatorTest 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 4 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(4, input.size());
}
Also used : PooledSplitJoinService(com.adaptris.core.services.splitter.PooledSplitJoinService) TimeInterval(com.adaptris.util.TimeInterval) BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NullService(com.adaptris.core.NullService) MimePartSplitter(com.adaptris.core.services.splitter.MimePartSplitter) Test(org.junit.Test)

Example 12 with PooledSplitJoinService

use of com.adaptris.core.services.splitter.PooledSplitJoinService in project interlok by adaptris.

the class MimeAggregatorTest method testService_withFilter.

@Test
public void testService_withFilter() 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(createAddMetadataService(getName()));
    service.setTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
    service.setSplitter(new LineCountSplitter());
    MimeAggregator aggr = createAggregatorForTests();
    aggr.setFilterCondition(new EvenOddCondition());
    service.setAggregator(aggr);
    execute(service, msg);
    BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
    assertEquals(6, input.size());
}
Also used : PooledSplitJoinService(com.adaptris.core.services.splitter.PooledSplitJoinService) EvenOddCondition(com.adaptris.core.services.aggregator.MessageAggregatorTest.EvenOddCondition) TimeInterval(com.adaptris.util.TimeInterval) BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) LineCountSplitter(com.adaptris.core.services.splitter.LineCountSplitter) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)12 PooledSplitJoinService (com.adaptris.core.services.splitter.PooledSplitJoinService)12 TimeInterval (com.adaptris.util.TimeInterval)12 Test (org.junit.Test)12 NullService (com.adaptris.core.NullService)9 BodyPartIterator (com.adaptris.util.text.mime.BodyPartIterator)7 LineCountSplitter (com.adaptris.core.services.splitter.LineCountSplitter)5 XpathMessageSplitter (com.adaptris.core.services.splitter.XpathMessageSplitter)5 InsertNode (com.adaptris.util.text.xml.InsertNode)5 XPath (com.adaptris.util.text.xml.XPath)5 EvenOddCondition (com.adaptris.core.services.aggregator.MessageAggregatorTest.EvenOddCondition)2 MimePartSplitter (com.adaptris.core.services.splitter.MimePartSplitter)2