Search in sources :

Example 11 with MultiPartOutput

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

the class TestMultipartOutput method testCreate7bitMimeOutput.

@Test
public void testCreate7bitMimeOutput() {
    try {
        MultiPartOutput output = new MultiPartOutput(guid.getUUID());
        output.addPart(PAYLOAD_1, ENCODING_7BIT, guid.getUUID());
        ByteArrayIterator input = new ByteArrayIterator(output.getBytes());
        assertEquals(NUMBER_OF_PARTS, 1, input.size());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Example 12 with MultiPartOutput

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

the class TestMultipartOutput method testCreateMultiPartWithNullPayload.

@Test
public void testCreateMultiPartWithNullPayload() {
    try {
        MultiPartOutput output = new MultiPartOutput(guid.getUUID());
        byte[] nullOutput = null;
        output.addPart(nullOutput, guid.getUUID());
        byte[] mimePayload = output.getBytes();
        ByteArrayIterator input = new ByteArrayIterator(output.getBytes());
        assertEquals(NUMBER_OF_PARTS, 1, input.size());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Example 13 with MultiPartOutput

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

the class TestMultipartOutput method testCreateQuotedPrintableMimeOutput.

@Test
public void testCreateQuotedPrintableMimeOutput() {
    try {
        MultiPartOutput output = new MultiPartOutput(guid.getUUID());
        output.addPart(PAYLOAD_1, ENCODING_QUOTED, guid.getUUID());
        ByteArrayIterator input = new ByteArrayIterator(output.getBytes());
        assertEquals(NUMBER_OF_PARTS, 1, input.size());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Example 14 with MultiPartOutput

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

the class TestMultipartOutput method testCreateMultiPartWithRemovedParts.

@Test
public void testCreateMultiPartWithRemovedParts() {
    try {
        MultiPartOutput output = new MultiPartOutput(guid.getUUID());
        String matchingContentId = guid.getUUID();
        output.addPart(PAYLOAD_1, guid.getUUID());
        output.addPart(PAYLOAD_1, matchingContentId);
        output.addPart(PAYLOAD_1, guid.getUUID());
        output.addPart(PAYLOAD_1, matchingContentId);
        output.removePart(matchingContentId);
        byte[] mimePayload = output.getBytes();
        ByteArrayIterator input = new ByteArrayIterator(output.getBytes());
        assertEquals(NUMBER_OF_PARTS, 2, input.size());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Example 15 with MultiPartOutput

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

the class TestMultipartOutput method testCreatePlainMimeOutput.

@Test
public void testCreatePlainMimeOutput() {
    try {
        MultiPartOutput output = new MultiPartOutput(guid.getUUID());
        output.addPart(PAYLOAD_1, guid.getUUID());
        ByteArrayIterator input = new ByteArrayIterator(output.getBytes());
        assertEquals(NUMBER_OF_PARTS, 1, input.size());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Aggregations

MultiPartOutput (com.adaptris.util.text.mime.MultiPartOutput)23 ByteArrayIterator (com.adaptris.util.text.mime.ByteArrayIterator)8 Test (org.junit.Test)8 OutputStream (java.io.OutputStream)5 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 CoreException (com.adaptris.core.CoreException)3 MetadataCollection (com.adaptris.core.MetadataCollection)3 GuidGenerator (com.adaptris.util.GuidGenerator)3 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 MimeBodyPart (javax.mail.internet.MimeBodyPart)3 ServiceException (com.adaptris.core.ServiceException)2 Properties (java.util.Properties)2 MessagingException (javax.mail.MessagingException)2 MimeMultipart (javax.mail.internet.MimeMultipart)2 InputStreamDataSource (com.adaptris.util.text.mime.InputStreamDataSource)1 File (java.io.File)1 InputStream (java.io.InputStream)1 BodyPart (javax.mail.BodyPart)1