[seam-commits] Seam SVN: r15538 - in branches/enterprise/WFK-2_1/examples/mail: mail-ear and 25 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Jun 4 02:41:10 EDT 2013
Author: tremes
Date: 2013-06-04 02:41:09 -0400 (Tue, 04 Jun 2013)
New Revision: 15538
Added:
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/main/resources/META-INF/ejb-jar.xml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/Deployments.java
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/MailTest.java
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/arquillian.xml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/components.xml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/ejb-jar.xml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/html.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/jboss-deployment-structure.xml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/plain.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/seam.properties
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/simple.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/template.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/templating.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/web.xml
Removed:
branches/enterprise/WFK-2_1/examples/mail/mail-tests/pom.xml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/MailTest.java
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/selenium/SeleniumMailTest.java
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-ftest/testng.xml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/arquillian.xml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/web.xml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml
branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml
Modified:
branches/enterprise/WFK-2_1/examples/mail/mail-ear/pom.xml
branches/enterprise/WFK-2_1/examples/mail/mail-ejb/pom.xml
branches/enterprise/WFK-2_1/examples/mail/mail-web/pom.xml
branches/enterprise/WFK-2_1/examples/mail/pom.xml
Log:
Mail example migrated
Modified: branches/enterprise/WFK-2_1/examples/mail/mail-ear/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ear/pom.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ear/pom.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -61,6 +61,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
+ <version>${version.ear.plugin}</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
Modified: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/pom.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/pom.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -20,26 +20,146 @@
<type>ejb</type>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam-mail</artifactId>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
+
+ <profiles>
+ <profile>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ </property>
+ </activation>
+ <properties>
+ <jndiPattern>java:app/seam-mail/#{ejbName}</jndiPattern>
+ <distributable>false</distributable>
+ </properties>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>arq-jbossas-7-managed</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ <value>jbossas-managed-7</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <profile>
+ <id>arq-jbossas-7-remote</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ <value>jbossas-remote-7</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-remote</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <!-- Skip tests by default -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/main/resources/META-INF/ejb-jar.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/main/resources/META-INF/ejb-jar.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/main/resources/META-INF/ejb-jar.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+
+ <interceptors>
+ <interceptor>
+ <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor>
+ </interceptors>
+
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/Deployments.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/Deployments.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/Deployments.java 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,47 @@
+package org.jboss.seam.example.mail.test;
+
+import java.io.File;
+
+import org.jboss.seam.example.mail.MailExample;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+public class Deployments
+{
+
+ public static WebArchive mailDeployment() {
+
+ // use profiles defined in 'maven.profiles' property in pom.xml
+ String profilesString = System.getProperty("maven.profiles");
+ String[] profiles = profilesString != null ? profilesString.split(", ?") : new String[0];
+
+ File[] libs = Maven.resolver().loadPomFromFile("pom.xml", profiles)
+ .importCompileAndRuntimeDependencies()
+ // force resolve jboss-seam, because it is provided-scoped in the pom, but we need it bundled in the WAR
+ .resolve("org.jboss.seam:jboss-seam").withTransitivity().asFile();
+
+
+
+ return ShrinkWrap.create(WebArchive.class, "seam-mail.war")
+ .addPackage(MailExample.class.getPackage())
+ .addAsWebInfResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
+ .addAsWebInfResource("components.xml", "components.xml")
+ .addAsWebInfResource("jboss-deployment-structure.xml", "jboss-deployment-structure.xml")
+ .addAsWebInfResource("seam.properties", "classes/seam.properties")
+ .addAsWebInfResource("web.xml", "web.xml")
+ .addAsWebResource("org/jboss/seam/example/mail/test/errors1.xhtml", "org/jboss/seam/example/mail/test/errors1.xhtml")
+ .addAsWebResource("org/jboss/seam/example/mail/test/errors2.xhtml", "org/jboss/seam/example/mail/test/errors2.xhtml")
+ .addAsWebResource("org/jboss/seam/example/mail/test/errors3.xhtml", "org/jboss/seam/example/mail/test/errors3.xhtml")
+ .addAsWebResource("org/jboss/seam/example/mail/test/errors4.xhtml", "org/jboss/seam/example/mail/test/errors4.xhtml")
+ .addAsWebResource("org/jboss/seam/example/mail/test/sanitization.xhtml", "org/jboss/seam/example/mail/test/sanitization.xhtml")
+ .addAsWebResource("simple.xhtml")
+ .addAsWebResource("plain.xhtml")
+ .addAsWebResource("html.xhtml")
+ .addAsWebResource("templating.xhtml")
+ .addAsWebResource("template.xhtml")
+ .addAsLibraries(libs);
+
+ }
+
+}
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/MailTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/MailTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/java/org/jboss/seam/example/mail/test/MailTest.java 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,512 @@
+package org.jboss.seam.example.mail.test;
+
+import static javax.mail.Message.RecipientType.BCC;
+import static javax.mail.Message.RecipientType.CC;
+
+import java.io.InputStream;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.Seam;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.document.ByteArrayDocumentData;
+import org.jboss.seam.document.DocumentData;
+import org.jboss.seam.example.mail.Person;
+import org.jboss.seam.faces.Renderer;
+import org.jboss.seam.mail.MailSession;
+import org.jboss.seam.mail.ui.UIAttachment;
+import org.jboss.seam.mail.ui.UIMessage;
+import org.jboss.seam.mock.MockTransport;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Pete Muir
+ *
+ */
+ at RunWith(Arquillian.class)
+public class MailTest
+{
+ @Deployment(name = "MailTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+
+ return Deployments.mailDeployment();
+ }
+
+ @Before
+ public void before()
+ {
+ Lifecycle.beginCall();
+ }
+
+ @After
+ public void after()
+ {
+ Lifecycle.endCall();
+ }
+
+ protected MimeMessage getRenderedMailMessage(String viewId)
+ {
+ Contexts.getApplicationContext().set(Seam.getComponentName(MailSession.class), new MailSession("mock").create());
+ MockTransport.clearMailMessage();
+ Renderer.instance().render(viewId);
+ return MockTransport.getMailMessage();
+ }
+
+ @Test
+ public void testSimple() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ person.setAddress("test at example.com");
+
+ MimeMessage renderedMessage = getRenderedMailMessage("/simple.xhtml");
+ Assert.assertTrue(MailSession.instance().getTransport() instanceof MockTransport);
+
+ // Test the headers
+
+ Assert.assertNotNull(renderedMessage);
+ Assert.assertEquals(renderedMessage.getAllRecipients().length, 1);
+ Assert.assertTrue(renderedMessage.getAllRecipients()[0] instanceof InternetAddress);
+ InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
+ Assert.assertEquals(to.getAddress(), "test at example.com");
+ Assert.assertEquals(to.getPersonal(), "Pete Muir");
+ Assert.assertEquals(renderedMessage.getFrom().length, 1);
+ Assert.assertTrue(renderedMessage.getFrom()[0] instanceof InternetAddress);
+ InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
+ Assert.assertEquals(from.getAddress(), "peter at example.com");
+ Assert.assertEquals(from.getPersonal(), "Peter");
+ Assert.assertEquals(renderedMessage.getSubject(), "Try out Seam!");
+ Assert.assertNull(renderedMessage.getHeader("Precedence"));
+ Assert.assertNull(renderedMessage.getHeader("X-Priority"));
+ Assert.assertNull(renderedMessage.getHeader("Priority"));
+ Assert.assertNull(renderedMessage.getHeader("Importance"));
+ Assert.assertNull(renderedMessage.getHeader("Disposition-Notification-To"));
+
+ // Check the body
+
+ Assert.assertNotNull(renderedMessage.getContent());
+ Assert.assertTrue(renderedMessage.getContent() instanceof MimeMultipart);
+ MimeMultipart body = (MimeMultipart) renderedMessage.getContent();
+ Assert.assertEquals(body.getCount(), 1);
+ Assert.assertNotNull(body.getBodyPart(0));
+ Assert.assertTrue(body.getBodyPart(0) instanceof MimeBodyPart);
+ MimeBodyPart bodyPart = (MimeBodyPart) body.getBodyPart(0);
+ Assert.assertNotNull(bodyPart.getContent());
+ Assert.assertEquals(bodyPart.getDisposition(), "inline");
+ Assert.assertTrue(bodyPart.isMimeType("text/html"));
+ }
+
+ @Ignore
+ @Test
+ public void testAttachment() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Gavin");
+ person.setLastname("King");
+ person.setAddress("gavin at king.com");
+
+ MimeMessage renderedMessage = getRenderedMailMessage("/attachment.xhtml");
+
+ // Test the headers
+
+ InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
+ Assert.assertEquals(to.getAddress(), "gavin at king.com");
+ Assert.assertEquals(to.getPersonal(), "Gavin King");
+ InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
+ Assert.assertEquals(from.getAddress(), "do-not-reply at jboss.com");
+ Assert.assertEquals(from.getPersonal(), "Seam");
+ Assert.assertEquals(renderedMessage.getSubject(), "Try out Seam!");
+ MimeMultipart body = (MimeMultipart) renderedMessage.getContent();
+
+ Assert.assertEquals(body.getCount(), 6); // 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");
+ Assert.assertNotNull(bodyPart.getContentID());
+
+ // Root Attachment 0
+ Assert.assertNotNull(body.getBodyPart(1));
+ Assert.assertTrue(body.getBodyPart(1) instanceof MimeBodyPart);
+ bodyPart = (MimeBodyPart) body.getBodyPart(1);
+ Assert.assertNotNull(bodyPart.getContent());
+ Assert.assertTrue(bodyPart.getContent() instanceof InputStream);
+ Assert.assertEquals(bodyPart.getFileName(), "numbers.csv");
+ Assert.assertTrue(bodyPart.isMimeType("content/unknown"));
+ Assert.assertEquals(bodyPart.getDisposition(), "attachment");
+ Assert.assertNull(bodyPart.getContentID());
+
+ // Root Attachment 1
+ Assert.assertNotNull(body.getBodyPart(2));
+ Assert.assertTrue(body.getBodyPart(2) instanceof MimeBodyPart);
+ bodyPart = (MimeBodyPart) body.getBodyPart(2);
+ Assert.assertNotNull(bodyPart.getContent());
+ Assert.assertTrue(bodyPart.getContent() instanceof String);
+ Assert.assertEquals(bodyPart.getFileName(), "whyseam.pdf");
+ Assert.assertEquals(bodyPart.getDisposition(), "attachment");
+ Assert.assertNull(bodyPart.getContentID());
+
+ // Root Attachment 3
+ Assert.assertNotNull(body.getBodyPart(3));
+ Assert.assertTrue(body.getBodyPart(3) instanceof MimeBodyPart);
+ bodyPart = (MimeBodyPart) body.getBodyPart(3);
+ Assert.assertNotNull(bodyPart.getContent());
+ Assert.assertEquals(bodyPart.getFileName(), "excel.xls");
+ Assert.assertTrue(bodyPart.isMimeType("application/vnd.ms-excel"));
+ Assert.assertEquals(bodyPart.getDisposition(), "attachment");
+ Assert.assertNull(bodyPart.getContentID());
+
+ }
+
+ @Test
+ public void testPdfAttachment() throws Exception
+ {
+ UIAttachment attachment = new UIAttachment();
+ attachment.setFileName("filename.pdf");
+ UIMessage message = new UIMessage();
+ attachment.setParent(message);
+ message.setMailSession(MailSession.instance());
+ DocumentData doc = new ByteArrayDocumentData("filename", new DocumentData.DocumentType("pdf", "application/pdf"), new byte[] {});
+ attachment.setValue(doc);
+ attachment.encodeEnd(FacesContext.getCurrentInstance());
+
+ // verify we built the message
+ Assert.assertEquals(message.getAttachments().size(), 1);
+ MimeBodyPart bodyPart = message.getAttachments().get(0);
+ Assert.assertEquals(bodyPart.getFileName(), "filename.pdf");
+ Assert.assertEquals(bodyPart.getDisposition(), "attachment");
+ }
+
+ @Test
+ public void testHtml() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ person.setAddress("test at example.com");
+
+ MimeMessage renderedMessage = getRenderedMailMessage("/html.xhtml");
+
+ // Test the standard headers
+
+ InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
+ Assert.assertEquals(to.getAddress(), "test at example.com");
+ Assert.assertEquals(to.getPersonal(), "Pete Muir");
+ InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
+ Assert.assertEquals(from.getAddress(), "do-not-reply at jboss.com");
+ Assert.assertEquals(from.getPersonal(), "Seam");
+ Assert.assertEquals(renderedMessage.getSubject(), "Seam Mail");
+
+ // Test the extra headers
+
+ // 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], "5");
+ Assert.assertEquals(renderedMessage.getHeader("Priority")[0], "Non-urgent");
+ Assert.assertEquals(renderedMessage.getHeader("Importance")[0], "low");
+
+ // read receipt
+ Assert.assertNotNull(renderedMessage.getHeader("Disposition-Notification-To"));
+ Assert.assertEquals(renderedMessage.getHeader("Disposition-Notification-To").length, 1);
+ Assert.assertEquals(renderedMessage.getHeader("Disposition-Notification-To")[0], "Seam <do-not-reply at jboss.com>");
+
+ // m:header
+ Assert.assertNotNull(renderedMessage.getHeader("X-Sent-From"));
+ Assert.assertEquals(renderedMessage.getHeader("X-Sent-From").length, 1);
+ Assert.assertEquals(renderedMessage.getHeader("X-Sent-From")[0], "Seam");
+
+ 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();
+ Assert.assertEquals(bodyParts.getCount(), 2);
+ Assert.assertTrue(bodyParts.getBodyPart(0) instanceof MimeBodyPart);
+ Assert.assertTrue(bodyParts.getBodyPart(1) instanceof MimeBodyPart);
+ MimeBodyPart alternative = (MimeBodyPart) bodyParts.getBodyPart(0);
+ MimeBodyPart html = (MimeBodyPart) bodyParts.getBodyPart(1);
+ Assert.assertTrue(alternative.isMimeType("text/plain"));
+ Assert.assertEquals(alternative.getDisposition(), "inline");
+ Assert.assertTrue(html.isMimeType("text/html"));
+ }
+
+ @Test
+ public void testPlain() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ person.setAddress("test at example.com");
+
+ MimeMessage renderedMessage = getRenderedMailMessage("/plain.xhtml");
+
+ // Test the standard headers
+
+ InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
+ Assert.assertEquals(to.getAddress(), "test at example.com");
+ Assert.assertEquals(to.getPersonal(), "Pete Muir");
+ InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
+ Assert.assertEquals(from.getAddress(), "do-not-reply at 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 at 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 at 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 at 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"));
+
+ }
+
+ @Test
+ public void testAttachmentErrors() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ person.setAddress("test at example.com");
+
+ // Test for an unavailable attachment
+
+ Contexts.getEventContext().set("attachment", "/foo.pdf");
+
+ }
+
+ @Test
+ public void testAddressValidation() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ boolean exceptionThrown = false;
+ person.setAddress("testexample.com");
+
+ try
+ {
+ getRenderedMailMessage("/org/jboss/seam/example/mail/test/errors2.xhtml");
+ }
+ catch (FacesException e)
+ {
+ Assert.assertTrue(e.getCause() instanceof AddressException);
+ AddressException ae = (AddressException) e.getCause();
+ Assert.assertTrue(ae.getMessage().startsWith("Missing final '@domain'"));
+ exceptionThrown = true;
+ }
+ Assert.assertTrue(exceptionThrown);
+
+ }
+
+ // JBSEAM-2109
+ // @Test
+ public void testReplyToErrors() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ person.setAddress("test at example.com");
+
+ boolean exceptionThrown = false;
+
+ try
+ {
+ getRenderedMailMessage("/org/jboss/seam/example/mail/test/errors3.xhtml");
+ }
+ catch (Exception e)
+ {
+ Assert.assertTrue(e.getCause() instanceof AddressException);
+ AddressException ae = (AddressException) e.getCause();
+ System.out.println(ae.getMessage());
+ Assert.assertTrue(ae.getMessage().startsWith("Email cannot have more than one Reply-to address"));
+ exceptionThrown = true;
+ }
+ Assert.assertTrue(exceptionThrown);
+ }
+
+ @Test
+ public void testFromErrors() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ person.setAddress("test at example.com");
+
+ boolean exceptionThrown = false;
+
+ try
+ {
+ getRenderedMailMessage("/org/jboss/seam/example/mail/test/errors4.xhtml");
+ }
+ catch (FacesException e)
+ {
+ Assert.assertTrue(e.getCause() instanceof AddressException);
+ AddressException ae = (AddressException) e.getCause();
+ Assert.assertTrue(ae.getMessage().startsWith("Email cannot have more than one from address"));
+ exceptionThrown = true;
+ }
+ Assert.assertTrue(exceptionThrown);
+ }
+
+ @Test
+ public void testSanitization() throws Exception
+ {
+ Contexts.getEventContext().set("name", "Pete\nMuir");
+ MimeMessage renderedMessage = getRenderedMailMessage("/org/jboss/seam/example/mail/test/sanitization.xhtml");
+ Assert.assertEquals(renderedMessage.getSubject(), "Try out Seam!");
+ InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
+ Assert.assertEquals(to.getAddress(), "peter at email.tld");
+ Assert.assertEquals(to.getPersonal(), "Pete");
+ Assert.assertEquals(renderedMessage.getFrom().length, 1);
+ Assert.assertTrue(renderedMessage.getFrom()[0] instanceof InternetAddress);
+ InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
+ Assert.assertEquals(from.getAddress(), "peter at example.com");
+ Assert.assertEquals(from.getPersonal(), "Pete");
+ Assert.assertNotNull(renderedMessage.getHeader("Pete"));
+ Assert.assertEquals(renderedMessage.getHeader("Pete").length, 1);
+ Assert.assertEquals(renderedMessage.getHeader("Pete")[0], "roll over");
+ }
+
+ @Test
+ public void testTemplating() throws Exception
+ {
+ Person person = (Person) Component.getInstance("person");
+ person.setFirstname("Pete");
+ person.setLastname("Muir");
+ person.setAddress("test at example.com");
+
+ MimeMessage renderedMessage = getRenderedMailMessage("/templating.xhtml");
+
+ // Test the standard headers
+
+ InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
+ Assert.assertEquals(to.getAddress(), "test at example.com");
+ Assert.assertEquals(to.getPersonal(), "Pete Muir");
+ InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
+ Assert.assertEquals(from.getAddress(), "do-not-reply at 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();
+ Assert.assertEquals(bodyParts.getCount(), 2);
+ Assert.assertTrue(bodyParts.getBodyPart(0) instanceof MimeBodyPart);
+ Assert.assertTrue(bodyParts.getBodyPart(1) instanceof MimeBodyPart);
+ MimeBodyPart alternative = (MimeBodyPart) bodyParts.getBodyPart(0);
+ MimeBodyPart html = (MimeBodyPart) bodyParts.getBodyPart(1);
+ Assert.assertTrue(alternative.isMimeType("text/plain"));
+ Assert.assertEquals(alternative.getDisposition(), "inline");
+ Assert.assertTrue(html.isMimeType("text/html"));
+ Assert.assertEquals(html.getDisposition(), "inline");
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/arquillian.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/arquillian.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/arquillian.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://jboss.org/schema/arquillian"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+ <engine>
+ <property name="deploymentExportPath">target/</property>
+ </engine>
+
+ <container qualifier="jboss" default="true">
+ <configuration>
+ <!-- These properties are only valid for arquillian managed container,
+ but don't cause a problem for the remote container, so they can be left in. -->
+ <!-- To use jacoco, set jacoco.agent system property to something like
+ -javaagent:/path/to/jacocoagent.jar=append=true,destfile=/path/to/output/jacoco.exec -->
+ <property name="javaVmArguments">-Xmx1024m -XX:MaxPermSize=1024m ${jacoco.agent}</property>
+ <property name="serverConfig">standalone.xml</property>
+ <!-- If jbossHome property is not set, the JBOSS_HOME environment variable
+ is used -->
+ <!--<property name="jbossHome">/path/to/jboss/as</property> -->
+ </configuration>
+ </container>
+
+</arquillian>
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/components.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/components.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/components.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,20 @@
+<components xmlns="http://jboss.org/schema/seam/components"
+ xmlns:core="http://jboss.org/schema/seam/core"
+ xmlns:async="http://jboss.org/schema/seam/async"
+ xmlns:mail="http://jboss.org/schema/seam/mail"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://jboss.org/schema/seam/core http://jboss.org/schema/seam/core-2.3.xsd
+ http://jboss.org/schema/seam/async http://jboss.org/schema/seam/async-2.3.xsd
+ http://jboss.org/schema/seam/mail http://jboss.org/schema/seam/mail-2.3.xsd
+ http://jboss.org/schema/seam/components http://jboss.org/schema/seam/components-2.3.xsd">
+
+
+ <core:init debug="true" jndi-pattern="${jndiPattern}" />
+
+ <!-- If you need to alter the SMTP gateway, comment out this mail-session, -->
+ <!--<mail:mail-session host="localhost" port="2525" /> -->
+
+ <!-- uncomment this one and set the host attribute to the name or IP address of your SMTP gateway-->
+ <mail:mail-session host="localhost" tls="false" port="3025" ssl="false" />
+</components>
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/ejb-jar.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/ejb-jar.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/ejb-jar.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+
+ <interceptors>
+ <interceptor>
+ <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor>
+ </interceptors>
+
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/html.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/html.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/html.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,22 @@
+<m:message xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ importance="low" requestReadReceipt="true">
+ <m:header name="X-Sent-From" value="Seam" />
+ <m:from name="Seam" address="do-not-reply at jboss.com" />
+ <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
+ <m:subject>Seam Mail</m:subject>
+ <m:body>
+ <html>
+ <body>
+ <p><b>#{person.firstname},</b></p>
+ <p>This is an example <i>HTML</i> email sent by Seam.</p>
+ <p>It has an alternative text body for mail readers that don't support html.</p>
+ </body>
+ </html>
+ <f:facet name="alternative">
+ <h:outputText>This is the alternative text body for mail readers that don't support html</h:outputText>
+ </f:facet>
+ </m:body>
+</m:message>
\ No newline at end of file
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/jboss-deployment-structure.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/jboss-deployment-structure.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/jboss-deployment-structure.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,18 @@
+<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
+ <deployment>
+ <exclusions>
+ <module name="org.hibernate" slot="main" />
+ </exclusions>
+ <dependencies>
+ <module name="org.apache.log4j" export="true" />
+ <module name="org.dom4j" export="true" />
+ <module name="org.apache.commons.logging" export="true" />
+ <module name="org.apache.commons.collections" export="true" />
+ <module name="javax.faces.api" export="true" />
+ <module name="com.sun.jsf-impl" export="true" />
+ <module name="org.slf4j" export="true" />
+ <module name="org.javassist" export="true"/>
+ <module name="javax.mail.api" export="true"/>
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
Copied: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml (from rev 15537, branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml)
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,10 @@
+<m:message xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <m:from name="Peter">peter at example.com</m:from>
+ <m:to name="Peter">peter at email.tld</m:to>
+ <m:subject>Try out Seam!</m:subject>
+ <m:attachment value="#{attachment}" />
+ <m:body>A mail message to test exception handling</m:body>
+</m:message>
\ No newline at end of file
Copied: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml (from rev 15537, branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml)
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,9 @@
+<m:message xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <m:from name="Peter" address="peter at example.com" />
+ <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
+ <m:subject>Try out Seam!</m:subject>
+ <m:body>A mail message to test exception handling</m:body>
+</m:message>
\ No newline at end of file
Copied: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml (from rev 15537, branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml)
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,11 @@
+<m:message xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <m:replyTo address="foo at bar.com" />
+ <m:replyTo address="bar at bar.com" />
+ <m:from name="Peter" address="peter at example.com" />
+ <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
+ <m:subject>Try out Seam!</m:subject>
+ <m:body>A mail message to test exception handling</m:body>
+</m:message>
\ No newline at end of file
Copied: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml (from rev 15537, branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml)
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,10 @@
+<m:message xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <m:from address="bar at bar.com" />
+ <m:from name="Peter" address="peter at example.com" />
+ <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
+ <m:subject>Try out Seam!</m:subject>
+ <m:body>A mail message to test exception handling</m:body>
+</m:message>
\ No newline at end of file
Copied: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml (from rev 15537, branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml)
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,14 @@
+<m:message xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <m:from name="#{name}">peter at example.com
+foo</m:from>
+ <m:to name="#{name}">peter at email.tld
+bar</m:to>
+ <m:subject>Try out
+ Seam!</m:subject>
+ <m:header name="#{name}">roll
+ over</m:header>
+ <m:body>A mail message to test sanitization</m:body>
+</m:message>
\ No newline at end of file
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/plain.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/plain.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/plain.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,16 @@
+<m:message xmlns:m="http://jboss.org/schema/seam/mail" importance="high" precedence="bulk">
+
+ <m:from name="Seam" address="do-not-reply at jboss.com" />
+ <m:replyTo name="JBoss" address="another.address at jboss.org" />
+ <m:cc name="#{person.firstname} #{person.lastname}">#{person.address}</m:cc>
+ <m:bcc name="#{person.firstname} #{person.lastname}">#{person.address}</m:bcc>
+ <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
+ <m:subject>Plain text email sent by Seam</m:subject>
+ <m:body type="plain">Dear #{person.firstname},
+
+This is a plain text, email.
+
+Regards
+
+JBoss Seam Mail</m:body>
+</m:message>
\ No newline at end of file
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/seam.properties
===================================================================
Copied: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/simple.xhtml (from rev 15537, branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml)
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/simple.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/simple.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,14 @@
+<m:message xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <m:from name="Peter" address="peter at example.com" />
+ <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
+ <m:subject>Try out Seam!</m:subject>
+ <m:body>
+ <p><h:outputText value="Dear #{person.firstname}" />,</p>
+ <p>You can try out Seam by visiting <a href="http://www.seamframework.org">http://www.seamframework.org</a>.</p>
+ <p>Regards</p>
+ <p>Peter</p>
+ </m:body>
+</m:message>
\ No newline at end of file
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/template.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/template.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/template.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,37 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:s="http://jboss.org/schema/seam/taglib"
+ xmlns:m="http://jboss.org/schema/seam/mail"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <m:message>
+ <m:from name="Seam" address="do-not-reply at jboss.com" />
+ <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
+ <m:subject>#{subject}</m:subject>
+ <m:body>
+ <html>
+ <body>
+ <ui:insert name="body">
+ This is the default body, specified by the template.
+ </ui:insert>
+ </body>
+ </html>
+ <f:facet name="alternative">
+ <ui:insert name="alternative">
+ <h:outputText>Sorry, your mail reader doesn't support html.</h:outputText>
+ </ui:insert>
+ </f:facet>
+ </m:body>
+ </m:message>
+
+ <ui:insert name="successMessage">
+ <html>
+ <body>
+ <p>This email was sent directly from the view without invoking a bean - just link to a page which contains an <m:message> tag!</p>
+ <p>The email has been successfully sent. <s:link view="/index.xhtml">Click here</s:link> to return to the index.</p>
+ </body>
+ </html>
+ </ui:insert>
+
+</ui:composition>
\ No newline at end of file
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/templating.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/templating.xhtml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/templating.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,28 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ template="template.xhtml" importance="normal">
+
+ <ui:param name="subject" value="Templating with Seam Mail" />
+
+ <ui:define name="body">
+
+ <p>This email demonstrates that you can easily use <i>facelets templating features</i> in your code!</p>
+
+ <p>In fact you can use <b>any</b> JSF tags that you like!</p>
+
+ <p>Here's a dataTable</p>
+
+ <h:dataTable value="#{lists.daysOfWeek}" var="day">
+ <h:column>
+ <f:facet name="header">
+ Day
+ </f:facet>
+ <h:outputText value="#{day}" />
+ </h:column>
+ </h:dataTable>
+
+ </ui:define>
+
+</ui:composition>
\ No newline at end of file
Added: branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/web.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/web.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-ejb/src/test/resources/web.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="3.0"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+ <!-- Seam -->
+
+ <listener>
+ <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
+ </listener>
+
+ <filter>
+ <filter-name>Seam Filter</filter-name>
+ <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Seam Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>com.sun.faces.allowTextChildren</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.seam</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>Mail Servlet</servlet-name>
+ <servlet-class>org.jboss.seam.example.mail.MailSenderServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Mail Servlet</servlet-name>
+ <url-pattern>/mail/sender</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/pom.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/pom.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,193 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>mail</artifactId>
- <groupId>org.jboss.seam.examples</groupId>
- <version>2.3.1.Final-redhat-2</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <groupId>org.jboss.seam.examples.mail</groupId>
- <artifactId>mail-tests</artifactId>
- <name>Mail Integration Tests Module (EE6)</name>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.seam.examples.mail</groupId>
- <artifactId>mail-ejb</artifactId>
- <type>ejb</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam</artifactId>
- <type>ejb</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-mail</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-pdf</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-excel</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-ui</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-server</artifactId>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-java</artifactId>
- </dependency>
- <dependency>
- <groupId>org.subethamail</groupId>
- <artifactId>subethasmtp-wiser</artifactId>
- <version>1.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>functional-tests</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.spec.javax.el</groupId>
- <artifactId>jboss-el-api_2.2_spec</artifactId>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- </testResource>
- <testResource> <!-- this takes datasource mail-ds.xml -->
- <directory>${basedir}/../mail-ear/src/main/resources</directory>
- <filtering>true</filtering>
- </testResource>
- <testResource> <!-- this takes themes aka *.properties -->
- <directory>${basedir}/../mail-web/src/main/resources</directory>
- <filtering>true</filtering>
- </testResource>
- <testResource>
- <directory>src/test/resources-integration</directory>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>integration-tests</id>
- <activation>
- <property>
- <name>arquillian</name>
- </property>
- </activation>
- </profile>
-
- <profile>
- <id>arq-jbossas-7-managed</id>
- <activation>
- <property>
- <name>arquillian</name>
- <value>jbossas-managed-7</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>arq-jbossas-7-remote</id>
- <activation>
- <property>
- <name>arquillian</name>
- <value>jbossas-remote-7</value>
- </property>
- </activation>
- </profile>
-
- <profile>
- <id>ftest-jbossas</id>
- <properties>
- <example.context.path>seam-mail</example.context.path>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>selenium-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>failsafe-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/MailTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/MailTest.java 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/MailTest.java 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,529 +0,0 @@
-package org.jboss.seam.example.mail.test;
-
-import static javax.mail.Message.RecipientType.BCC;
-import static javax.mail.Message.RecipientType.CC;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.importer.ZipImporter;
-import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.container.test.api.OverProtocol;
-import org.jboss.arquillian.junit.Arquillian;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.Seam;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.contexts.Lifecycle;
-import org.jboss.seam.document.ByteArrayDocumentData;
-import org.jboss.seam.document.DocumentData;
-import org.jboss.seam.example.mail.Person;
-import org.jboss.seam.faces.Renderer;
-import org.jboss.seam.mail.MailSession;
-import org.jboss.seam.mail.ui.UIAttachment;
-import org.jboss.seam.mail.ui.UIMessage;
-import org.jboss.seam.mock.MockTransport;
-
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.runner.RunWith;
-
-/**
- * @author Pete Muir
- *
- */
- at RunWith(Arquillian.class)
-public class MailTest
-{
- @Deployment(name="MailTest")
- @OverProtocol("Servlet 3.0")
- public static Archive<?> createDeployment()
- {
- EnterpriseArchive er = ShrinkWrap.create(ZipImporter.class, "seam-mail.ear").importFrom(new File("../mail-ear/target/seam-mail.ear"))
- .as(EnterpriseArchive.class);
- WebArchive web = er.getAsType(WebArchive.class, "mail-web.war");
- web.addClasses(MailTest.class);
- web.addAsWebResource("org/jboss/seam/example/mail/test/errors1.xhtml", "org/jboss/seam/example/mail/test/errors1.xhtml");
- web.addAsWebResource("org/jboss/seam/example/mail/test/errors2.xhtml", "org/jboss/seam/example/mail/test/errors2.xhtml");
- web.addAsWebResource("org/jboss/seam/example/mail/test/errors3.xhtml", "org/jboss/seam/example/mail/test/errors3.xhtml");
- web.addAsWebResource("org/jboss/seam/example/mail/test/errors4.xhtml", "org/jboss/seam/example/mail/test/errors4.xhtml");
- web.addAsWebResource("org/jboss/seam/example/mail/test/sanitization.xhtml", "org/jboss/seam/example/mail/test/sanitization.xhtml");
-
- return er;
- }
-
- @Before
- public void before() {
- Lifecycle.beginCall();
- }
-
- @After
- public void after() {
- Lifecycle.endCall();
- }
-
- protected MimeMessage getRenderedMailMessage(String viewId)
- {
- Contexts.getApplicationContext().set(Seam.getComponentName(MailSession.class), new MailSession("mock").create());
- MockTransport.clearMailMessage();
- Renderer.instance().render(viewId);
- return MockTransport.getMailMessage();
- }
-
-
-
- @Test
- public void testSimple() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- person.setAddress("test at example.com");
-
- MimeMessage renderedMessage = getRenderedMailMessage("/simple.xhtml");
- Assert.assertTrue(MailSession.instance().getTransport() instanceof MockTransport);
-
- // Test the headers
-
- Assert.assertNotNull(renderedMessage);
- Assert.assertEquals(renderedMessage.getAllRecipients().length, 1);
- Assert.assertTrue(renderedMessage.getAllRecipients()[0] instanceof InternetAddress);
- InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
- Assert.assertEquals(to.getAddress(), "test at example.com");
- Assert.assertEquals(to.getPersonal(), "Pete Muir");
- Assert.assertEquals(renderedMessage.getFrom().length, 1);
- Assert.assertTrue(renderedMessage.getFrom()[0] instanceof InternetAddress);
- InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
- Assert.assertEquals(from.getAddress(), "peter at example.com");
- Assert.assertEquals(from.getPersonal(), "Peter");
- Assert.assertEquals(renderedMessage.getSubject(), "Try out Seam!");
- Assert.assertNull(renderedMessage.getHeader("Precedence"));
- Assert.assertNull(renderedMessage.getHeader("X-Priority"));
- Assert.assertNull(renderedMessage.getHeader("Priority"));
- Assert.assertNull(renderedMessage.getHeader("Importance"));
- Assert.assertNull(renderedMessage.getHeader("Disposition-Notification-To"));
-
- // Check the body
-
- Assert.assertNotNull(renderedMessage.getContent());
- Assert.assertTrue(renderedMessage.getContent() instanceof MimeMultipart);
- MimeMultipart body = (MimeMultipart) renderedMessage.getContent();
- Assert.assertEquals(body.getCount(), 1);
- Assert.assertNotNull(body.getBodyPart(0));
- Assert.assertTrue(body.getBodyPart(0) instanceof MimeBodyPart);
- MimeBodyPart bodyPart = (MimeBodyPart) body.getBodyPart(0);
- Assert.assertNotNull(bodyPart.getContent());
- Assert.assertEquals(bodyPart.getDisposition(), "inline");
- Assert.assertTrue(bodyPart.isMimeType("text/html"));
- }
-
- @Ignore
- @Test
- public void testAttachment() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Gavin");
- person.setLastname("King");
- person.setAddress("gavin at king.com");
-
- MimeMessage renderedMessage = getRenderedMailMessage("/attachment.xhtml");
-
- // Test the headers
-
- InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
- Assert.assertEquals(to.getAddress(), "gavin at king.com");
- Assert.assertEquals(to.getPersonal(), "Gavin King");
- InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
- Assert.assertEquals(from.getAddress(), "do-not-reply at jboss.com");
- Assert.assertEquals(from.getPersonal(), "Seam");
- Assert.assertEquals(renderedMessage.getSubject(), "Try out Seam!");
- MimeMultipart body = (MimeMultipart) renderedMessage.getContent();
-
- Assert.assertEquals(body.getCount(), 6); //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");
- Assert.assertNotNull(bodyPart.getContentID());
-
- // Root Attachment 0
- Assert.assertNotNull(body.getBodyPart(1));
- Assert.assertTrue(body.getBodyPart(1) instanceof MimeBodyPart);
- bodyPart = (MimeBodyPart) body.getBodyPart(1);
- Assert.assertNotNull(bodyPart.getContent());
- Assert.assertTrue( bodyPart.getContent() instanceof InputStream);
- Assert.assertEquals(bodyPart.getFileName(), "numbers.csv");
- Assert.assertTrue(bodyPart.isMimeType("content/unknown"));
- Assert.assertEquals(bodyPart.getDisposition(), "attachment");
- Assert.assertNull(bodyPart.getContentID());
-
- // Root Attachment 1
- Assert.assertNotNull(body.getBodyPart(2));
- Assert.assertTrue(body.getBodyPart(2) instanceof MimeBodyPart);
- bodyPart = (MimeBodyPart) body.getBodyPart(2);
- Assert.assertNotNull(bodyPart.getContent());
- Assert.assertTrue(bodyPart.getContent() instanceof String);
- Assert.assertEquals(bodyPart.getFileName(), "whyseam.pdf");
- Assert.assertEquals(bodyPart.getDisposition(), "attachment");
- Assert.assertNull(bodyPart.getContentID());
-
- // Root Attachment 3
- Assert.assertNotNull(body.getBodyPart(3));
- Assert.assertTrue(body.getBodyPart(3) instanceof MimeBodyPart);
- bodyPart = (MimeBodyPart) body.getBodyPart(3);
- Assert.assertNotNull(bodyPart.getContent());
- Assert.assertEquals(bodyPart.getFileName(), "excel.xls");
- Assert.assertTrue(bodyPart.isMimeType("application/vnd.ms-excel"));
- Assert.assertEquals(bodyPart.getDisposition(), "attachment");
- Assert.assertNull(bodyPart.getContentID());
-
- }
-
- @Test
- public void testPdfAttachment() throws Exception
- {
- UIAttachment attachment = new UIAttachment();
- attachment.setFileName("filename.pdf");
- UIMessage message = new UIMessage();
- attachment.setParent(message);
- message.setMailSession(MailSession.instance());
- DocumentData doc = new ByteArrayDocumentData("filename", new DocumentData.DocumentType("pdf", "application/pdf"), new byte[] {});
- attachment.setValue(doc);
- attachment.encodeEnd(FacesContext.getCurrentInstance());
-
- // verify we built the message
- Assert.assertEquals(message.getAttachments().size(), 1);
- MimeBodyPart bodyPart = message.getAttachments().get(0);
- Assert.assertEquals(bodyPart.getFileName(), "filename.pdf");
- Assert.assertEquals(bodyPart.getDisposition(),"attachment");
- }
-
- @Test
- public void testHtml() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- person.setAddress("test at example.com");
-
- MimeMessage renderedMessage = getRenderedMailMessage("/html.xhtml");
-
- // Test the standard headers
-
- InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
- Assert.assertEquals(to.getAddress(), "test at example.com");
- Assert.assertEquals(to.getPersonal(), "Pete Muir");
- InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
- Assert.assertEquals(from.getAddress(), "do-not-reply at jboss.com");
- Assert.assertEquals(from.getPersonal(), "Seam");
- Assert.assertEquals(renderedMessage.getSubject(), "Seam Mail");
-
- // Test the extra headers
-
- // 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], "5");
- Assert.assertEquals(renderedMessage.getHeader("Priority")[0], "Non-urgent");
- Assert.assertEquals(renderedMessage.getHeader("Importance")[0], "low");
-
- // read receipt
- Assert.assertNotNull(renderedMessage.getHeader("Disposition-Notification-To"));
- Assert.assertEquals(renderedMessage.getHeader("Disposition-Notification-To").length, 1);
- Assert.assertEquals(renderedMessage.getHeader("Disposition-Notification-To")[0], "Seam <do-not-reply at jboss.com>");
-
- // m:header
- Assert.assertNotNull(renderedMessage.getHeader("X-Sent-From"));
- Assert.assertEquals(renderedMessage.getHeader("X-Sent-From").length, 1);
- Assert.assertEquals(renderedMessage.getHeader("X-Sent-From")[0], "Seam");
-
- 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();
- Assert.assertEquals(bodyParts.getCount(), 2);
- Assert.assertTrue(bodyParts.getBodyPart(0) instanceof MimeBodyPart);
- Assert.assertTrue(bodyParts.getBodyPart(1) instanceof MimeBodyPart);
- MimeBodyPart alternative = (MimeBodyPart) bodyParts.getBodyPart(0);
- MimeBodyPart html = (MimeBodyPart) bodyParts.getBodyPart(1);
- Assert.assertTrue(alternative.isMimeType("text/plain"));
- Assert.assertEquals(alternative.getDisposition(), "inline");
- Assert.assertTrue(html.isMimeType("text/html"));
- }
-
-
- @Test
- public void testPlain() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- person.setAddress("test at example.com");
-
- MimeMessage renderedMessage = getRenderedMailMessage("/plain.xhtml");
-
- // Test the standard headers
-
- InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
- Assert.assertEquals(to.getAddress(), "test at example.com");
- Assert.assertEquals(to.getPersonal(), "Pete Muir");
- InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
- Assert.assertEquals(from.getAddress(), "do-not-reply at 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 at 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 at 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 at 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"));
-
- }
-
- @Test
- public void testAttachmentErrors() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- person.setAddress("test at example.com");
-
- // Test for an unavailable attachment
-
- Contexts.getEventContext().set("attachment", "/foo.pdf");
-
- }
-
- @Test
- public void testAddressValidation() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- boolean exceptionThrown = false;
- person.setAddress("testexample.com");
-
- try
- {
- getRenderedMailMessage("/org/jboss/seam/example/mail/test/errors2.xhtml");
- }
- catch (FacesException e)
- {
- Assert.assertTrue(e.getCause() instanceof AddressException);
- AddressException ae = (AddressException) e.getCause();
- Assert.assertTrue(ae.getMessage().startsWith("Missing final '@domain'"));
- exceptionThrown = true;
- }
- Assert.assertTrue(exceptionThrown);
-
- }
-
-
- //JBSEAM-2109
- //@Test
- public void testReplyToErrors() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- person.setAddress("test at example.com");
-
- boolean exceptionThrown = false;
-
- try
- {
- getRenderedMailMessage("/org/jboss/seam/example/mail/test/errors3.xhtml");
- }
- catch (Exception e)
- {
- Assert.assertTrue(e.getCause() instanceof AddressException);
- AddressException ae = (AddressException) e.getCause();
- System.out.println(ae.getMessage());
- Assert.assertTrue(ae.getMessage().startsWith("Email cannot have more than one Reply-to address"));
- exceptionThrown = true;
- }
- Assert.assertTrue(exceptionThrown);
- }
-
- @Test
- public void testFromErrors() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- person.setAddress("test at example.com");
-
- boolean exceptionThrown = false;
-
- try
- {
- getRenderedMailMessage("/org/jboss/seam/example/mail/test/errors4.xhtml");
- }
- catch (FacesException e)
- {
- Assert.assertTrue(e.getCause() instanceof AddressException);
- AddressException ae = (AddressException) e.getCause();
- Assert.assertTrue(ae.getMessage().startsWith("Email cannot have more than one from address"));
- exceptionThrown = true;
- }
- Assert.assertTrue(exceptionThrown);
- }
-
- @Test
- public void testSanitization() throws Exception
- {
- Contexts.getEventContext().set("name", "Pete\nMuir");
- MimeMessage renderedMessage = getRenderedMailMessage("/org/jboss/seam/example/mail/test/sanitization.xhtml");
- Assert.assertEquals(renderedMessage.getSubject(), "Try out Seam!");
- InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
- Assert.assertEquals(to.getAddress(), "peter at email.tld");
- Assert.assertEquals(to.getPersonal(), "Pete");
- Assert.assertEquals(renderedMessage.getFrom().length, 1);
- Assert.assertTrue(renderedMessage.getFrom()[0] instanceof InternetAddress);
- InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
- Assert.assertEquals(from.getAddress(), "peter at example.com");
- Assert.assertEquals(from.getPersonal(), "Pete");
- Assert.assertNotNull(renderedMessage.getHeader("Pete"));
- Assert.assertEquals(renderedMessage.getHeader("Pete").length, 1);
- Assert.assertEquals(renderedMessage.getHeader("Pete")[0], "roll over");
- }
-
- @Test
- public void testTemplating() throws Exception
- {
- Person person = (Person)Component.getInstance("person");
- person.setFirstname("Pete");
- person.setLastname("Muir");
- person.setAddress("test at example.com");
-
- MimeMessage renderedMessage = getRenderedMailMessage("/templating.xhtml");
-
- // Test the standard headers
-
- InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
- Assert.assertEquals(to.getAddress(), "test at example.com");
- Assert.assertEquals(to.getPersonal(), "Pete Muir");
- InternetAddress from = (InternetAddress) renderedMessage.getFrom()[0];
- Assert.assertEquals(from.getAddress(), "do-not-reply at 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();
- Assert.assertEquals(bodyParts.getCount(), 2);
- Assert.assertTrue(bodyParts.getBodyPart(0) instanceof MimeBodyPart);
- Assert.assertTrue(bodyParts.getBodyPart(1) instanceof MimeBodyPart);
- MimeBodyPart alternative = (MimeBodyPart) bodyParts.getBodyPart(0);
- MimeBodyPart html = (MimeBodyPart) bodyParts.getBodyPart(1);
- Assert.assertTrue(alternative.isMimeType("text/plain"));
- Assert.assertEquals(alternative.getDisposition(), "inline");
- Assert.assertTrue(html.isMimeType("text/html"));
- Assert.assertEquals(html.getDisposition(), "inline");
- }
-}
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/selenium/SeleniumMailTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/selenium/SeleniumMailTest.java 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/java/org/jboss/seam/example/mail/test/selenium/SeleniumMailTest.java 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,148 +0,0 @@
-package org.jboss.seam.example.mail.test.selenium;
-
-import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
-import org.subethamail.wiser.Wiser;
-import org.subethamail.wiser.WiserMessage;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.assertFalse;
-
-public class SeleniumMailTest extends SeamSeleniumTest
-{
- public static final String HOME_PAGE = "/index.seam";
- public static final String HOME_PAGE_TITLE = "Seam Mail";
- public static final String ENVELOPE_SENDER = "peter at example.com|do-not-reply at jboss.com";
-
- public static final String FIRSTNAME_INPUT = "id=emailform:firstname";
- public static final String FIRSTNAME = "John";
- public static final String LASTNAME_INPUT = "id=emailform:lastname";
- public static final String LASTNAME = "Smith";
- public static final String ADDRESS_INPUT = "id=emailform:address";
- public static final String ADDRESS = "john.smith at localhost";
- public static final String SERVLET_NAME_INPUT = "id=name";
- public static final String SERVLET_ADDRESS_INPUT = "id=email";
-
- public static final String SEND_SIMPLE_BUTTON = "id=emailform:sendSimple";
- public static final String SEND_PLAIN_BUTTON = "id=emailform:sendPlain";
- public static final String SEND_HTML_BUTTON = "id=emailform:sendHtml";
- public static final String SEND_ATTACHMENT_BUTTON = "id=emailform:sendAttachment";
- public static final String SEND_ASYNCHRONOUS_BUTTON = "id=emailform:sendAsynchronous";
- public static final String SEND_TEMPLATE_BUTTON = "id=emailform:sendTemplate";
- public static final String SEND_SERVLET_BUTTON = "id=sendServlet";
-
- protected Wiser wiser;
-
- @BeforeMethod
- @Override
- public void setUp()
- {
- super.setUp();
- browser.open(CONTEXT_PATH + HOME_PAGE);
- }
-
- /**
- * We restart SMTP after each Method, because Wiser doesn't have mechanism to flush recieved emails.
- */
- @BeforeMethod
- public void startSMTP()
- {
- wiser = new Wiser();
- wiser.setPort(2525);
- wiser.start();
- }
-
- @AfterMethod
- public void stopSMTP()
- {
- wiser.stop();
- }
-
- /**
- * Place holder - just verifies that example deploys
- */
- @Test
- public void homePageLoadTest()
- {
- assertEquals("Unexpected page title.", HOME_PAGE_TITLE, browser.getTitle());
- }
-
- @DataProvider(name = "sendMethods")
- public Object[][] mailTest() {
- return new Object[][] {
- {SEND_SIMPLE_BUTTON, new String[] {"Content-Type: text/html; charset=ISO-8859-1", "Content-Disposition: inline", "<p>Dear " + FIRSTNAME + ",</p>"}},
- {SEND_PLAIN_BUTTON, new String[] {"This is a plain text, email."}},
- {SEND_HTML_BUTTON, new String[] {"Subject: Seam Mail", "Content-Type: multipart/mixed;", "Content-Type: multipart/alternative;", "Content-Type: text/plain; charset=ISO-8859-1", "This is the alternative text body for mail readers that don't support html", "Content-Type: text/html; charset=ISO-8859-1", "<p>This is an example <i>HTML</i> email sent by Seam.</p>"}},
- {SEND_ATTACHMENT_BUTTON, new String[] {"Content-Type: multipart/mixed;","Content-Type: application/octet-stream; name=jboss.jpg", "/9j/4AAQSkZJRgABA"/*jpeg start*/, "Content-Type: application/octet-stream; name=numbers.csv", "3,Three,treis,trois", "Content-Type: image/png; name=" + FIRSTNAME + "_" + LASTNAME + ".jpg", "iVBORw0KGgo" /*png start*/ }},
- {SEND_ASYNCHRONOUS_BUTTON, new String[] {"Content-Type: multipart/mixed;", "Content-Type: text/html; charset=ISO-8859-1", "Content-Disposition: inline", "<p>Dear " + FIRSTNAME + ",</p>"}},
- {SEND_TEMPLATE_BUTTON, new String[] {"Subject: Templating with Seam Mail", "Content-Type: multipart/mixed;", "Content-Type: multipart/alternative;", "Content-Type: text/plain; charset=ISO-8859-1", "Sorry, your mail reader doesn't support html.", "Content-Type: text/html; charset=ISO-8859-1", "<p>Here's a dataTable</p><table>", "<td>Saturday</td>"}},
- {SEND_SERVLET_BUTTON, new String[] {"Content-Type: multipart/mixed;", "Content-Disposition: inline", "Dear John Smith,", "This is a plain text, email."}}
- };
- }
-
- /**
- * Sends a mail and verifies it was delivered
- */
- @Test(dataProvider = "sendMethods")
- public void mailTest(String buttonToClick, String[] expectedMessageContents) {
- fillInInputs();
- sendEmail(buttonToClick);
- checkDelivered(expectedMessageContents);
- }
-
- /**
- * Fills in html text inputs.
- */
- private void fillInInputs()
- {
- browser.type(FIRSTNAME_INPUT, FIRSTNAME);
- browser.type(LASTNAME_INPUT, LASTNAME);
- browser.type(ADDRESS_INPUT, ADDRESS);
- browser.type(SERVLET_NAME_INPUT, FIRSTNAME + " " + LASTNAME);
- browser.type(SERVLET_ADDRESS_INPUT, ADDRESS);
- }
-
- /**
- * Sends an email by clicking on specified button. If the send method is asynchronous,
- * waits for the associated action to take place. It assures that the email was sent
- * by verifying appropriate message.
- * @param buttonToClick
- */
- private void sendEmail(String buttonToClick)
- {
- browser.clickAndWait(buttonToClick);
- if (buttonToClick.equals(SEND_ASYNCHRONOUS_BUTTON)) {
- assertTrue(browser.isTextPresent("Seam Email")); // asynchronous email send produces no message, so we just check that we didn't end up on a debug page
- try
- {
- Thread.sleep(4000);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- } else {
- assertTrue("Expected message about successfuly sent mail. See also JBSEAM-3769.", browser.isTextPresent("Email sent successfully"));
- }
- }
-
- /**
- * Checks that the expected email was delivered.
- * @param expectedMessageContents
- */
- private void checkDelivered(String[] expectedMessageContents)
- {
- assertFalse("Expected a message", wiser.getMessages().isEmpty());
- WiserMessage message = wiser.getMessages().get(0); // although "send plain text" example sends 3 mails (To:, CC:, Bcc:) Wiser cannot distinquish between them so we just check the first mail.
- assertEquals(ADDRESS, message.getEnvelopeReceiver());
- assertTrue("Envelope sender (" + message.getEnvelopeSender() + ") doesn't match expected one (" + ENVELOPE_SENDER + ")", message.getEnvelopeSender().matches(ENVELOPE_SENDER));
-
- for (String expectedMessageContent: expectedMessageContents) {
- assertTrue("Didn't find expected text (" + expectedMessageContent + ") in the received email.", new String(message.getData()).contains(expectedMessageContent));
- }
- }
-
-}
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors1.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,10 +0,0 @@
-<m:message xmlns="http://www.w3.org/1999/xhtml"
- xmlns:m="http://jboss.org/schema/seam/mail"
- xmlns:h="http://java.sun.com/jsf/html">
-
- <m:from name="Peter">peter at example.com</m:from>
- <m:to name="Peter">peter at email.tld</m:to>
- <m:subject>Try out Seam!</m:subject>
- <m:attachment value="#{attachment}" />
- <m:body>A mail message to test exception handling</m:body>
-</m:message>
\ No newline at end of file
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors2.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,9 +0,0 @@
-<m:message xmlns="http://www.w3.org/1999/xhtml"
- xmlns:m="http://jboss.org/schema/seam/mail"
- xmlns:h="http://java.sun.com/jsf/html">
-
- <m:from name="Peter" address="peter at example.com" />
- <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
- <m:subject>Try out Seam!</m:subject>
- <m:body>A mail message to test exception handling</m:body>
-</m:message>
\ No newline at end of file
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors3.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,11 +0,0 @@
-<m:message xmlns="http://www.w3.org/1999/xhtml"
- xmlns:m="http://jboss.org/schema/seam/mail"
- xmlns:h="http://java.sun.com/jsf/html">
-
- <m:replyTo address="foo at bar.com" />
- <m:replyTo address="bar at bar.com" />
- <m:from name="Peter" address="peter at example.com" />
- <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
- <m:subject>Try out Seam!</m:subject>
- <m:body>A mail message to test exception handling</m:body>
-</m:message>
\ No newline at end of file
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/errors4.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,10 +0,0 @@
-<m:message xmlns="http://www.w3.org/1999/xhtml"
- xmlns:m="http://jboss.org/schema/seam/mail"
- xmlns:h="http://java.sun.com/jsf/html">
-
- <m:from address="bar at bar.com" />
- <m:from name="Peter" address="peter at example.com" />
- <m:to name="#{person.firstname} #{person.lastname}">#{person.address}</m:to>
- <m:subject>Try out Seam!</m:subject>
- <m:body>A mail message to test exception handling</m:body>
-</m:message>
\ No newline at end of file
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources/org/jboss/seam/example/mail/test/sanitization.xhtml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,14 +0,0 @@
-<m:message xmlns="http://www.w3.org/1999/xhtml"
- xmlns:m="http://jboss.org/schema/seam/mail"
- xmlns:h="http://java.sun.com/jsf/html">
-
- <m:from name="#{name}">peter at example.com
-foo</m:from>
- <m:to name="#{name}">peter at email.tld
-bar</m:to>
- <m:subject>Try out
- Seam!</m:subject>
- <m:header name="#{name}">roll
- over</m:header>
- <m:body>A mail message to test sanitization</m:body>
-</m:message>
\ No newline at end of file
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-ftest/testng.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-ftest/testng.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-ftest/testng.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,26 +0,0 @@
-
- <!--
- JBoss, Home of Professional Open Source Copyright 2008, Red Hat
- Middleware LLC, and individual contributors by the @authors tag. See
- the copyright.txt in the distribution for a full listing of individual
- contributors. This is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version. This software is
- distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- License for more details. You should have received a copy of the GNU
- Lesser General Public License along with this software; if not, write
- to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- -->
-<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
-<suite name="Mail example" verbose="2" parallel="false">
- <test name="mail_jboss">
- <parameter name="PROPERTY_FILE" value="" />
- <classes>
- <class name="org.jboss.seam.example.mail.test.selenium.SeleniumMailTest" />
- </classes>
- </test>
-</suite>
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/arquillian.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/arquillian.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/arquillian.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://jboss.org/schema/arquillian"
- xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
-
- <engine>
- <property name="deploymentExportPath">target/</property>
- </engine>
-
- <container qualifier="jboss" default="true">
- <configuration>
- <property name="javaVmArguments">-Xmx1024m -XX:MaxPermSize=512m ${jacoco.agent}</property>
- </configuration>
- </container>
-
-</arquillian>
Deleted: branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/web.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/web.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-tests/src/test/resources-integration/web.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,12 +0,0 @@
-<?xml version="1.0" ?>
-
-<web-app version="3.0"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
-
- <listener>
- <listener-class>org.jboss.seam.mock.MockSeamListener</listener-class>
- </listener>
-
-</web-app>
Modified: branches/enterprise/WFK-2_1/examples/mail/mail-web/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/mail-web/pom.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/mail-web/pom.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -75,6 +75,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
+ <version>${version.war.plugin}</version>
<configuration>
<webResources>
<resource>
Modified: branches/enterprise/WFK-2_1/examples/mail/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/mail/pom.xml 2013-06-04 06:09:08 UTC (rev 15537)
+++ branches/enterprise/WFK-2_1/examples/mail/pom.xml 2013-06-04 06:41:09 UTC (rev 15538)
@@ -1,47 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.seam.examples</groupId>
<artifactId>mail</artifactId>
- <parent>
- <groupId>org.jboss.seam</groupId>
- <artifactId>examples</artifactId>
- <version>2.3.1.Final-redhat-2</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <packaging>pom</packaging>
- <name>Seam Mail Example (EE6)</name>
-
- <properties>
- <example.name>mail</example.name>
- </properties>
-
- <modules>
- <module>mail-ear</module>
- <module>mail-ejb</module>
- <module>mail-web</module>
- <module>mail-tests</module>
- </modules>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.jboss.seam.examples.mail</groupId>
- <artifactId>mail-ejb</artifactId>
- <version>${project.version}</version>
- <type>ejb</type>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam.examples.mail</groupId>
- <artifactId>mail-web</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam.examples.mail</groupId>
- <artifactId>mail-ear</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <version>2.3.1.Final-redhat-2</version>
+ <packaging>pom</packaging>
+ <name>Seam Mail Example (EE6)</name>
+
+ <properties>
+ <example.name>mail</example.name>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.target>1.6</maven.compiler.target>
+ <maven.compiler.source>1.6</maven.compiler.source>
+
+ <!-- To use jacoco, set jacoco.agent system property to something like
+ -javaagent:/path/to/jacocoagent.jar=append=true,destfile=/path/to/output/jacoco.exec -->
+ <jacoco.agent />
+
+ <!-- To use custom Maven settings and profiles, uncomment and customize
+ the following properties. This is necessary for the ShrinkWrap resolver to
+ function properly. -->
+ <!--<maven.user.settings>/path/to/custom/settings.xml</maven.user.settings> -->
+ <!--<maven.profiles>custom,profile</maven.profiles> -->
+
+ <version.commons.logging>1.1.1</version.commons.logging>
+ <version.shrinkwrap.resolver>2.0.0-beta-4</version.shrinkwrap.resolver>
+
+ <!-- Plugin versions -->
+ <version.dependency.plugin>2.5.1</version.dependency.plugin>
+ <version.surefire.plugin>2.10</version.surefire.plugin>
+ <version.compiler.plugin>2.3.1</version.compiler.plugin>
+ <version.ear.plugin>2.6</version.ear.plugin>
+ <version.war.plugin>2.1.1</version.war.plugin>
+ <version.jboss.maven.plugin>7.4.Final</version.jboss.maven.plugin>
+ </properties>
+
+ <modules>
+ <module>mail-ear</module>
+ <module>mail-ejb</module>
+ <module>mail-web</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.seam.examples.mail</groupId>
+ <artifactId>mail-ejb</artifactId>
+ <version>${project.version}</version>
+ <type>ejb</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.examples.mail</groupId>
+ <artifactId>mail-web</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.examples.mail</groupId>
+ <artifactId>mail-ear</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- BOMs -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-bom</artifactId>
+ <version>${version.shrinkwrap.resolver}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${version.commons.logging}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- Manage plugin versions for build stability -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${version.surefire.plugin}</version>
+ <configuration>
+ <systemPropertyVariables>
+ <org.apache.maven.user-settings>${maven.user.settings}</org.apache.maven.user-settings>
+ <maven.profiles>${maven.profiles}</maven.profiles>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>${version.dependency.plugin}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${version.compiler.plugin}</version>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
</project>
More information about the seam-commits
mailing list