Author: davsclaus
Date: Fri Oct 16 15:50:20 2009
New Revision: 825962
URL: http://svn.apache.org/viewvc?rev=825962&view=rev
Log:
CAMEL-2072: Fixed issue with extracting mails having multiple values in headers.
Added:
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
(with props)
Modified:
camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
Modified:
camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java?rev=825962&r1=825961&r2=825962&view=diff
==============================================================================
---
camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
(original)
+++
camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
Fri Oct 16 15:50:20 2009
@@ -433,14 +433,9 @@
while (names.hasMoreElements()) {
Header header = (Header)names.nextElement();
- String[] value = mailMessage.getHeader(header.getName());
- if (headerFilterStrategy != null
- &&
!headerFilterStrategy.applyFilterToExternalHeaders(header.getName(), value,
exchange)) {
- if (value.length == 1) {
- CollectionHelper.appendValue(answer, header.getName(),
value[0]);
- } else {
- CollectionHelper.appendValue(answer, header.getName(),
value);
- }
+ String value = header.getValue();
+ if (headerFilterStrategy != null &&
!headerFilterStrategy.applyFilterToExternalHeaders(header.getName(), value,
exchange)) {
+ CollectionHelper.appendValue(answer, header.getName(), value);
}
}
Added:
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java?rev=825962&view=auto
==============================================================================
---
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
(added)
+++
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
Fri Oct 16 15:50:20 2009
@@ -0,0 +1,63 @@
+/**
+ * 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 java.util.List;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.jvnet.mock_javamail.Mailbox;
+
+/**
+ * @version $Revision$
+ */
+public class MailCollectionHeaderTest extends CamelTestSupport {
+
+ @Test
+ public void testMailHeaderWithCollection() throws Exception {
+ Mailbox.clearAll();
+
+ String[] foo = new String[] {"Carlsberg", "Heineken"};
+ template.sendBodyAndHeader("direct:a", "Hello World", "beers", foo);
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived("Hello World");
+ mock.message(0).header("beers").isNotNull();
+
+ mock.assertIsSatisfied();
+
+ Object beers =
mock.getReceivedExchanges().get(0).getIn().getHeader("beers");
+ assertNotNull(beers);
+ List list = assertIsInstanceOf(List.class, beers);
+ assertEquals("Carlsberg", list.get(0));
+ assertEquals("Heineken", list.get(1));
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+
from("direct:a").to("smtp://localhost?username=ja...@localhost");
+
+
from("pop3://localhost?username=james&password=secret&consumer.delay=1000").to("mock:result");
+ }
+ };
+ }
+
+}
Propchange:
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date