camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] camel git commit: CAMEL-9714: camel-boon - Unmarshal to Map does not work
Date Wed, 16 Mar 2016 08:04:19 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 59fc35401 -> 14980a0a8
  refs/heads/master 68c6dabca -> fc0eb8c57


CAMEL-9714: camel-boon - Unmarshal to Map does not work


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

Branch: refs/heads/master
Commit: 7786a323930b7906473a3e7466338ec91c556103
Parents: 68c6dab
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Mar 16 08:53:00 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Mar 16 08:53:00 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/component/boon/BoonDataFormat.java  | 15 +++++++++++----
 .../camel/component/boon/BoonDataFormatTest.java     |  8 ++++----
 2 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7786a323/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
b/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
index 5e9f7cd..a867c32 100644
--- a/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
+++ b/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
-import java.util.HashMap;
 import java.util.List;
 
 import org.apache.camel.Exchange;
@@ -47,7 +46,7 @@ public class BoonDataFormat extends ServiceSupport implements DataFormat,
DataFo
     private boolean useList;
 
     public BoonDataFormat() {
-        this(HashMap.class);
+        this(null);
     }
 
     /**
@@ -86,8 +85,16 @@ public class BoonDataFormat extends ServiceSupport implements DataFormat,
DataFo
     @Override
     public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
         BufferedReader reader = IOHelper.buffered(new InputStreamReader(stream, IOHelper.getCharsetName(exchange)));
-        Object result = objectMapper.fromJson(reader, this.unmarshalType);
-        reader.close();
+        Object result;
+        try {
+            if (unmarshalType != null) {
+                result = objectMapper.fromJson(reader, unmarshalType);
+            } else {
+                result = objectMapper.fromJson(reader);
+            }
+        } finally {
+            IOHelper.close(reader);
+        }
         return result;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7786a323/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
b/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
index 8f4c6b5..1da380b 100644
--- a/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
+++ b/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
@@ -17,7 +17,6 @@
 package org.apache.camel.component.boon;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -93,14 +92,15 @@ public class BoonDataFormatTest extends CamelTestSupport {
         TestPojo in = new TestPojo();
         in.setName("Camel");
         
-        HashMap<String, TestPojo> map = new LinkedHashMap<String, TestPojo>();
+        Map<String, TestPojo> map = new LinkedHashMap<String, TestPojo>();
         map.put("test1", in);
         map.put("test2", in);
 
         MockEndpoint mock = getMockEndpoint("mock:reversePojosMap");
         mock.expectedMessageCount(1);
-        mock.message(0).body().isInstanceOf(HashMap.class);
-        mock.message(0).body().isEqualTo(map);
+        mock.message(0).body().isInstanceOf(Map.class);
+        mock.message(0).body().matches().simple("${body[test1].name} == 'Camel'");
+        mock.message(0).body().matches().simple("${body[test2].name} == 'Camel'");
 
         Object marshalled = template.requestBody("direct:inPojosMap", map);
         String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);


Mime
View raw message