camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1170079 - in /camel/trunk/components/camel-csv/src: main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
Date Tue, 13 Sep 2011 08:21:19 GMT
Author: davsclaus
Date: Tue Sep 13 08:21:19 2011
New Revision: 1170079

URL: http://svn.apache.org/viewvc?rev=1170079&view=rev
Log:
CAMEL-4440: camel-csv now always return a List to be consistent regardless if 0, 1 or more
rows returned. Thanks to Ioannis for the patch.

Modified:
    camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
    camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java

Modified: camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java?rev=1170079&r1=1170078&r2=1170079&view=diff
==============================================================================
--- camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
(original)
+++ camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
Tue Sep 13 08:21:19 2011
@@ -105,11 +105,7 @@ public class CsvDataFormat implements Da
                 List<String> line = Arrays.asList(strings);
                 list.add(line);
             }
-            if (list.size() == 1) {
-                return list.get(0);
-            } else {
-                return list;
-            }
+            return list;
         } finally {
             in.close();
         }

Modified: camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java?rev=1170079&r1=1170078&r2=1170079&view=diff
==============================================================================
--- camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
(original)
+++ camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
Tue Sep 13 08:21:19 2011
@@ -37,7 +37,7 @@ public class CsvUnmarshalPipeDelimiterTe
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testCsvMarshal() throws Exception {
+    public void testCsvUnMarshal() throws Exception {
         result.expectedMessageCount(1);
 
         template.sendBody("direct:start", "123|Camel in Action|1\n124|ActiveMQ in Action|2");
@@ -53,6 +53,22 @@ public class CsvUnmarshalPipeDelimiterTe
         assertEquals("ActiveMQ in Action", body.get(1).get(1));
         assertEquals("2", body.get(1).get(2));        
     }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testCsvUnMarshalSingleLine() throws Exception {
+        result.expectedMessageCount(1);
+
+        template.sendBody("direct:start", "123|Camel in Action|1");
+
+        assertMockEndpointsSatisfied();
+
+        List<List<String>> body = result.getReceivedExchanges().get(0).getIn().getBody(List.class);
+        assertEquals(1, body.size());
+        assertEquals("123", body.get(0).get(0));
+        assertEquals("Camel in Action", body.get(0).get(1));
+        assertEquals("1", body.get(0).get(2));
+    }
     
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {



Mime
View raw message