camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r683109 - in /activemq/camel/trunk/components/camel-mail/src: main/java/org/apache/camel/component/mail/ test/java/org/apache/camel/component/mail/
Date Wed, 06 Aug 2008 05:06:03 GMT
Author: davsclaus
Date: Tue Aug  5 22:06:03 2008
New Revision: 683109

URL: http://svn.apache.org/viewvc?rev=683109&view=rev
Log:
CAMEL-777: Allow @ in username option

Added:
    activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java
      - copied, changed from r683103, activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
Modified:
    activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
    activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java

Modified: activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java?rev=683109&r1=683108&r2=683109&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
Tue Aug  5 22:06:03 2008
@@ -79,11 +79,6 @@
         String userInfo = uri.getUserInfo();
         if (userInfo != null) {
             setUsername(userInfo);
-
-            // set default destination to userInfo@host for backwards compatibility
-            // can be overridden by URI parameters
-            String address = userInfo + "@" + host;
-            recipients.put(Message.RecipientType.TO, address);
         }
 
         int port = uri.getPort();
@@ -265,7 +260,10 @@
         if (!recipients.containsKey(Message.RecipientType.TO)) {
             // set default destination to username@host for backwards compatibility
             // can be overridden by URI parameters
-            String address = username + "@" + host;
+            String address = username;
+            if (address.indexOf("@") == -1) {
+                address += "@" + host;
+            }
             recipients.put(Message.RecipientType.TO, address);
         }
     }

Copied: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java
(from r683103, activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java?p2=activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java&p1=activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java&r1=683103&r2=683109&rev=683109&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java
Tue Aug  5 22:06:03 2008
@@ -16,43 +16,34 @@
  */
 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 using camel headers to set recipeient subject.
+ * Unit test for Mail using @ in username option
  */
-public class MailUsingHeadersTest extends ContextTestSupport {
+public class MailUsernameWithAtSignTest extends ContextTestSupport {
 
-    public void testMailUsingHeaders() throws Exception {
+    public void testMailUsingAtSignInUsername() 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.sendBodyAndHeaders("smtp://james@localhost", body, map);
-        // END SNIPPET: e1
+        template.sendBody("direct:a", body);
 
-        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());
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived(body);
+        mock.assertIsSatisfied();
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                // no routes
+                from("direct:a").to("smtp://localhost?username=james@localhost");
+
+                from("pop3://localhost?username=james&password=secret&consumer.delay=1000").to("mock:result");
             }
         };
     }

Modified: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java?rev=683109&r1=683108&r2=683109&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
Tue Aug  5 22:06:03 2008
@@ -39,7 +39,7 @@
         map.put("Subject", "Camel rocks");
 
         String body = "Hello Claus.\nYes it does.\n\nRegards James.";
-        template.sendBodyAndHeaders("smtp://james@localhost", body, map);
+        template.sendBodyAndHeaders("smtp://davsclaus@apache.org", body, map);
         // END SNIPPET: e1
 
         Mailbox box = Mailbox.get("davsclaus@apache.org");



Mime
View raw message