Skip to content

Commit

Permalink
Merge branch 'release/3.0.0.Alpha1'
Browse files Browse the repository at this point in the history
  • Loading branch information
LightGuard committed Jul 26, 2011
2 parents f2119af + 772e2eb commit 5564afc
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 23 deletions.
4 changes: 2 additions & 2 deletions core/api/pom.xml
Expand Up @@ -4,13 +4,13 @@
<parent>
<artifactId>seam-mail-parent</artifactId>
<groupId>org.jboss.seam.mail</groupId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-core-api</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Seam Mail Module Core API</name>

Expand Down
4 changes: 2 additions & 2 deletions core/impl/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>seam-mail-parent</artifactId>
<groupId>org.jboss.seam.mail</groupId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -48,7 +48,7 @@

</dependencies>

<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
7 changes: 3 additions & 4 deletions dist/pom.xml
@@ -1,19 +1,18 @@
<?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>

<parent>
<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-distribution</artifactId>
<name>Seam Mail Module Distribution</name>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<description>Builds a Seam Mail module release distribution</description>
<packaging>pom</packaging>

Expand Down
7 changes: 3 additions & 4 deletions docs/pom.xml
@@ -1,17 +1,16 @@
<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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-reference-guide</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>Seam Mail Module Reference Guide</name>

Expand Down
18 changes: 14 additions & 4 deletions examples/sendmail/pom.xml
Expand Up @@ -5,13 +5,13 @@
<parent>
<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-example-sendmail</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<packaging>war</packaging>

<name>Seam Mail Module Example: Sendmail</name>
Expand Down Expand Up @@ -54,7 +54,6 @@
<dependency>
<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-render-impl</artifactId>
<version>3.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

Expand Down Expand Up @@ -137,6 +136,17 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${ftest.testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.test</groupId>
<artifactId>richfaces-selenium</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -187,7 +197,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.1</version>
<configuration>
<jbossHome>${jboss.home}</jbossHome>
<serverName>${jboss.domain}</serverName>
Expand Down
@@ -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 <a href="mailto:tremes@redhat.com"> Tomas Remes </a>
*
*/
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","<p><b>Dear <a href=\"mailto:"+ ADDRESS_VALUE+"\">"+NAME_VALUE+"</a>,</b></p>","<p>This is an example <i>HTML</i> email sent by Seam 3 and FreeMarker.</p>","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","<p><b>Dear <a href=\"mailto:"+ ADDRESS_VALUE+"\">"+NAME_VALUE+"</a>,</b></p>","<p>This is an example <i>HTML</i> email sent by Seam 3 and Velocity.</p>","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","<p><b>Dear <a href=\"mailto:"+ ADDRESS_VALUE+"\">"+NAME_VALUE+"</a>,</b></p>","<p>This is an example <i>HTML</i> email sent by Seam 3 and Seam Render.</p>","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));
}
}

}
9 changes: 9 additions & 0 deletions examples/sendmail/src/test/resources/ftests.xml
@@ -0,0 +1,9 @@
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="Seam Mail Example" verbose="2" parallel="false">
<test name="sendmail_ftest">
<parameter name="example.context.path" value="/sendmail"/>
<packages>
<package name="org.jboss.seam.mail.examples.sendmail.ftest"/>
</packages>
</test>
</suite>
4 changes: 2 additions & 2 deletions freemarker/impl/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>seam-mail-parent</artifactId>
<groupId>org.jboss.seam.mail</groupId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -51,7 +51,7 @@

</dependencies>

<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -10,7 +10,7 @@
<groupId>org.jboss.seam.mail</groupId>
<artifactId>seam-mail-parent</artifactId>
<packaging>pom</packaging>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<name>Seam Mail Module</name>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions seam-render/impl/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>seam-mail-parent</artifactId>
<groupId>org.jboss.seam.mail</groupId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -51,7 +51,7 @@

</dependencies>

<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions velocity/impl/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>seam-mail-parent</artifactId>
<groupId>org.jboss.seam.mail</groupId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -55,7 +55,7 @@

</dependencies>

<version>3.0.0-SNAPSHOT</version>
<version>3.0.0.Beta1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down

0 comments on commit 5564afc

Please sign in to comment.