Search in sources :

Example 61 with TimeInterval

use of com.adaptris.util.TimeInterval 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 62 with TimeInterval

use of com.adaptris.util.TimeInterval 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 63 with TimeInterval

use of com.adaptris.util.TimeInterval in project interlok by adaptris.

the class XmlAggregatorTest method testSplitJoinService_WithExplicitDocumentEnoding.

@Test
public void testSplitJoinService_WithExplicitDocumentEnoding() throws Exception {
    // This is a XML doc with 3 iterable elements...
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(SplitterCase.XML_MESSAGE);
    PooledSplitJoinService service = new PooledSplitJoinService();
    // The service doesn't actually matter right now.
    service.setService(asCollection(new NullService()));
    service.setTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
    service.setSplitter(new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8));
    XmlDocumentAggregator aggr = new XmlDocumentAggregator(new InsertNode(XPATH_ENVELOPE));
    aggr.setDocumentEncoding("UTF-8");
    service.setAggregator(aggr);
    execute(service, msg);
    // Should now be 6 document nodes
    XPath xpath = new XPath();
    assertEquals(6, xpath.selectNodeList(XmlHelper.createDocument(msg, true), ENVELOPE_DOCUMENT).getLength());
    assertEquals("UTF-8", msg.getContentEncoding());
}
Also used : PooledSplitJoinService(com.adaptris.core.services.splitter.PooledSplitJoinService) XPath(com.adaptris.util.text.xml.XPath) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NullService(com.adaptris.core.NullService) XpathMessageSplitter(com.adaptris.core.services.splitter.XpathMessageSplitter) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Example 64 with TimeInterval

use of com.adaptris.util.TimeInterval 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());
}
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 65 with TimeInterval

use of com.adaptris.util.TimeInterval in project interlok by adaptris.

the class IgnoreOriginalXmlAggregatorTest method testSplitJoinService_WithExplicitDocumentEnoding.

@Test
public void testSplitJoinService_WithExplicitDocumentEnoding() throws Exception {
    // This is a XML doc with 3 iterable elements...
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(SplitterCase.XML_MESSAGE);
    PooledSplitJoinService service = new PooledSplitJoinService();
    // The service doesn't actually matter right now.
    service.setService(asCollection(new NullService()));
    service.setTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
    service.setSplitter(new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8));
    IgnoreOriginalXmlDocumentAggregator aggr = new IgnoreOriginalXmlDocumentAggregator("<new/>", new InsertNode("/new"));
    aggr.setDocumentEncoding("UTF-8");
    service.setAggregator(aggr);
    execute(service, msg);
    // Should now be 3 document nodes
    // because we ignore the original
    XPath xpath = new XPath();
    assertEquals(3, xpath.selectNodeList(XmlHelper.createDocument(msg, true), "/new/document").getLength());
    assertEquals("UTF-8", msg.getContentEncoding());
}
Also used : PooledSplitJoinService(com.adaptris.core.services.splitter.PooledSplitJoinService) XPath(com.adaptris.util.text.xml.XPath) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NullService(com.adaptris.core.NullService) XpathMessageSplitter(com.adaptris.core.services.splitter.XpathMessageSplitter) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Aggregations

TimeInterval (com.adaptris.util.TimeInterval)310 Test (org.junit.Test)249 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)86 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)49 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)42 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)40 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)38 Channel (com.adaptris.core.Channel)36 MockChannel (com.adaptris.core.stubs.MockChannel)32 File (java.io.File)28 StandardWorkflow (com.adaptris.core.StandardWorkflow)27 Adapter (com.adaptris.core.Adapter)26 GuidGenerator (com.adaptris.util.GuidGenerator)25 FilenameFilter (java.io.FilenameFilter)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 StandaloneProducer (com.adaptris.core.StandaloneProducer)23 CoreException (com.adaptris.core.CoreException)22 WaitService (com.adaptris.core.services.WaitService)22 RandomAccessFile (java.io.RandomAccessFile)21 ObjectName (javax.management.ObjectName)21