You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/12/26 12:58:01 UTC
svn commit: r1425885 - in /camel/trunk/components/camel-mail/src:
main/java/org/apache/camel/component/mail/
test/java/org/apache/camel/component/mail/
Author: ningjiang
Date: Wed Dec 26 11:58:01 2012
New Revision: 1425885
URL: http://svn.apache.org/viewvc?rev=1425885&view=rev
Log:
CAMEL-5910 Mail Producer should store the mail message id when it sends the message.
Added:
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java
Modified:
camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java
camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java?rev=1425885&r1=1425884&r2=1425885&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java (original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConstants.java Wed Dec 26 11:58:01 2012
@@ -22,6 +22,8 @@ public final class MailConstants {
public static final String MAIL_ALTERNATIVE_BODY = "CamelMailAlternativeBody";
public static final String MAIL_DEFAULT_FOLDER = "INBOX";
public static final String MAIL_DEFAULT_FROM = "camel@localhost";
+ public static final String MAIL_MESSAGE_ID = "CamelMailMessageId";
+
public static final long MAIL_DEFAULT_CONNECTION_TIMEOUT = 30000L;
private MailConstants() {
Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java?rev=1425885&r1=1425884&r2=1425885&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java (original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java Wed Dec 26 11:58:01 2012
@@ -47,6 +47,8 @@ public class MailProducer extends Defaul
LOG.debug("Sending MimeMessage: {}", MailUtils.dumpMessage(mimeMessage));
}
sender.send(mimeMessage);
+ // set the message ID for further processing
+ exchange.getIn().setHeader(MailConstants.MAIL_MESSAGE_ID, mimeMessage.getMessageID());
} catch (MessagingException e) {
exchange.setException(e);
} catch (IOException e) {
Modified: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java?rev=1425885&r1=1425884&r2=1425885&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java (original)
+++ camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java Wed Dec 26 11:58:01 2012
@@ -54,6 +54,7 @@ public class MailProducerConcurrentTest
getMockEndpoint("mock:result").expectedMessageCount(files);
getMockEndpoint("mock:result").expectsNoDuplicates(body());
+
final CountDownLatch latch = new CountDownLatch(files);
ExecutorService executor = Executors.newFixedThreadPool(poolSize);
Added: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java?rev=1425885&view=auto
==============================================================================
--- camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java (added)
+++ camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java Wed Dec 26 11:58:01 2012
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mail;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.jvnet.mock_javamail.Mailbox;
+
+public class MailProducerTest extends CamelTestSupport {
+
+ @Test
+ public void testProduer() throws Exception {
+ Mailbox.clearAll();
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBodyAndHeader("direct:start", "Message ", "To", "someone@localhost");
+ assertMockEndpointsSatisfied();
+ // need to check the message header
+ Exchange exchange = getMockEndpoint("mock:result").getExchanges().get(0);
+ assertNotNull("The message id should not be null", exchange.getIn().getHeader(MailConstants.MAIL_MESSAGE_ID));
+
+ Mailbox box = Mailbox.get("someone@localhost");
+ assertEquals(1, box.size());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").to("smtp://camel@localhost", "mock:result");
+ }
+ };
+ }
+
+
+}