}
@Override
protected void invokeApplication() throws Exception
{
MimeMessage renderedMessage = getRenderedMailMessage("/plain.xhtml");
// Test the standard headers
InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
Assert.assertEquals(to.getAddress(), "test@example.com");
Assert.assertEquals(to.getPersonal(), "Pete Muir");
InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
Assert.assertEquals(from.getAddress(), "do-not-reply@jboss.com");
Assert.assertEquals(from.getPersonal(), "Seam");
Assert.assertEquals(renderedMessage.getReplyTo().length, 1);
Assert.assertTrue(renderedMessage.getReplyTo()[0] instanceof InternetAddress);
InternetAddress replyTo = (InternetAddress) renderedMessage.getReplyTo()[0];
Assert.assertEquals(replyTo.getAddress(), "another.address@jboss.org");
Assert.assertEquals(replyTo.getPersonal(), "JBoss");
Assert.assertEquals(renderedMessage.getRecipients(CC).length, 1);
Assert.assertTrue(renderedMessage.getRecipients(CC)[0] instanceof InternetAddress);
InternetAddress cc = (InternetAddress) renderedMessage.getRecipients(CC)[0];
Assert.assertEquals(cc.getAddress(), "test@example.com");
Assert.assertEquals(cc.getPersonal(), "Pete Muir");
Assert.assertEquals(renderedMessage.getRecipients(BCC).length, 1);
Assert.assertTrue(renderedMessage.getRecipients(BCC)[0] instanceof InternetAddress);
InternetAddress bcc = (InternetAddress) renderedMessage.getRecipients(CC)[0];
Assert.assertEquals(bcc.getAddress(), "test@example.com");
Assert.assertEquals(bcc.getPersonal(), "Pete Muir");
Assert.assertEquals(renderedMessage.getHeader("Precedence")[0], "bulk");
// Importance
Assert.assertNotNull(renderedMessage.getHeader("X-Priority"));
Assert.assertNotNull(renderedMessage.getHeader("Priority"));
Assert.assertNotNull(renderedMessage.getHeader("Importance"));
Assert.assertEquals(renderedMessage.getHeader("X-Priority").length, 1);
Assert.assertEquals(renderedMessage.getHeader("Priority").length, 1);
Assert.assertEquals(renderedMessage.getHeader("Importance").length, 1);
Assert.assertEquals(renderedMessage.getHeader("X-Priority")[0], "1");
Assert.assertEquals(renderedMessage.getHeader("Priority")[0], "Urgent");
Assert.assertEquals(renderedMessage.getHeader("Importance")[0], "high");
Assert.assertEquals(renderedMessage.getSubject(), "Plain text email sent by Seam");
// Check the body
Assert.assertNotNull(renderedMessage.getContent());
MimeMultipart body = (MimeMultipart) renderedMessage.getContent();
Assert.assertEquals(body.getCount(), 1);
MimeBodyPart bodyPart = (MimeBodyPart) body.getBodyPart(0);
Assert.assertNotNull(bodyPart.getContent());
Assert.assertEquals(bodyPart.getDisposition(), "inline");
Assert.assertTrue(bodyPart.isMimeType("text/plain"));