Search in sources :

Example 6 with BodyPartIterator

use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.

the class FlattenMimePartTest method testFlatten_NotNested.

@Test
public void testFlatten_NotNested() throws Exception {
    FlattenMimeParts service = new FlattenMimeParts();
    AdaptrisMessage msg = MimeJunitHelper.create();
    execute(service, msg);
    BodyPartIterator mime = MimeHelper.createBodyPartIterator(msg);
    assertEquals(3, mime.size());
}
Also used : BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 7 with BodyPartIterator

use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.

the class MimeHelperTest method testBodyPartIterator_CreateFromReal.

@Test
public void testBodyPartIterator_CreateFromReal() throws Exception {
    BodyPartIterator m = MimeHelper.createBodyPartIterator(AdaptrisMessageFactory.getDefaultInstance().newMessage(MIME_HEADER + "\r\n\r\n" + MIME_PAYLOAD));
    assertNotNull(m);
    assertEquals(2, m.size());
}
Also used : BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) Test(org.junit.Test)

Example 8 with BodyPartIterator

use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.

the class MultiPayloadMessageMimeEncoder method readMessage.

@Override
public AdaptrisMessage readMessage(InputStream source) throws CoreException {
    try {
        MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) currentMessageFactory().newMessage();
        BodyPartIterator input = new BodyPartIterator(source);
        boolean deleteDefault = addPartsToMessage(input, message);
        if (deleteDefault) {
            // delete the unused default
            message.deletePayload(MultiPayloadAdaptrisMessage.DEFAULT_PAYLOAD_ID);
        }
        return message;
    } catch (Exception e) {
        throw ExceptionHelper.wrapCoreException(e);
    }
}
Also used : BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) MessagingException(javax.mail.MessagingException) IOException(java.io.IOException)

Example 9 with BodyPartIterator

use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.

the class AggregatingFtpConsumeServiceTest method testService_MultipleFiles.

@Test
public void testService_MultipleFiles() throws Exception {
    int count = 5;
    EmbeddedFtpServer helper = new EmbeddedFtpServer();
    MockMessageListener listener = new MockMessageListener();
    FakeFtpServer server = helper.createAndStart(helper.createFilesystem(count));
    try {
        // should be ftp://localhost/home/user/work/ which is created when you
        // create the filesystem.
        String ftpConsumeUrl = "ftp://localhost" + DEFAULT_WORK_DIR_CANONICAL;
        FtpConnection conn = createConnection(server);
        AggregatingFtpConsumer consumer = createConsumer(ftpConsumeUrl, ".*", new IgnoreOriginalMimeAggregator());
        AggregatingFtpConsumeService service = new AggregatingFtpConsumeService(conn, consumer);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        execute(service, msg);
        BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
        assertEquals(count, input.size());
    } finally {
        server.stop();
    }
}
Also used : FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) IgnoreOriginalMimeAggregator(com.adaptris.core.services.aggregator.IgnoreOriginalMimeAggregator) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) Test(org.junit.Test)

Example 10 with BodyPartIterator

use of com.adaptris.util.text.mime.BodyPartIterator in project interlok by adaptris.

the class FlattenMimePartTest method testFlatten_Nested.

@Test
public void testFlatten_Nested() throws Exception {
    FlattenMimeParts service = new FlattenMimeParts();
    AdaptrisMessage msg = MimeJunitHelper.createNested();
    execute(service, msg);
    BodyPartIterator mime = MimeHelper.createBodyPartIterator(msg);
    assertEquals(6, mime.size());
}
Also used : BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

BodyPartIterator (com.adaptris.util.text.mime.BodyPartIterator)24 Test (org.junit.Test)20 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)18 PooledSplitJoinService (com.adaptris.core.services.splitter.PooledSplitJoinService)7 TimeInterval (com.adaptris.util.TimeInterval)7 MimeBodyPart (javax.mail.internet.MimeBodyPart)6 LineCountSplitter (com.adaptris.core.services.splitter.LineCountSplitter)5 MetadataElement (com.adaptris.core.MetadataElement)4 NullService (com.adaptris.core.NullService)4 IgnoreOriginalMimeAggregator (com.adaptris.core.services.aggregator.IgnoreOriginalMimeAggregator)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 CoreException (com.adaptris.core.CoreException)2 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 MimePartSplitter (com.adaptris.core.services.splitter.MimePartSplitter)2 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)2 HashSet (java.util.HashSet)2 MessagingException (javax.mail.MessagingException)2 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)2 AdaptrisMessageFactory (com.adaptris.core.AdaptrisMessageFactory)1