Assert.assertEquals(to.getPersonal(), "Gavin King");
InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
Assert.assertEquals(from.getAddress(), "do-not-reply@jboss.com");
Assert.assertEquals(from.getPersonal(), "Seam");
Assert.assertEquals(renderedMessage.getSubject(), "Try out Seam!");
MimeMultipart body = (MimeMultipart) renderedMessage.getContent();
Assert.assertEquals(body.getCount(), 4); //3 Attachments and 1 MimeMultipart
// The root multipart/related
Assert.assertNotNull(body.getBodyPart(0));
Assert.assertTrue(body.getBodyPart(0) instanceof MimeBodyPart);
MimeBodyPart bodyPart = (MimeBodyPart) body.getBodyPart(0);
Assert.assertNotNull(bodyPart.getContent());
Assert.assertTrue(bodyPart.getContent() instanceof MimeMultipart);
Assert.assertTrue(bodyPart.isMimeType("multipart/related"));
MimeMultipart attachments = (MimeMultipart) bodyPart.getContent();
Assert.assertEquals(attachments.getCount(), 3); //2 Attachments and 1 MimeMultipart
// Attachment 0 (the actual message)
Assert.assertNotNull(attachments.getBodyPart(0));
Assert.assertTrue(attachments.getBodyPart(0) instanceof MimeBodyPart);
bodyPart = (MimeBodyPart) attachments.getBodyPart(0);
Assert.assertNotNull(bodyPart.getContent());
Assert.assertNotNull(bodyPart.getContent());
Assert.assertTrue(bodyPart.isMimeType("text/html"));
Assert.assertEquals(bodyPart.getDisposition(), "inline");
// Inline Attachment 1 // Attachment Jboss Logo
Assert.assertNotNull(attachments.getBodyPart(1));
Assert.assertTrue(attachments.getBodyPart(1) instanceof MimeBodyPart);
bodyPart = (MimeBodyPart) attachments.getBodyPart(1);
Assert.assertNotNull(bodyPart.getContent());
Assert.assertTrue(bodyPart.getContent() instanceof InputStream);
Assert.assertEquals(bodyPart.getFileName(), "jboss.jpg");
Assert.assertTrue(bodyPart.isMimeType("image/jpeg"));
Assert.assertEquals(bodyPart.getDisposition(), "inline");
Assert.assertNotNull(bodyPart.getContentID());
// Inline Attachment 1 // Attachment Gavin Pic
Assert.assertNotNull(attachments.getBodyPart(2));
Assert.assertTrue(attachments.getBodyPart(2) instanceof MimeBodyPart);
bodyPart = (MimeBodyPart) attachments.getBodyPart(2);
Assert.assertNotNull(bodyPart.getContent());
Assert.assertTrue(bodyPart.getContent() instanceof InputStream);
Assert.assertEquals(bodyPart.getFileName(), "Gavin_King.jpg");
Assert.assertTrue(bodyPart.isMimeType("image/png"));
Assert.assertEquals(bodyPart.getDisposition(), "inline");