continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r741682 - /continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
Date Fri, 06 Feb 2009 19:15:08 GMT
Author: evenisse
Date: Fri Feb  6 19:15:08 2009
New Revision: 741682

URL: http://svn.apache.org/viewvc?rev=741682&view=rev
Log:
Add more test

Modified:
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java?rev=741682&r1=741681&r2=741682&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
Fri Feb  6 19:15:08 2009
@@ -19,18 +19,9 @@
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.Address;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMessage.RecipientType;
-
 import org.apache.continuum.notification.mail.MockJavaMailSender;
 import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -43,6 +34,15 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.mail.javamail.JavaMailSender;
 
+import javax.mail.Address;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMessage.RecipientType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -50,9 +50,9 @@
 public class MailContinuumNotifierTest
     extends AbstractContinuumTest
 {
-    
+
     protected Logger logger = LoggerFactory.getLogger( getClass() );
-    
+
     public void testSuccessfulBuild()
         throws Exception
     {
@@ -66,11 +66,21 @@
 
         BuildResult build = makeBuild( ContinuumProjectState.OK );
 
+        BuildDefinition buildDef = new BuildDefinition();
+        buildDef.setType( "maven2" );
+        buildDef.setBuildFile( "pom.xml" );
+        buildDef.setGoals( "clean install" );
+        buildDef.setArguments( "" );
+        build.setBuildDefinition( buildDef );
+
         MimeMessage mailMessage = sendNotificationAndGetMessage( project, build, "lots out
build output", toOverride );
 
         assertEquals( "[continuum] BUILD SUCCESSFUL: foo.bar Test Project", mailMessage.getSubject()
);
 
-        dumpContent( mailMessage, "recipient@host.com" );
+        String mailContent = dumpContent( mailMessage, "recipient@host.com" );
+
+        //CONTINUUM-1946
+        assertTrue( mailContent.indexOf( "Goals: clean install" ) > 0 );
     }
 
     public void testFailedBuild()
@@ -107,40 +117,42 @@
         dumpContent( mailMessage );
     }
 
-    private void dumpContent( MimeMessage mailMessage )
+    private String dumpContent( MimeMessage mailMessage )
         throws Exception
     {
-        dumpContent( mailMessage, null );
+        return dumpContent( mailMessage, null );
     }
 
-    private void dumpContent( MimeMessage mailMessage, String toOverride )
+    private String dumpContent( MimeMessage mailMessage, String toOverride )
         throws Exception
     {
-        Address[] tos  = mailMessage.getRecipients( RecipientType.TO );
+        Address[] tos = mailMessage.getRecipients( RecipientType.TO );
         if ( toOverride != null )
         {
-            assertEquals( toOverride, ( (InternetAddress) tos[ 0 ] ).getAddress() );
+            assertEquals( toOverride, ( (InternetAddress) tos[0] ).getAddress() );
         }
         else
         {
-            assertEquals( "foo@bar", ( (InternetAddress) tos[ 0 ] ).getAddress() );
+            assertEquals( "foo@bar", ( (InternetAddress) tos[0] ).getAddress() );
         }
         assertTrue( "The template isn't loaded correctly.",
-                    ((String)mailMessage.getContent()).indexOf( "#shellBuildResult()" ) <
0 );
+                    ( (String) mailMessage.getContent() ).indexOf( "#shellBuildResult()"
) < 0 );
         assertTrue( "The template isn't loaded correctly.",
-                    ((String)mailMessage.getContent()).indexOf( "Build statistics" ) >
0 );
+                    ( (String) mailMessage.getContent() ).indexOf( "Build statistics" ) >
0 );
 
-        if ( true )
-        {
-            logger.info( ((String)mailMessage.getContent()) );
-        }
+        String mailContent = (String) mailMessage.getContent();
+
+        logger.info( mailContent );
+
+        return mailContent;
     }
 
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
-    private MimeMessage sendNotificationAndGetMessage( Project project, BuildResult build,
String buildOutput, String toOverride )
+    private MimeMessage sendNotificationAndGetMessage( Project project, BuildResult build,
String buildOutput,
+                                                       String toOverride )
         throws Exception
     {
         MessageContext context = new MessageContext();
@@ -188,15 +200,15 @@
         //
         // ----------------------------------------------------------------------
 
-        assertEquals( "continuum@localhost", ((InternetAddress) mailMessage.getFrom()[0]).getAddress()
);
+        assertEquals( "continuum@localhost", ( (InternetAddress) mailMessage.getFrom()[0]
).getAddress() );
 
-        assertEquals( "Continuum", ((InternetAddress) mailMessage.getFrom()[0]).getPersonal()
);
+        assertEquals( "Continuum", ( (InternetAddress) mailMessage.getFrom()[0] ).getPersonal()
);
 
-        Address[] tos  = mailMessage.getRecipients( RecipientType.TO );
+        Address[] tos = mailMessage.getRecipients( RecipientType.TO );
 
         assertEquals( 1, tos.length );
 
-        assertEquals(toOverride == null ? "foo@bar" : toOverride, ( (InternetAddress) tos[0]
).getAddress() );
+        assertEquals( toOverride == null ? "foo@bar" : toOverride, ( (InternetAddress) tos[0]
).getAddress() );
 
         return mailMessage;
     }



Mime
View raw message