You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2008/04/27 15:22:07 UTC

svn commit: r651941 - /activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java

Author: davsclaus
Date: Sun Apr 27 06:22:05 2008
New Revision: 651941

URL: http://svn.apache.org/viewvc?rev=651941&view=rev
Log:
CAMEL-335
- improved unit test with more assertions instead of logging

Modified:
    activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java

Modified: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java?rev=651941&r1=651940&r2=651941&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java (original)
+++ activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java Sun Apr 27 06:22:05 2008
@@ -18,7 +18,6 @@
 
 import java.io.File;
 import java.net.URISyntaxException;
-import java.util.Iterator;
 import java.util.Properties;
 
 import javax.activation.DataHandler;
@@ -70,10 +69,11 @@
         assertEquals("mail body", body, text);
 
         assertNotNull("attachments got lost", exchange.getIn().getAttachments());
-        Iterator<String> keyIt = exchange.getIn().getAttachmentNames().iterator();
-        while (keyIt.hasNext()) {
-            DataHandler dh = exchange.getIn().getAttachment(keyIt.next());
-            log.info("Found attachment: " + dh.getName());
+        for (String s : exchange.getIn().getAttachmentNames()) {
+            DataHandler dh = exchange.getIn().getAttachment(s);
+            assertEquals("log4j.properties", dh.getName());
+            Object content = dh.getContent();
+            assertNotNull("Content should not be empty", content);
         }
     }
 
@@ -99,7 +99,7 @@
         mixed.addBodyPart(plainPart);
         mixed.addBodyPart(htmlPart);
 
-        DataSource ds = null;
+        DataSource ds;
         try {
             File f = new File(getClass().getResource("/log4j.properties").toURI());
             ds = new FileDataSource(f);
@@ -108,7 +108,7 @@
         }
         DataHandler dh = new DataHandler(ds);
 
-        BodyPart attachmentBodyPart = null;
+        BodyPart attachmentBodyPart;
         // Create another body part
         attachmentBodyPart = new MimeBodyPart();
         // Set the data handler to the attachment