Order matter so use linked hashmap instead of hashmap

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

Branch: refs/heads/master
Commit: 07e8071855d29ecf4ae44389e90e71229d1a6139
Parents: bbc905e
Author: Claus Ibsen <davscl...@apache.org>
Authored: Sat Dec 5 10:00:29 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Sat Dec 5 10:00:29 2015 +0100

----------------------------------------------------------------------
 .../camel/dataformat/csv/CsvMarshalTest.java     | 19 +++++++++----------
 .../camel/dataformat/csv/CsvRouteTest.java       | 12 ++++++------
 .../apache/camel/dataformat/csv/TestUtils.java   |  4 ++--
 3 files changed, 17 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/07e80718/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalTest.java
 
b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalTest.java
index 8f44d9b..3827d67 100644
--- 
a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalTest.java
+++ 
b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.dataformat.csv;
 
-
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -44,7 +43,7 @@ public class CsvMarshalTest extends CamelTestSupport {
         ));
         output.assertIsSatisfied();
 
-        String[] actuals = readOutputLines();
+        String[] actuals = readOutputLines(0);
         assertArrayEquals(new String[]{"1,2,3", "one,two,three"}, actuals);
     }
 
@@ -58,7 +57,7 @@ public class CsvMarshalTest extends CamelTestSupport {
         ));
         output.assertIsSatisfied();
 
-        String[] actuals = readOutputLines();
+        String[] actuals = readOutputLines(0);
         assertArrayEquals(new String[]{"1", "one"}, actuals);
     }
 
@@ -72,7 +71,7 @@ public class CsvMarshalTest extends CamelTestSupport {
         ));
         output.assertIsSatisfied();
 
-        assertArrayEquals(new String[]{"1,2,3", "one,two,three"}, 
readOutputLines());
+        assertArrayEquals(new String[]{"1,2,3", "one,two,three"}, 
readOutputLines(0));
     }
 
     @Test
@@ -82,7 +81,7 @@ public class CsvMarshalTest extends CamelTestSupport {
         template.sendBody("direct:default", TestUtils.asMap("A", "1", "B", 
"2", "C", "3"));
         output.assertIsSatisfied();
 
-        assertArrayEquals(new String[]{"1,2,3"}, readOutputLines());
+        assertArrayEquals(new String[]{"1,2,3"}, readOutputLines(0));
     }
 
     @Test
@@ -95,7 +94,7 @@ public class CsvMarshalTest extends CamelTestSupport {
         ));
         output.assertIsSatisfied();
 
-        assertArrayEquals(new String[]{"A,C", "1,3", "one,three"}, 
readOutputLines());
+        assertArrayEquals(new String[]{"A,C", "1,3", "one,three"}, 
readOutputLines(0));
     }
 
     @Test
@@ -106,8 +105,8 @@ public class CsvMarshalTest extends CamelTestSupport {
        template.sendBody("direct:default", TestUtils.asMap("X", "1", "Y", "2", 
"Z", "3"));
        
        output.assertIsSatisfied();
-       assertArrayEquals(new String[]{"1,2"}, readOutputLines());
-       assertArrayEquals(new String[]{"1,2,3"}, 
output.getExchanges().get(1).getIn().getBody(String.class).split("\r\n|\r|\n"));
+       assertArrayEquals(new String[]{"1,2"}, readOutputLines(0));
+       assertArrayEquals(new String[]{"1,2,3"}, readOutputLines(1));
     }
     
 
@@ -129,7 +128,7 @@ public class CsvMarshalTest extends CamelTestSupport {
         };
     }
 
-    private String[] readOutputLines() {
-        return 
output.getExchanges().get(0).getIn().getBody(String.class).split("\r\n|\r|\n");
+    private String[] readOutputLines(int index) {
+        return 
output.getExchanges().get(index).getIn().getBody(String.class).split("\r\n|\r|\n");
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/07e80718/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
 
b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
index 91b718a..bf9ccd0 100644
--- 
a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
+++ 
b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
@@ -32,7 +32,7 @@
  */
 package org.apache.camel.dataformat.csv;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
@@ -55,7 +55,7 @@ public class CsvRouteTest extends CamelTestSupport {
         resultEndpoint.expectedMessageCount(1);
 
         // START SNIPPET: marshalInput
-        Map<String, Object> body = new HashMap<String, Object>();
+        Map<String, Object> body = new LinkedHashMap<String, Object>();
         body.put("foo", "abc");
         body.put("bar", 123);
         // END SNIPPET: marshalInput
@@ -82,11 +82,11 @@ public class CsvRouteTest extends CamelTestSupport {
         MockEndpoint resultEndpoint = 
resolveMandatoryEndpoint("mock:resultMulti",
                 MockEndpoint.class);
         resultEndpoint.expectedMessageCount(2);
-        Map<String, Object> body1 = new HashMap<String, Object>();
+        Map<String, Object> body1 = new LinkedHashMap<String, Object>();
         body1.put("foo", "abc");
         body1.put("bar", 123);
 
-        Map<String, Object> body2 = new HashMap<String, Object>();
+        Map<String, Object> body2 = new LinkedHashMap<String, Object>();
         body2.put("foo", "def");
         body2.put("bar", 456);
         body2.put("baz", 789);
@@ -123,11 +123,11 @@ public class CsvRouteTest extends CamelTestSupport {
         MockEndpoint resultEndpoint = 
resolveMandatoryEndpoint("mock:resultMultiCustom",
                 MockEndpoint.class);
         resultEndpoint.expectedMessageCount(2);
-        Map<String, Object> body1 = new HashMap<String, Object>();
+        Map<String, Object> body1 = new LinkedHashMap<String, Object>();
         body1.put("foo", "abc");
         body1.put("bar", 123);
 
-        Map<String, Object> body2 = new HashMap<String, Object>();
+        Map<String, Object> body2 = new LinkedHashMap<String, Object>();
         body2.put("foo", "def");
         body2.put("bar", 456);
         body2.put("baz", 789);

http://git-wip-us.apache.org/repos/asf/camel/blob/07e80718/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/TestUtils.java
----------------------------------------------------------------------
diff --git 
a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/TestUtils.java
 
b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/TestUtils.java
index 38e74a7..6d4b0b7 100644
--- 
a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/TestUtils.java
+++ 
b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/TestUtils.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.dataformat.csv;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
@@ -39,7 +39,7 @@ final class TestUtils {
             throw new IllegalArgumentException("Cannot create a map with an 
add number of strings");
         }
 
-        Map<String, String> map = new HashMap<String, String>(strings.length / 
2);
+        Map<String, String> map = new LinkedHashMap<>(strings.length / 2);
         for (int i = 0; i < strings.length; i += 2) {
             map.put(strings[i], strings[i + 1]);
         }

Reply via email to