Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F0899105FB for ; Thu, 11 Jul 2013 16:09:23 +0000 (UTC) Received: (qmail 17945 invoked by uid 500); 11 Jul 2013 16:09:23 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 17910 invoked by uid 500); 11 Jul 2013 16:09:23 -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 17890 invoked by uid 99); 11 Jul 2013 16:09:23 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jul 2013 16:09:23 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 45BD988F90E; Thu, 11 Jul 2013 16:09:23 +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: Thu, 11 Jul 2013 16:09:23 -0000 Message-Id: <12958f3615694d418cc63f44b8c28328@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] git commit: Added unit test about using custom type converters in camel-test-blueprint Updated Branches: refs/heads/master e42b0b9e5 -> dc281f360 Added unit test about using custom type converters in camel-test-blueprint Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a5b32962 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a5b32962 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a5b32962 Branch: refs/heads/master Commit: a5b3296216b44c7cd08263b066b374a86c2b2b0f Parents: e42b0b9 Author: Claus Ibsen Authored: Thu Jul 11 11:43:16 2013 +0200 Committer: Claus Ibsen Committed: Thu Jul 11 18:04:38 2013 +0200 ---------------------------------------------------------------------- .../org/apache/camel/test/blueprint/Foo.java | 39 +++++++++++++++++ .../converter/CustomConverterTest.java | 44 ++++++++++++++++++++ .../test/blueprint/converter/MyConverter.java | 34 +++++++++++++++ .../services/org/apache/camel/TypeConverter | 18 ++++++++ .../src/test/resources/log4j.properties | 1 + .../blueprint/converter/CustomConverterTest.xml | 34 +++++++++++++++ 6 files changed, 170 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java new file mode 100644 index 0000000..b6782d9 --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java @@ -0,0 +1,39 @@ +/** + * 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.test.blueprint; + +public class Foo { + + private String first; + private String last; + + public String getFirst() { + return first; + } + + public void setFirst(String first) { + this.first = first; + } + + public String getLast() { + return last; + } + + public void setLast(String last) { + this.last = last; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java new file mode 100644 index 0000000..1c1ce64 --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java @@ -0,0 +1,44 @@ +/** + * 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.test.blueprint.converter; + +import org.apache.camel.test.blueprint.CamelBlueprintTestSupport; +import org.apache.camel.test.blueprint.Foo; +import org.junit.Test; + +public class CustomConverterTest extends CamelBlueprintTestSupport { + + @Override + protected String getBlueprintDescriptor() { + return "org/apache/camel/test/blueprint/converter/CustomConverterTest.xml"; + } + + @Test + public void testCustomConverter() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(1); + getMockEndpoint("mock:result").message(0).body().isInstanceOf(Foo.class); + + template.sendBody("direct:start", "John,Doe"); + + assertMockEndpointsSatisfied(); + + Foo foo = getMockEndpoint("mock:result").getReceivedExchanges().get(0).getIn().getBody(Foo.class); + assertEquals("John", foo.getFirst()); + assertEquals("Doe", foo.getLast()); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java new file mode 100644 index 0000000..58131cc --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java @@ -0,0 +1,34 @@ +/** + * 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.test.blueprint.converter; + +import org.apache.camel.Converter; +import org.apache.camel.test.blueprint.Foo; + +@Converter +public class MyConverter { + + @Converter + public static Foo convertToFoo(String data) { + String[] s = data.split(","); + Foo foo = new Foo(); + foo.setFirst(s[0]); + foo.setLast(s[1]); + return foo; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter b/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter new file mode 100644 index 0000000..2b0f5e5 --- /dev/null +++ b/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter @@ -0,0 +1,18 @@ +# +# 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. +# + +org.apache.camel.test.blueprint.converter.MyConverter \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/resources/log4j.properties b/components/camel-test-blueprint/src/test/resources/log4j.properties index f090d64..8d8dd6b 100644 --- a/components/camel-test-blueprint/src/test/resources/log4j.properties +++ b/components/camel-test-blueprint/src/test/resources/log4j.properties @@ -23,6 +23,7 @@ log4j.rootLogger=INFO, file #log4j.logger.de.kalpatec.pojosr=DEBUG #log4j.logger.org.apache.camel.test.blueprint=DEBUG #log4j.logger.org.apache.camel=DEBUG +#log4j.logger.org.apache.camel.impl.osgi.Activator=DEBUG #log4j.logger.org.apache.camel.blueprint=TRACE #log4j.logger.org.apache.camel.core.osgi=TRACE #log4j.logger.org.apache.aries.blueprint.container=DEBUG http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml new file mode 100644 index 0000000..3b6f43b --- /dev/null +++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + +