Updated Branches: refs/heads/master c569bd95f -> efe77bbdd
CAMEL-6404 Fixed the NPE issue when the dataformate is CXF_MESSAGE Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/efe77bbd Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/efe77bbd Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/efe77bbd Branch: refs/heads/master Commit: efe77bbdd09e097752c6e9246c1e7cf7b0be73e0 Parents: c569bd9 Author: Willem Jiang <[email protected]> Authored: Fri May 31 22:35:49 2013 +0800 Committer: Willem Jiang <[email protected]> Committed: Fri May 31 22:35:49 2013 +0800 ---------------------------------------------------------------------- .../camel/component/cxf/DefaultCxfBinding.java | 5 +- .../cxf/CxfGreeterCXFMessageRouterTest.java | 60 +++++++++++++++ .../cxf/GreeterEndpointCxfMessageBeans.xml | 48 ++++++++++++ 3 files changed, 112 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/efe77bbd/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java index 50da65b..05129ec 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java @@ -662,7 +662,10 @@ public class DefaultCxfBinding implements CxfBinding, HeaderFilterStrategyAware } else if (dataFormat.dealias() == DataFormat.RAW) { answer = message.getContent(InputStream.class); - } else if (dataFormat.dealias() == DataFormat.CXF_MESSAGE) { + } else if (dataFormat.dealias() == DataFormat.CXF_MESSAGE + && message.getContent(List.class) != null) { + // CAMEL-6404 added check point of message content + // The message content of list could be null if there is a fault message is received answer = message.getContent(List.class).get(0); } http://git-wip-us.apache.org/repos/asf/camel/blob/efe77bbd/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java new file mode 100644 index 0000000..0b7283a --- /dev/null +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java @@ -0,0 +1,60 @@ +/** + * 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.cxf; + +import javax.xml.ws.Endpoint; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.hello_world_soap_http.GreeterImpl; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class CxfGreeterCXFMessageRouterTest extends AbstractCXFGreeterRouterTest { + protected static Endpoint endpoint; + @AfterClass + public static void stopService() { + if (endpoint != null) { + endpoint.stop(); + } + } + + + @BeforeClass + public static void startService() { + Object implementor = new GreeterImpl(); + String address = "http://localhost:" + getPort1() + + "/CxfGreeterCXFMessageRouterTest/SoapContext/SoapPort"; + endpoint = Endpoint.publish(address, implementor); + } + + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("cxf:bean:routerEndpoint?dataFormat=CXF_MESSAGE&publishedEndpointUrl=http://www.simple.com/services/test") + .to("cxf:bean:serviceEndpoint?dataFormat=CXF_MESSAGE"); + } + }; + } + + @Override + protected ClassPathXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointCxfMessageBeans.xml"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/efe77bbd/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageBeans.xml ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageBeans.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageBeans.xml new file mode 100644 index 0000000..c36500b --- /dev/null +++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageBeans.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:cxf="http://camel.apache.org/schema/cxf" + + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + "> + + <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> + + <import resource="classpath:META-INF/cxf/cxf.xml"/> + <!-- Added the import for testing the CAMEL-329 --> + + + <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:${CXFTestSupport.port2}/CxfGreeterCXFMessageRouterTest/CamelContext/RouterPort" + serviceClass="org.apache.hello_world_soap_http.GreeterImpl" + loggingFeatureEnabled="true"> + </cxf:cxfEndpoint> + + <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:${CXFTestSupport.port1}/CxfGreeterCXFMessageRouterTest/SoapContext/SoapPort" + wsdlURL="testutils/hello_world.wsdl" + serviceClass="org.apache.hello_world_soap_http.Greeter" + endpointName="s:SoapPort" + serviceName="s:SOAPService" + xmlns:s="http://apache.org/hello_world_soap_http" > + + </cxf:cxfEndpoint> + +</beans> \ No newline at end of file
