Search in sources :

Example 6 with MimeMultipart

use of javax.mail.internet.MimeMultipart in project rest.li by linkedin.

the class TestMIMEIntegrationReader method testMultipleAbnormalBodies.

@Test(dataProvider = "multipleAbnormalBodies")
public void testMultipleAbnormalBodies(final int chunkSize, final List<MimeBodyPart> bodyPartList) throws Exception {
    MimeMultipart multiPartMimeBody = new MimeMultipart();
    //Add your body parts
    for (final MimeBodyPart bodyPart : bodyPartList) {
        multiPartMimeBody.addBodyPart(bodyPart);
    }
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    multiPartMimeBody.writeTo(byteArrayOutputStream);
    final ByteString requestPayload = ByteString.copy(byteArrayOutputStream.toByteArray());
    executeRequestAndAssert(trimTrailingCRLF(requestPayload), chunkSize, multiPartMimeBody);
}
Also used : MimeMultipart(javax.mail.internet.MimeMultipart) ByteString(com.linkedin.data.ByteString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MimeBodyPart(javax.mail.internet.MimeBodyPart) Test(org.testng.annotations.Test)

Example 7 with MimeMultipart

use of javax.mail.internet.MimeMultipart in project rest.li by linkedin.

the class TestMIMEIntegrationReader method testAllTypesOfBodiesDataSource.

@Test(dataProvider = "allTypesOfBodiesDataSource")
public void testAllTypesOfBodiesDataSource(final int chunkSize, final List<MimeBodyPart> bodyPartList) throws Exception {
    MimeMultipart multiPartMimeBody = new MimeMultipart();
    //Add your body parts
    for (final MimeBodyPart bodyPart : bodyPartList) {
        multiPartMimeBody.addBodyPart(bodyPart);
    }
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    multiPartMimeBody.writeTo(byteArrayOutputStream);
    final ByteString requestPayload = ByteString.copy(byteArrayOutputStream.toByteArray());
    executeRequestAndAssert(trimTrailingCRLF(requestPayload), chunkSize, multiPartMimeBody);
}
Also used : MimeMultipart(javax.mail.internet.MimeMultipart) ByteString(com.linkedin.data.ByteString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MimeBodyPart(javax.mail.internet.MimeBodyPart) Test(org.testng.annotations.Test)

Example 8 with MimeMultipart

use of javax.mail.internet.MimeMultipart in project rest.li by linkedin.

the class TestMIMEIntegrationReader method testMultipleNormalBodiesDataSource.

@Test(dataProvider = "multipleNormalBodiesDataSource")
public void testMultipleNormalBodiesDataSource(final int chunkSize, final List<MimeBodyPart> bodyPartList) throws Exception {
    MimeMultipart multiPartMimeBody = new MimeMultipart();
    //Add your body parts
    for (final MimeBodyPart bodyPart : bodyPartList) {
        multiPartMimeBody.addBodyPart(bodyPart);
    }
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    multiPartMimeBody.writeTo(byteArrayOutputStream);
    final ByteString requestPayload = ByteString.copy(byteArrayOutputStream.toByteArray());
    executeRequestAndAssert(trimTrailingCRLF(requestPayload), chunkSize, multiPartMimeBody);
}
Also used : MimeMultipart(javax.mail.internet.MimeMultipart) ByteString(com.linkedin.data.ByteString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MimeBodyPart(javax.mail.internet.MimeBodyPart) Test(org.testng.annotations.Test)

Example 9 with MimeMultipart

use of javax.mail.internet.MimeMultipart in project rest.li by linkedin.

the class TestMIMEIntegrationReader method testEachSingleBodyDataSourceMultipleTimes.

@Test(dataProvider = "eachSingleBodyDataSource")
public void testEachSingleBodyDataSourceMultipleTimes(final int chunkSize, final MimeBodyPart bodyPart) throws Exception {
    MimeMultipart multiPartMimeBody = new MimeMultipart();
    //Add your body parts
    multiPartMimeBody.addBodyPart(bodyPart);
    multiPartMimeBody.addBodyPart(bodyPart);
    multiPartMimeBody.addBodyPart(bodyPart);
    multiPartMimeBody.addBodyPart(bodyPart);
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    multiPartMimeBody.writeTo(byteArrayOutputStream);
    final ByteString requestPayload = ByteString.copy(byteArrayOutputStream.toByteArray());
    executeRequestAndAssert(trimTrailingCRLF(requestPayload), chunkSize, multiPartMimeBody);
}
Also used : MimeMultipart(javax.mail.internet.MimeMultipart) ByteString(com.linkedin.data.ByteString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 10 with MimeMultipart

use of javax.mail.internet.MimeMultipart in project rest.li by linkedin.

the class TestMIMEReader method testStackOverflow.

///////////////////////////////////////////////////////////////////////////////////////
//Special test to make sure we don't stack overflow.
//Have tons of small parts that are all read in at once due to the huge chunk size.
@Test
public void testStackOverflow() throws Exception {
    MimeMultipart multiPartMimeBody = new MimeMultipart();
    _testTimeout = 600000;
    //does not lead to a stack overflow.
    for (int i = 0; i < 5000; i++) {
        multiPartMimeBody.addBodyPart(TINY_DATA_SOURCE);
    }
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    multiPartMimeBody.writeTo(byteArrayOutputStream);
    final ByteString requestPayload = ByteString.copy(byteArrayOutputStream.toByteArray());
    executeRequestAndAssert(trimTrailingCRLF(requestPayload), Integer.MAX_VALUE, multiPartMimeBody);
}
Also used : MimeMultipart(javax.mail.internet.MimeMultipart) ByteString(com.linkedin.data.ByteString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Aggregations

MimeMultipart (javax.mail.internet.MimeMultipart)188 MimeBodyPart (javax.mail.internet.MimeBodyPart)114 MimeMessage (javax.mail.internet.MimeMessage)71 MessagingException (javax.mail.MessagingException)65 BodyPart (javax.mail.BodyPart)51 ByteArrayOutputStream (java.io.ByteArrayOutputStream)49 IOException (java.io.IOException)45 ByteString (com.linkedin.data.ByteString)37 Test (org.testng.annotations.Test)31 ZMimeMultipart (com.zimbra.common.zmime.ZMimeMultipart)27 InternetAddress (javax.mail.internet.InternetAddress)27 ZMimeBodyPart (com.zimbra.common.zmime.ZMimeBodyPart)26 HashMap (java.util.HashMap)25 DataHandler (javax.activation.DataHandler)25 Multipart (javax.mail.Multipart)21 ByteArrayDataSource (javax.mail.util.ByteArrayDataSource)19 InputStream (java.io.InputStream)18 Date (java.util.Date)17 ByteArrayInputStream (java.io.ByteArrayInputStream)16 Properties (java.util.Properties)16