Search in sources :

Example 1 with LineCountSplitter

use of com.adaptris.core.services.splitter.LineCountSplitter 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());
}
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) LineCountSplitter(com.adaptris.core.services.splitter.LineCountSplitter) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 2 with LineCountSplitter

use of com.adaptris.core.services.splitter.LineCountSplitter 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());
}
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) LineCountSplitter(com.adaptris.core.services.splitter.LineCountSplitter) Test(org.junit.Test)

Example 3 with LineCountSplitter

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

the class IgnoreOriginalMimeAggregatorTest method testService_ContentEncoding.

@Test
public void testService_ContentEncoding() throws Exception {
    // This is a 100 line message, so we expect to get 10 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();
    aggr.setEncoding("base64");
    service.setAggregator(aggr);
    execute(service, msg);
    BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
    assertEquals(10, 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) LineCountSplitter(com.adaptris.core.services.splitter.LineCountSplitter) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 4 with LineCountSplitter

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

the class IgnoreOriginalMimeAggregatorTest method testService_ContentIdProvided.

@Test
public void testService_ContentIdProvided() throws Exception {
    // This is a 100 line message, so we expect to get 10 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.setPartContentId("%message{" + getName() + "}");
    service.setAggregator(aggr);
    execute(service, msg);
    BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
    assertEquals(10, 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) LineCountSplitter(com.adaptris.core.services.splitter.LineCountSplitter) Test(org.junit.Test)

Example 5 with LineCountSplitter

use of com.adaptris.core.services.splitter.LineCountSplitter 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)5 LineCountSplitter (com.adaptris.core.services.splitter.LineCountSplitter)5 PooledSplitJoinService (com.adaptris.core.services.splitter.PooledSplitJoinService)5 TimeInterval (com.adaptris.util.TimeInterval)5 BodyPartIterator (com.adaptris.util.text.mime.BodyPartIterator)5 Test (org.junit.Test)5 NullService (com.adaptris.core.NullService)2 EvenOddCondition (com.adaptris.core.services.aggregator.MessageAggregatorTest.EvenOddCondition)1