}
@Override
protected void invokeApplication() throws Exception
{
MimeMessage renderedMessage = getRenderedMailMessage("/templating.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.getSubject(), "Templating with Seam Mail");
Assert.assertNull(renderedMessage.getHeader("X-Priority"));
Assert.assertNull(renderedMessage.getHeader("Priority"));
Assert.assertNull(renderedMessage.getHeader("Importance"));
// Check the body
MimeMultipart body = (MimeMultipart) renderedMessage.getContent();
// Check the alternative facet
Assert.assertTrue(renderedMessage.getContentType().startsWith("multipart/mixed"));
Assert.assertEquals(body.getCount(), 1);
MimeBodyPart bodyPart = (MimeBodyPart) body.getBodyPart(0);
Assert.assertTrue(bodyPart.getContentType().startsWith("multipart/alternative"));
Assert.assertTrue(bodyPart.getContent() instanceof MimeMultipart);
MimeMultipart bodyParts = (MimeMultipart) bodyPart.getContent();