You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ws...@apache.org on 2008/10/28 15:42:16 UTC
svn commit: r708589 -
/continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
Author: wsmoak
Date: Tue Oct 28 07:42:16 2008
New Revision: 708589
URL: http://svn.apache.org/viewvc?rev=708589&view=rev
Log:
[CONTINUUM-1944] Add a test to check that when there are multiple notifiers in the pom, there are multiple recipients on the email. Thanks to Olivier for fixing the assertions.
Modified:
continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
Modified: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java?rev=708589&r1=708588&r2=708589&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java (original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java Tue Oct 28 07:42:16 2008
@@ -28,6 +28,7 @@
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
+import javax.mail.Message;
import org.apache.continuum.notification.mail.MockJavaMailSender;
import org.apache.maven.continuum.AbstractContinuumTest;
@@ -103,6 +104,56 @@
dumpContent( mailMessage );
}
+ /**
+ * When there are multiple notifiers in the pom, there should be multiple recipients on the email.
+ * @throws Exception
+ */
+ public void testMultipleNotifiers()
+ throws Exception
+ {
+ Project project = makeStubProject( "Test Project" );
+ project.setGroupId( "com.example" );
+
+ BuildResult build = makeBuild( ContinuumProjectState.ERROR );
+
+ MessageContext context = new MessageContext();
+ context.setProject( project );
+ context.setBuildResult( build );
+
+ List<ProjectNotifier> projectNotifiers = new ArrayList<ProjectNotifier>();
+
+ ProjectNotifier pn1 = new ProjectNotifier();
+ pn1.setType( "mail" );
+ Map<String, String> config1 = new HashMap<String, String>();
+ config1.put( MailContinuumNotifier.ADDRESS_FIELD, "foo@example.com" );
+ pn1.setConfiguration( config1 );
+ projectNotifiers.add( pn1 );
+
+ ProjectNotifier pn2 = new ProjectNotifier();
+ pn2.setType( "mail" );
+ Map<String, String> config2 = new HashMap<String, String>();
+ config2.put( MailContinuumNotifier.ADDRESS_FIELD, "bar@example.com" );
+ pn2.setConfiguration( config2 );
+ projectNotifiers.add( pn2 );
+
+ context.setNotifier( projectNotifiers );
+
+ Notifier notifier = (Notifier) lookup( Notifier.class.getName(), "mail" );
+
+ ( (MailContinuumNotifier) notifier ).setBuildHost( "foo.bar.com" );
+
+ notifier.sendMessage( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE, context );
+
+ MockJavaMailSender mailSender = (MockJavaMailSender) lookup( JavaMailSender.class, "continuum" );
+
+ // one email
+ assertEquals( 1, mailSender.getReceivedEmails().size() );
+
+ // two recipients
+ assertEquals( 2, mailSender.getReceivedEmails().get( 0 ).getRecipients( Message.RecipientType.TO ).length );
+
+ }
+
private void dumpContent( MimeMessage mailMessage )
throws Exception
{