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 EB5A4200BEB for ; Tue, 13 Dec 2016 10:41:33 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id EA2E5160B15; Tue, 13 Dec 2016 09:41:33 +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 DE88E160B32 for ; Tue, 13 Dec 2016 10:41:32 +0100 (CET) Received: (qmail 28833 invoked by uid 500); 13 Dec 2016 09:41:32 -0000 Mailing-List: contact commits-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 commits@camel.apache.org Received: (qmail 28779 invoked by uid 99); 13 Dec 2016 09:41:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Dec 2016 09:41:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AD4ECF17B4; Tue, 13 Dec 2016 09:41:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Tue, 13 Dec 2016 09:41:34 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/4] camel git commit: Moved test from karaf to osgi. This fixes #1336. archived-at: Tue, 13 Dec 2016 09:41:34 -0000 Moved test from karaf to osgi. This fixes #1336. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/dac56906 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/dac56906 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/dac56906 Branch: refs/heads/camel-2.18.x Commit: dac569062759958b8a4c9de7ec2c872502fc6f11 Parents: 05ba679 Author: Claus Ibsen Authored: Tue Dec 13 10:40:41 2016 +0100 Committer: Claus Ibsen Committed: Tue Dec 13 10:41:22 2016 +0100 ---------------------------------------------------------------------- tests/camel-itest-karaf/pom.xml | 5 -- .../org/apache/camel/itest/karaf/bean/Pojo.java | 72 -------------------- .../CamelJacksonFallbackConverterTest.java | 60 ---------------- tests/camel-itest-osgi/pom.xml | 5 ++ .../CamelJacksonFallbackConverterTest.java | 66 ++++++++++++++++++ .../test/java/org/apache/camel/itest/Pojo.java | 72 ++++++++++++++++++++ .../itest/CamelJacksonFallbackConverterTest.xml | 26 +++++++ 7 files changed, 169 insertions(+), 137 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/dac56906/tests/camel-itest-karaf/pom.xml ---------------------------------------------------------------------- diff --git a/tests/camel-itest-karaf/pom.xml b/tests/camel-itest-karaf/pom.xml index f8941e3..e6d1dbe 100644 --- a/tests/camel-itest-karaf/pom.xml +++ b/tests/camel-itest-karaf/pom.xml @@ -121,11 +121,6 @@ test - org.apache.camel - camel-jackson - test - - org.apache.camel.karaf apache-camel ${project.version} http://git-wip-us.apache.org/repos/asf/camel/blob/dac56906/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/bean/Pojo.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/bean/Pojo.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/bean/Pojo.java deleted file mode 100644 index 4468913..0000000 --- a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/bean/Pojo.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.itest.karaf.bean; - -public class Pojo { - private int id; - private String name; - - public Pojo(int id, String name) { - this.id = id; - this.name = name; - } - - public Pojo() { - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Pojo)) { - return false; - } - - - Pojo pojo = (Pojo) o; - - if (id != pojo.getId()) { - return false; - } - return name != null ? name.equals(pojo.getName()) : pojo.getName() == null; - - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + (name != null ? name.hashCode() : 0); - return result; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/dac56906/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/converters/CamelJacksonFallbackConverterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/converters/CamelJacksonFallbackConverterTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/converters/CamelJacksonFallbackConverterTest.java deleted file mode 100644 index 136da20..0000000 --- a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/converters/CamelJacksonFallbackConverterTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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.itest.karaf.converters; - -import org.apache.camel.CamelContext; -import org.apache.camel.component.jackson.JacksonConstants; -import org.apache.camel.impl.DefaultExchange; -import org.apache.camel.itest.karaf.BaseKarafTest; -import org.apache.camel.itest.karaf.bean.Pojo; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.junit.Assert.assertNotNull; - -@RunWith(PaxExam.class) -public class CamelJacksonFallbackConverterTest extends BaseKarafTest { - - @Configuration - public static Option[] configure() { - return BaseKarafTest.configure("camel-jackson"); - } - - @Test - public void test() throws Exception { - CamelContext context = getOsgiService(bundleContext, CamelContext.class, "(camel.context.name=myCamel)", SERVICE_TIMEOUT); - assertNotNull("Cannot find CamelContext with name myCamel", context); - - // enable Jackson json type converter - context.getProperties().put(JacksonConstants.ENABLE_TYPE_CONVERTER, "true"); - // allow Jackson json to convert to pojo types also (by default jackson only converts to String and other simple types) - context.getProperties().put(JacksonConstants.TYPE_CONVERTER_TO_POJO, "true"); - - // test type conversion - final Pojo pojo = new Pojo(1337, "Constantine"); - final DefaultExchange exchange = new DefaultExchange(context); - final String string = context.getTypeConverter().mandatoryConvertTo(String.class, exchange, pojo); - final Pojo copy = context.getTypeConverter().mandatoryConvertTo(Pojo.class, exchange, string); - Assert.assertEquals(pojo, copy); - } - - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/dac56906/tests/camel-itest-osgi/pom.xml ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/pom.xml b/tests/camel-itest-osgi/pom.xml index 7ce17ec..f5f93d1 100644 --- a/tests/camel-itest-osgi/pom.xml +++ b/tests/camel-itest-osgi/pom.xml @@ -36,6 +36,11 @@ camel-test-karaf test + + org.apache.camel + camel-jackson + test + http://git-wip-us.apache.org/repos/asf/camel/blob/dac56906/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelJacksonFallbackConverterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelJacksonFallbackConverterTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelJacksonFallbackConverterTest.java new file mode 100644 index 0000000..84ad9f8 --- /dev/null +++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelJacksonFallbackConverterTest.java @@ -0,0 +1,66 @@ +/** + * 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.itest; + +import java.net.URL; + +import org.apache.camel.CamelContext; +import org.apache.camel.component.jackson.JacksonConstants; +import org.apache.camel.impl.DefaultExchange; +import org.apache.camel.test.karaf.AbstractFeatureTest; +import org.apache.camel.test.karaf.CamelKarafTestSupport; +import org.apache.camel.util.ObjectHelper; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; + +@RunWith(PaxExam.class) +public class CamelJacksonFallbackConverterTest extends AbstractFeatureTest { + + @Test + public void test() throws Exception { + // install the camel blueprint xml file we use in this test + URL url = ObjectHelper.loadResourceAsURL("org/apache/camel/itest/CamelJacksonFallbackConverterTest.xml", CamelJacksonFallbackConverterTest.class.getClassLoader()); + installBlueprintAsBundle("CamelJacksonFallbackConverterTest", url, true); + + // lookup Camel from OSGi + CamelContext camel = getOsgiService(bundleContext, CamelContext.class); + + // enable Jackson json type converter + camel.getProperties().put(JacksonConstants.ENABLE_TYPE_CONVERTER, "true"); + // allow Jackson json to convert to pojo types also (by default jackson only converts to String and other simple types) + camel.getProperties().put(JacksonConstants.TYPE_CONVERTER_TO_POJO, "true"); + + final Pojo pojo = new Pojo(1337, "Constantine"); + + final DefaultExchange exchange = new DefaultExchange(camel); + final String string = camel.getTypeConverter().mandatoryConvertTo(String.class, exchange, pojo); + LOG.info("POJO -> String: {}", string); + final Pojo copy = camel.getTypeConverter().mandatoryConvertTo(Pojo.class, exchange, string); + LOG.info("String -> POJO: {}", copy); + Assert.assertEquals(pojo, copy); + } + + @Configuration + public Option[] configure() { + return CamelKarafTestSupport.configure("camel-test-karaf", "camel-jackson"); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/dac56906/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/Pojo.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/Pojo.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/Pojo.java new file mode 100644 index 0000000..258774c --- /dev/null +++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/Pojo.java @@ -0,0 +1,72 @@ +/** + * 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.itest; + +public class Pojo { + private int id; + private String name; + + public Pojo(int id, String name) { + this.id = id; + this.name = name; + } + + public Pojo() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Pojo)) { + return false; + } + + + Pojo pojo = (Pojo) o; + + if (id != pojo.getId()) { + return false; + } + return name != null ? name.equals(pojo.getName()) : pojo.getName() == null; + + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + (name != null ? name.hashCode() : 0); + return result; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/dac56906/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelJacksonFallbackConverterTest.xml ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelJacksonFallbackConverterTest.xml b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelJacksonFallbackConverterTest.xml new file mode 100644 index 0000000..bf8202b --- /dev/null +++ b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelJacksonFallbackConverterTest.xml @@ -0,0 +1,26 @@ + + + + + + + +