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 2016/06/08 12:57:29 UTC
[1/2] camel git commit: Polished. This fixes #1018
Repository: camel
Updated Branches:
refs/heads/master 48e5785be -> 3846f1298
Polished. This fixes #1018
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3846f129
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3846f129
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3846f129
Branch: refs/heads/master
Commit: 3846f129869874b550e8c4b748ca1ee1bed8dd7e
Parents: bd14ebd
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jun 8 14:56:51 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jun 8 14:57:21 2016 +0200
----------------------------------------------------------------------
.../java/org/apache/camel/component/jackson/JacksonDataFormat.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3846f129/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
index ab142bb..154c387 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
@@ -70,7 +70,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
private boolean enableJacksonTypeConverter;
/**
- * Use the default Jackson {@link ObjectMapper} and {@link Map}
+ * Use the default Jackson {@link ObjectMapper} and {@link Object}
*/
public JacksonDataFormat() {
this(Object.class);
[2/2] camel git commit: CAMEL-10029 update default unmarshall type to
java.lang.Object instead of java.util.Map to be able to unmarshall any valid
Json document with the default configuration of Jackson unmarshaller
Posted by da...@apache.org.
CAMEL-10029 update default unmarshall type to java.lang.Object instead of java.util.Map to be able to unmarshall any valid Json document with the default configuration of Jackson unmarshaller
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bd14ebdc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bd14ebdc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bd14ebdc
Branch: refs/heads/master
Commit: bd14ebdc31b0768b8d54b52fa36cf1b58facba70
Parents: 48e5785
Author: apailhes <ad...@adioss.fr>
Authored: Tue Jun 7 18:59:01 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jun 8 14:57:21 2016 +0200
----------------------------------------------------------------------
.../component/jackson/JacksonDataFormat.java | 2 +-
.../jackson/JacksonDataFormatTest.java | 57 ++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/bd14ebdc/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
index 947eac6..ab142bb 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
@@ -73,7 +73,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
* Use the default Jackson {@link ObjectMapper} and {@link Map}
*/
public JacksonDataFormat() {
- this(HashMap.class);
+ this(Object.class);
}
/**
http://git-wip-us.apache.org/repos/asf/camel/blob/bd14ebdc/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonDataFormatTest.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonDataFormatTest.java
new file mode 100644
index 0000000..01dc521
--- /dev/null
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonDataFormatTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.jackson;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class JacksonDataFormatTest {
+ @Test
+ public void testString() throws Exception {
+ testJson("\"A string\"", "A string");
+ }
+
+ @Test
+ public void testMap() throws Exception {
+ testJson("{\"value\":123}", Collections.singletonMap("value", 123));
+ }
+
+ @Test
+ public void testList() throws Exception {
+ testJson("[{\"value\":123}]", new ArrayList<>(Collections.singletonList(Collections.singletonMap("value", 123))));
+
+ }
+
+ private void testJson(String json, Object expected) throws Exception {
+ Object unmarshalled;
+ JacksonDataFormat gsonDataFormat = new JacksonDataFormat();
+ gsonDataFormat.doStart();
+ try (InputStream in = new ByteArrayInputStream(json.getBytes())) {
+ unmarshalled = gsonDataFormat.unmarshal(new DefaultExchange(new DefaultCamelContext()), in);
+ }
+
+ assertEquals(expected, unmarshalled);
+ }
+}
\ No newline at end of file