camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r683103 - /activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
Date Wed, 06 Aug 2008 04:25:02 GMT
Author: davsclaus
Date: Tue Aug  5 21:25:01 2008
New Revision: 683103

URL: http://svn.apache.org/viewvc?rev=683103&view=rev
Log:
CAMEL-777: Added wiki example for camel-mail

Added:
    activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
  (contents, props changed)
      - copied, changed from r682583, activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java

Copied: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
(from r682583, activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java?p2=activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java&p1=activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java&r1=682583&r2=683103&rev=683103&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
Tue Aug  5 21:25:01 2008
@@ -16,39 +16,44 @@
  */
 package org.apache.camel.component.mail;
 
+import java.util.Map;
+import java.util.HashMap;
+import javax.mail.Message;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 import org.jvnet.mock_javamail.Mailbox;
 
 /**
- * Unit test for Mail subject support.
+ * Unit test for Mail using camel headers to set recipeient subject.
  */
-public class MailSubjectTest extends ContextTestSupport {
-    private String subject = "Camel rocks";
+public class MailUsingHeadersTest extends ContextTestSupport {
 
-    public void testMailSubject() throws Exception {
+    public void testMailUsingHeaders() throws Exception {
         Mailbox.clearAll();
 
+        // START SNIPPET: e1
+        Map map = new HashMap();
+        map.put("To", "davsclaus@apache.org");
+        map.put("From", "jstrachan@apache.org");
+        map.put("Subject", "Camel rocks");
+
         String body = "Hello Claus.\nYes it does.\n\nRegards James.";
-        template.sendBody("direct:a", body);
+        template.sendBodyAndHeaders("smtp://james@localhost", body, map);
+        // END SNIPPET: e1
 
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(1);
-        mock.expectedHeaderReceived("subject", subject);
-        mock.expectedBodiesReceived(body);
-        mock.assertIsSatisfied();
+        Mailbox box = Mailbox.get("davsclaus@apache.org");
+        Message msg = box.get(0);
+        assertEquals("davsclaus@apache.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
+        assertEquals("jstrachan@apache.org", msg.getFrom()[0].toString());
+        assertEquals("Camel rocks", msg.getSubject());
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                // START SNIPPET: e1
-                from("direct:a").setHeader("subject", constant(subject)).to("smtp://james2@localhost");
-                // END SNIPPET: e1
-
-                from("pop3://localhost?username=james2&password=secret&consumer.delay=1000").to("mock:result");
+                // no routes
             }
         };
     }
-}
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message