diff --git a/core/api/pom.xml b/core/api/pom.xml index adacff5..a61edc2 100644 --- a/core/api/pom.xml +++ b/core/api/pom.xml @@ -4,13 +4,13 @@ seam-mail-parent org.jboss.seam.mail - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../../pom.xml org.jboss.seam.mail seam-mail-core-api - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT jar Seam Mail Module Core API diff --git a/core/impl/pom.xml b/core/impl/pom.xml index 155ff8d..c852a96 100644 --- a/core/impl/pom.xml +++ b/core/impl/pom.xml @@ -5,7 +5,7 @@ seam-mail-parent org.jboss.seam.mail - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../../pom.xml @@ -48,7 +48,7 @@ - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT diff --git a/dist/pom.xml b/dist/pom.xml index cc192a8..ea19c6d 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -1,19 +1,18 @@ - + 4.0.0 org.jboss.seam.mail seam-mail-parent - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../pom.xml org.jboss.seam.mail seam-mail-distribution Seam Mail Module Distribution - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT Builds a Seam Mail module release distribution pom diff --git a/docs/pom.xml b/docs/pom.xml index 9d06eb7..dda5cc3 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -1,17 +1,16 @@ - + 4.0.0 org.jboss.seam.mail seam-mail-parent - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../pom.xml org.jboss.seam.mail seam-mail-reference-guide - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT jdocbook Seam Mail Module Reference Guide diff --git a/examples/sendmail/pom.xml b/examples/sendmail/pom.xml index 516a224..c6c84d7 100644 --- a/examples/sendmail/pom.xml +++ b/examples/sendmail/pom.xml @@ -5,13 +5,13 @@ org.jboss.seam.mail seam-mail-parent - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../../pom.xml org.jboss.seam.mail seam-mail-example-sendmail - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT war Seam Mail Module Example: Sendmail @@ -54,7 +54,6 @@ org.jboss.seam.mail seam-mail-render-impl - 3.0.0-SNAPSHOT compile @@ -137,6 +136,17 @@ test + + org.testng + testng + ${ftest.testng.version} + test + + + org.jboss.test + richfaces-selenium + test + @@ -187,7 +197,7 @@ org.codehaus.mojo jboss-maven-plugin - 1.4.1-SNAPSHOT + 1.4.1 ${jboss.home} ${jboss.domain} diff --git a/examples/sendmail/src/test/java/org/jboss/seam/mail/examples/sendmail/ftest/SeleniumMailTest.java b/examples/sendmail/src/test/java/org/jboss/seam/mail/examples/sendmail/ftest/SeleniumMailTest.java new file mode 100644 index 0000000..9e2a955 --- /dev/null +++ b/examples/sendmail/src/test/java/org/jboss/seam/mail/examples/sendmail/ftest/SeleniumMailTest.java @@ -0,0 +1,143 @@ +package org.jboss.seam.mail.examples.sendmail.ftest; + + +import java.net.MalformedURLException; +import java.net.URL; + +import org.jboss.test.selenium.AbstractTestCase; +import org.jboss.test.selenium.locator.XpathLocator; +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.jboss.test.selenium.locator.LocatorFactory.xp; +import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.assertFalse; + +/** + * A functional test for send mail example + * @author Tomas Remes + * + */ +public class SeleniumMailTest extends AbstractTestCase +{ + + public static final String HOME_PAGE_TITLE = "Seam 3 Sendmail Example"; + public static final String ENVELOPE_SENDER = "seam@test.test"; + + public static final XpathLocator NAME = xp("//input[contains(@name,':name')]"); + public static final XpathLocator ADDRESS = xp("//input[contains(@name,':email')]"); + public static final String ADDRESS_VALUE= "john.smith@localhost"; + public static final String NAME_VALUE= "John Smith"; + + public static final XpathLocator SEND_TEXT_EMAIL = xp("//input[contains(@value,'Send Text Email')]"); + public static final XpathLocator SEND_HTML_EMAIL_WITH_FREEMARKER = xp("//input[contains(@value,'Send HTML Email with FreeMarker')]"); + public static final XpathLocator SEND_HTML_EMAIL_WITH_VELOCITY = xp("//input[contains(@value,'Send HTML Email with Velocity')]"); + public static final XpathLocator SEND_HTML_EMAIL_WITH_SEAM = xp("//input[contains(@value,'Send HTML Email with Seam Render')]"); + public static final XpathLocator SEND_HTML_TEXT_EMAIL_WITH_FREEMARKER = xp("//input[contains(@value,'Send HTML+Text Email with FreeMarker')]"); + public static final XpathLocator SEND_HTML_TEXT_EMAIL_WITH_VELOCITY = xp("//input[contains(@value,'Send HTML+Text Email with Velocity')]"); + public static final XpathLocator SEND_HTML_TEXT_EMAIL_WITH_SEAM = xp("//input[contains(@value,'Send HTML+Text Email with Seam Render')]"); + + protected Wiser wiser; + + + @BeforeMethod + public void setUp() throws MalformedURLException + { + selenium.setSpeed(300); + selenium.open(new URL(contextPath.toString())); + } + + /** + * 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(8977); + 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, selenium.getTitle()); + } + + @DataProvider(name = "sendMethods") + public Object[][] mailTest() { + + return new Object[][] { + {SEND_TEXT_EMAIL, new String[] {"Content-Type: text/plain","Simple Message with text body"}}, + {SEND_HTML_EMAIL_WITH_FREEMARKER, new String[] {"Content-Type: text/html","Content-Type: multipart/mixed","Content-Type: image/png; name=seamLogo.png","Content-Disposition: inline","

Dear "+NAME_VALUE+",

","

This is an example HTML email sent by Seam 3 and FreeMarker.

","Importance: high"}}, + {SEND_HTML_EMAIL_WITH_VELOCITY, new String[]{"Content-Type: text/html","Content-Type: multipart/mixed","Content-Type: image/png; name=seamLogo.png","Content-Disposition: inline","

Dear "+NAME_VALUE+",

","

This is an example HTML email sent by Seam 3 and Velocity.

","Importance: high"}}, + {SEND_HTML_EMAIL_WITH_SEAM, new String[] {"Content-Type: text/html","Content-Type: multipart/mixed","Content-Type: image/png; name=seamLogo.png","Content-Disposition: inline","

Dear "+NAME_VALUE+",

","

This is an example HTML email sent by Seam 3 and Seam Render.

","Importance: high"}}, + {SEND_HTML_TEXT_EMAIL_WITH_FREEMARKER, new String[] {"Content-Type: text/plain","Content-Type: multipart/alternative","Content-Type: multipart/mixed","Content-Type: image/png; name=seamLogo.png","Content-Disposition: inline","Hello "+NAME_VALUE,"This is the alternative text body for mail readers that don't support html. This was sent with Seam 3 and FreeMarker.","Importance: low"}}, + {SEND_HTML_TEXT_EMAIL_WITH_VELOCITY, new String[] {"Content-Type: text/plain","Content-Type: multipart/alternative","Content-Type: multipart/mixed","Content-Type: image/png; name=seamLogo.png","Content-Disposition: inline","Hello "+NAME_VALUE,"This is the alternative text body for mail readers that don't support html. This was sent with Seam 3 and Velocity.","Importance: low"}}, + {SEND_HTML_TEXT_EMAIL_WITH_SEAM, new String[] {"Content-Type: text/plain","Content-Type: multipart/alternative","Content-Type: multipart/mixed","Content-Type: image/png; name=seamLogo.png","Content-Disposition: inline","Hello "+NAME_VALUE,"This is the alternative text body for mail readers that don't support html. This was sent with Seam 3 and Seam Render.","Importance: low"}}, + + }; + } + + /** + * Sends a mail and verifies it was delivered + */ + @Test(dataProvider = "sendMethods") + public void mailTest(XpathLocator buttonToClick, String[] expectedMessageContents) { + + fillInInputs(); + sendEmail(buttonToClick); + checkDelivered(expectedMessageContents); + } + + /** + * Fills in html text inputs. + */ + private void fillInInputs() + { + selenium.type(NAME, NAME_VALUE); + selenium.type(ADDRESS, ADDRESS_VALUE); + + } + + /** + * Sends an email by clicking on specified button. + * @param buttonToClick + */ + private void sendEmail(XpathLocator buttonToClick) + { + waitHttp(selenium).click(buttonToClick); + } + /** + * 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_VALUE, 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)); + } + } + +} diff --git a/examples/sendmail/src/test/resources/ftests.xml b/examples/sendmail/src/test/resources/ftests.xml new file mode 100644 index 0000000..918da73 --- /dev/null +++ b/examples/sendmail/src/test/resources/ftests.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/freemarker/impl/pom.xml b/freemarker/impl/pom.xml index 7c871db..9fdd9c4 100644 --- a/freemarker/impl/pom.xml +++ b/freemarker/impl/pom.xml @@ -5,7 +5,7 @@ seam-mail-parent org.jboss.seam.mail - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../../pom.xml @@ -51,7 +51,7 @@ - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT diff --git a/pom.xml b/pom.xml index 3228f50..e2af038 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.jboss.seam.mail seam-mail-parent pom - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT Seam Mail Module diff --git a/seam-render/impl/pom.xml b/seam-render/impl/pom.xml index f48f291..6a3f14c 100644 --- a/seam-render/impl/pom.xml +++ b/seam-render/impl/pom.xml @@ -5,7 +5,7 @@ seam-mail-parent org.jboss.seam.mail - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../../pom.xml @@ -51,7 +51,7 @@ - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT diff --git a/velocity/impl/pom.xml b/velocity/impl/pom.xml index fe7eea4..c7b4579 100644 --- a/velocity/impl/pom.xml +++ b/velocity/impl/pom.xml @@ -5,7 +5,7 @@ seam-mail-parent org.jboss.seam.mail - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT ../../pom.xml @@ -55,7 +55,7 @@ - 3.0.0-SNAPSHOT + 3.0.0.Beta1-SNAPSHOT