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 2014/01/07 10:26:45 UTC

[2/3] git commit: CAMEL-7109: Message attachments should preserve order using linked map. Thanks to Ronald Dehuysser for patch.

CAMEL-7109: Message attachments should preserve order using linked map. Thanks to Ronald Dehuysser for patch.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ab71264d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ab71264d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ab71264d

Branch: refs/heads/camel-2.12.x
Commit: ab71264d5668c13484302e25d9b9ae6a53ed4834
Parents: 6cd00c0
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jan 7 10:29:45 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jan 7 10:30:08 2014 +0100

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultMessage.java   |  4 +-
 .../apache/camel/impl/DefaultMessageTest.java   | 39 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ab71264d/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
index da60279..ebc8c25 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.impl;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 import javax.activation.DataHandler;
@@ -205,7 +205,7 @@ public class DefaultMessage extends MessageSupport {
      * @return return a newly constructed Map
      */
     protected Map<String, DataHandler> createAttachments() {
-        Map<String, DataHandler> map = new HashMap<String, DataHandler>();
+        Map<String, DataHandler> map = new LinkedHashMap<String, DataHandler>();
         populateInitialAttachments(map);
         return map;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/ab71264d/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageTest.java
new file mode 100644
index 0000000..59b4cdc
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageTest.java
@@ -0,0 +1,39 @@
+/**
+ * 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.impl;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.activation.DataHandler;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class DefaultMessageTest {
+
+    @Test
+    public void testAttachmentsAreSorted() {
+        DefaultMessage message = new DefaultMessage();
+
+        Map<String, DataHandler> attachments = message.createAttachments();
+
+        assertThat(attachments, instanceOf(LinkedHashMap.class));
+    }
+
+}