Search in sources :

Example 1 with ByteArrayIterator

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

the class TestMultipartOutput method testCreateMultiPartMimeOutput.

@Test
public void testCreateMultiPartMimeOutput() {
    try {
        MultiPartOutput output = new MultiPartOutput(guid.getUUID());
        output.addPart(PAYLOAD_1, guid.getUUID());
        output.addPart(PAYLOAD_2, guid.getUUID());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.getProperties().store(out, PROPERTY_FILE_HEADER);
        output.addPart(out.toByteArray(), guid.getUUID());
        ByteArrayIterator input = new ByteArrayIterator(output.getBytes());
        assertEquals(NUMBER_OF_PARTS, 3, input.size());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Example 2 with ByteArrayIterator

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

the class MimeHelperTest method testByteArrayIterator_CreateFromInvalid.

@Test
public void testByteArrayIterator_CreateFromInvalid() throws Exception {
    try {
        ByteArrayIterator m = MimeHelper.createByteArrayIterator(AdaptrisMessageFactory.getDefaultInstance().newMessage("AAAAAAAA"));
        fail("Failed");
    } catch (Exception expected) {
    }
}
Also used : ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Example 3 with ByteArrayIterator

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

the class MimeHelperTest method testByteArrayIterator_CreateFromFake.

@Test
public void testByteArrayIterator_CreateFromFake() throws Exception {
    ByteArrayIterator m = MimeHelper.createByteArrayIterator(AdaptrisMessageFactory.getDefaultInstance().newMessage(MIME_PAYLOAD));
    assertNotNull(m);
    assertEquals(2, m.size());
}
Also used : ByteArrayIterator(com.adaptris.util.text.mime.ByteArrayIterator) Test(org.junit.Test)

Example 4 with ByteArrayIterator

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

the class MimeHelperTest method testByteArrayIterator_CreateFromReal.

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

Example 5 with ByteArrayIterator

use of com.adaptris.util.text.mime.ByteArrayIterator 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)

Aggregations

ByteArrayIterator (com.adaptris.util.text.mime.ByteArrayIterator)11 Test (org.junit.Test)11 MultiPartOutput (com.adaptris.util.text.mime.MultiPartOutput)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1