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 34CA3909D for ; Thu, 19 Jan 2012 10:28:59 +0000 (UTC) Received: (qmail 67595 invoked by uid 500); 19 Jan 2012 10:28:59 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 67531 invoked by uid 500); 19 Jan 2012 10:28:57 -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 67524 invoked by uid 99); 19 Jan 2012 10:28:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2012 10:28:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2012 10:28:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 86BAE23889C5 for ; Thu, 19 Jan 2012 10:28:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1233269 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/converter/ components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/ tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/ tests/camel-it... Date: Thu, 19 Jan 2012 10:28:32 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120119102832.86BAE23889C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Thu Jan 19 10:28:31 2012 New Revision: 1233269 URL: http://svn.apache.org/viewvc?rev=1233269&view=rev Log: CAMEL-4915: Serialization data format should use ClassResolver API from Camel to work with other runtimes. Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/MySerialBean.java camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/MySerialBean.java camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/SerializationDataFormatTest.java - copied, changed from r1233154, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/direct/DirectTest.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java?rev=1233269&r1=1233268&r2=1233269&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java Thu Jan 19 10:28:31 2012 @@ -335,7 +335,7 @@ public final class IOConverter { @Override protected Class resolveClass(ObjectStreamClass objectStreamClass) throws IOException, ClassNotFoundException { // need to let Camel be able to resolve class using ClassResolver SPI, to let class loading - // work in OSGi and other runtimes + // work in OSGi and other containers Class answer = null; String name = objectStreamClass.getName(); if (exchange != null) { Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java?rev=1233269&r1=1233268&r2=1233269&view=diff ============================================================================== --- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java (original) +++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java Thu Jan 19 10:28:31 2012 @@ -39,10 +39,12 @@ public class OsgiClassResolver extends D } public Class resolveClass(String name) { + LOG.trace("Resolve class {}", name); name = ObjectHelper.normalizeClassName(name); Class clazz = ObjectHelper.loadSimpleType(name); if (clazz == null) { clazz = doLoadClass(name, bundleContext.getBundle()); + LOG.trace("Loading class {} using BundleContext {} -> {}", new Object[]{name, bundleContext.getBundle(), clazz}); } return clazz; } Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/MySerialBean.java URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/MySerialBean.java?rev=1233269&view=auto ============================================================================== --- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/MySerialBean.java (added) +++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/MySerialBean.java Thu Jan 19 10:28:31 2012 @@ -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.itest.osgi.blueprint; + +import java.io.Serializable; + +/** + * + */ +public class MySerialBean implements Serializable { + + private int id; + private String name; + + 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; + } +} Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/MySerialBean.java URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/MySerialBean.java?rev=1233269&view=auto ============================================================================== --- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/MySerialBean.java (added) +++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/MySerialBean.java Thu Jan 19 10:28:31 2012 @@ -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.itest.osgi.core.dataformat; + +import java.io.Serializable; + +/** + * + */ +public class MySerialBean implements Serializable { + + private int id; + private String name; + + 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; + } +} Copied: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/SerializationDataFormatTest.java (from r1233154, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/direct/DirectTest.java) URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/SerializationDataFormatTest.java?p2=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/SerializationDataFormatTest.java&p1=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/direct/DirectTest.java&r1=1233154&r2=1233269&rev=1233269&view=diff ============================================================================== --- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/direct/DirectTest.java (original) +++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/dataformat/SerializationDataFormatTest.java Thu Jan 19 10:28:31 2012 @@ -14,26 +14,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.itest.osgi.core.direct; +package org.apache.camel.itest.osgi.core.dataformat; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.junit.JUnit4TestRunner; @RunWith(JUnit4TestRunner.class) -public class DirectTest extends OSGiIntegrationTestSupport { - +public class SerializationDataFormatTest extends OSGiIntegrationTestSupport { + @Test - public void testSendMessage() throws Exception { - MockEndpoint mock = getMandatoryEndpoint("mock:result", MockEndpoint.class); - assertNotNull("The mock endpoint should not be null", mock); - - mock.expectedBodiesReceived("Hello World"); - template.sendBody("direct:start", "Hello World"); - assertMockEndpointsSatisfied(); + public void testSerialization() throws Exception { + MySerialBean bean = new MySerialBean(); + bean.setId(123); + bean.setName("Donald"); + + Object data = template.requestBody("direct:marshal", bean); + assertNotNull(data); + + Object out = template.requestBody("direct:unmarshal", data); + assertNotNull(out); + + MySerialBean outBean = context.getTypeConverter().convertTo(MySerialBean.class, out); + assertNotNull(outBean); + assertEquals(123, outBean.getId()); + assertEquals("Donald", outBean.getName()); } @Override @@ -41,7 +48,11 @@ public class DirectTest extends OSGiInte return new RouteBuilder() { @Override public void configure() throws Exception { - from("direct:start").to("mock:result"); + from("direct:unmarshal") + .unmarshal().serialization(); + + from("direct:marshal") + .marshal().serialization(); } }; }