Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 64A80200BDC for ; Wed, 14 Dec 2016 21:24:55 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 63552160B19; Wed, 14 Dec 2016 20:24:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8518A160B0D for ; Wed, 14 Dec 2016 21:24:54 +0100 (CET) Received: (qmail 53725 invoked by uid 500); 14 Dec 2016 20:24:53 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 53705 invoked by uid 99); 14 Dec 2016 20:24:53 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Dec 2016 20:24:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id CA14118129C for ; Wed, 14 Dec 2016 20:24:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.311 X-Spam-Level: X-Spam-Status: No, score=-0.311 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_REPLYTO_END_DIGIT=0.25, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_SPAM=0.5, REPTO_QUOTE_YAHOO=0.49, RP_MATCHES_RCVD=-2.999, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id iX8ddr_F2N6n for ; Wed, 14 Dec 2016 20:24:49 +0000 (UTC) Received: from nm49-vm9.bullet.mail.ne1.yahoo.com (nm49-vm9.bullet.mail.ne1.yahoo.com [98.138.121.137]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id E40495F54F for ; Wed, 14 Dec 2016 20:24:48 +0000 (UTC) Received: from [127.0.0.1] by nm49.bullet.mail.ne1.yahoo.com with NNFMP; 14 Dec 2016 20:24:41 -0000 Received: from [98.138.100.111] by nm49.bullet.mail.ne1.yahoo.com with NNFMP; 14 Dec 2016 20:18:21 -0000 Received: from [66.196.81.173] by tm100.bullet.mail.ne1.yahoo.com with NNFMP; 14 Dec 2016 20:15:57 -0000 Received: from [98.139.212.217] by tm19.bullet.mail.bf1.yahoo.com with NNFMP; 14 Dec 2016 20:15:57 -0000 Received: from [127.0.0.1] by omp1026.mail.bf1.yahoo.com with NNFMP; 14 Dec 2016 20:15:57 -0000 X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 141945.62527.bm@omp1026.mail.bf1.yahoo.com X-YMail-OSG: GXlhzCUVRDsWUMBsPLoIEa.vdf4.X2DRBy2TLwtuSp_qbyK2 Received: from jws400091.mail.bf2.yahoo.com by sendmailws156.mail.bf1.yahoo.com; Wed, 14 Dec 2016 20:15:56 +0000; 1481746556.763 Date: Wed, 14 Dec 2016 20:15:55 +0000 (UTC) From: Andrea Cosentino Reply-To: "ancosen1985@yahoo.com" To: "dev@camel.apache.org" , "dkulp@apache.org" , "commits@camel.apache.org" Message-ID: <95453379.3196015.1481746555746@mail.yahoo.com> In-Reply-To: References: Subject: R: [1/3] camel git commit: CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3196014_1139510993.1481746555744" archived-at: Wed, 14 Dec 2016 20:24:55 -0000 ------=_Part_3196014_1139510993.1481746555744 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks Daniel. I forget to fix on 2.16.x Thanks for tour backport :-) can you upgrade the JIRA too? Thanks=20 =20 Il mer, 14 dic, 2016 alle 21:11, dkulp@apache.org ha sc= ritto: Repository: camel Updated Branches: =C2=A0 refs/heads/camel-2.16.x 2f204b742 -> b093ebdb9 CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType heade= r use Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/235036d2 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/235036d2 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/235036d2 Branch: refs/heads/camel-2.16.x Commit: 235036d2396ae45b6809b72a1983dee33b5ba326 Parents: 2f204b7 Author: Andrea Cosentino Authored: Wed Dec 7 18:18:45 2016 +0100 Committer: Daniel Kulp Committed: Wed Dec 14 14:35:03 2016 -0500 ---------------------------------------------------------------------- .../component/jackson/JacksonDataFormat.java=C2=A0 =C2=A0 | 19 ++++++- ...arshalUnmarshalTypeHeaderNotAllowedTest.java | 54 ++++++++++++++++++++ .../JacksonMarshalUnmarshalTypeHeaderTest.java=C2=A0 |=C2=A0 1 + 3 files changed, 73 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/235036d2/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/compon= ent/jackson/JacksonDataFormat.java b/components/camel-jackson/src/main/java= /org/apache/camel/component/jackson/JacksonDataFormat.java index 381b81a..553387c 100644 --- a/components/camel-jackson/src/main/java/org/apache/camel/component/jac= kson/JacksonDataFormat.java +++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jac= kson/JacksonDataFormat.java @@ -68,6 +68,7 @@ public class JacksonDataFormat extends ServiceSupport imp= lements DataFormat, Dat =C2=A0 =C2=A0 private String enableFeatures; =C2=A0 =C2=A0 private String disableFeatures; =C2=A0 =C2=A0 private boolean enableJacksonTypeConverter; +=C2=A0 =C2=A0 private boolean allowJacksonUnmarshallType; =20 =C2=A0 =C2=A0 /** =C2=A0 =C2=A0 =C2=A0 * Use the default Jackson {@link ObjectMapper} and {@l= ink Map} @@ -159,7 +160,10 @@ public class JacksonDataFormat extends ServiceSupport = implements DataFormat, Dat =20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // is there a header with the unmarshal type? =C2=A0 =C2=A0 =C2=A0 =C2=A0 Class clazz =3D unmarshalType; -=C2=A0 =C2=A0 =C2=A0 =C2=A0 String type =3D exchange.getIn().getHeader(Jac= ksonConstants.UNMARSHAL_TYPE, String.class); +=C2=A0 =C2=A0 =C2=A0 =C2=A0 String type =3D null; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (allowJacksonUnmarshallType) { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 type =3D exchange.getIn().getHea= der(JacksonConstants.UNMARSHAL_TYPE, String.class); +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (type =3D=3D null && isAllowJmsType()) { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 type =3D exchange.getIn().getHead= er("JMSType", String.class); =C2=A0 =C2=A0 =C2=A0 =C2=A0 } @@ -323,6 +327,19 @@ public class JacksonDataFormat extends ServiceSupport = implements DataFormat, Dat =C2=A0 =C2=A0 public void setEnableJacksonTypeConverter(boolean enableJacks= onTypeConverter) { =C2=A0 =C2=A0 =C2=A0 =C2=A0 this.enableJacksonTypeConverter =3D enableJacks= onTypeConverter; =C2=A0 =C2=A0 } +=C2=A0 =C2=A0=20 +=C2=A0 =C2=A0 public boolean isAllowJacksonUnmarshallType() { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return allowJacksonUnmarshallType; +=C2=A0 =C2=A0 } + +=C2=A0 =C2=A0 /** +=C2=A0 =C2=A0 * If enabled then Jackson is allowed to attempt to use the C= amelJacksonUnmarshalType header during the unmarshalling. +=C2=A0 =C2=A0 *

+=C2=A0 =C2=A0 * This should only be enabled when desired to be used. +=C2=A0 =C2=A0 */ +=C2=A0 =C2=A0 public void setAllowJacksonUnmarshallType(boolean allowJacks= onUnmarshallType) { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.allowJacksonUnmarshallType =3D allowJacks= onUnmarshallType; +=C2=A0 =C2=A0 } =20 =C2=A0 =C2=A0 public String getEnableFeatures() { =C2=A0 =C2=A0 =C2=A0 =C2=A0 return enableFeatures; http://git-wip-us.apache.org/repos/asf/camel/blob/235036d2/components/camel= -jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnm= arshalTypeHeaderNotAllowedTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jackson/src/test/java/org/apache/camel/compon= ent/jackson/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java b/componen= ts/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMa= rshalUnmarshalTypeHeaderNotAllowedTest.java new file mode 100644 index 0000000..ffabeeb --- /dev/null +++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jac= kson/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java @@ -0,0 +1,54 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements.=C2=A0 See the NOTICE file distributed w= ith + * 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.=C2=A0 You may obtain a copy of the License at + * + *=C2=A0 =C2=A0 =C2=A0 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.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends Camel= TestSupport { + +=C2=A0 =C2=A0 @Test +=C2=A0 =C2=A0 public void testUnmarshalPojo() throws Exception { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 MockEndpoint mock =3D getMockEndpoint("mock:re= versePojo"); +=C2=A0 =C2=A0 =C2=A0 =C2=A0 mock.expectedMessageCount(1); +=C2=A0 =C2=A0 =C2=A0 =C2=A0 mock.message(0).body().isInstanceOf(LinkedHash= Map.class); + +=C2=A0 =C2=A0 =C2=A0 =C2=A0 String json =3D "{\"name\":\"Camel\"}"; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 template.sendBodyAndHeader("direct:backPojo", = json, JacksonConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + +=C2=A0 =C2=A0 =C2=A0 =C2=A0 assertMockEndpointsSatisfied(); +=C2=A0 =C2=A0 } + +=C2=A0 =C2=A0 @Override +=C2=A0 =C2=A0 protected RouteBuilder createRouteBuilder() throws Exception= { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return new RouteBuilder() { + +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 @Override +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 public void configure() throws E= xception { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 JacksonDataFormat = format =3D new JacksonDataFormat(); + +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 from("direct:backP= ojo").unmarshal(format).to("mock:reversePojo"); + +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }; +=C2=A0 =C2=A0 } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/235036d2/components/camel= -jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnm= arshalTypeHeaderTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jackson/src/test/java/org/apache/camel/compon= ent/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java b/components/camel-j= ackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmar= shalTypeHeaderTest.java index 9cb5b59..623b32e 100644 --- a/components/camel-jackson/src/test/java/org/apache/camel/component/jac= kson/JacksonMarshalUnmarshalTypeHeaderTest.java +++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jac= kson/JacksonMarshalUnmarshalTypeHeaderTest.java @@ -46,6 +46,7 @@ public class JacksonMarshalUnmarshalTypeHeaderTest extend= s CamelTestSupport { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 @Override =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 public void configure() throws Ex= ception { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 JacksonDataFormat f= ormat =3D new JacksonDataFormat(); +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 format.setAllowJac= ksonUnmarshallType(true); =20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 from("direct:backPo= jo").unmarshal(format).to("mock:reversePojo"); =20 =20 ------=_Part_3196014_1139510993.1481746555744--