You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/10/20 10:40:46 UTC

[4/4] git commit: CAMEL-6243 Fixed the NPE of ClientFaultConverter when receiving a soapfault with the CFX_MESSAGE dataformat

CAMEL-6243 Fixed the NPE of ClientFaultConverter when receiving a soapfault with the CFX_MESSAGE dataformat


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec779785
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec779785
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec779785

Branch: refs/heads/camel-2.10.x
Commit: ec779785b97b740d3e336574c6527aba94d31b1e
Parents: 422d3f3
Author: Willem Jiang <ni...@apache.org>
Authored: Sun Oct 20 16:25:52 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Oct 20 16:31:41 2013 +0800

----------------------------------------------------------------------
 .../cxf/feature/AbstractDataFormatFeature.java  | 17 +++++++
 .../feature/CXFMessageDataFormatFeature.java    |  1 +
 .../cxf/feature/PayLoadDataFormatFeature.java   | 11 +----
 .../cxf/CxfGreeterCXFMessageRouterTest.java     |  2 +
 ...xfGreeterCXFMessageWithoutSEIRouterTest.java | 50 ++++++++++++++++++++
 ...GreeterEndpointCxfMessageWithoutSEIBeans.xml | 47 ++++++++++++++++++
 6 files changed, 118 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
index 92acf64..857b532 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
@@ -17,12 +17,15 @@
 
 package org.apache.camel.component.cxf.feature;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.ClientFaultConverter;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.PhaseInterceptor;
@@ -32,11 +35,18 @@ import org.slf4j.Logger;
  * The abstract class for the data format feature
  */
 public abstract class AbstractDataFormatFeature extends AbstractFeature {
+    protected static final Collection<Class<?>> REMOVING_FAULT_IN_INTERCEPTORS;
+    
+    static {
+        REMOVING_FAULT_IN_INTERCEPTORS = new ArrayList<Class<?>>();
+        REMOVING_FAULT_IN_INTERCEPTORS.add(ClientFaultConverter.class);
+    }
 
     // The interceptors which need to be keeped
     protected Set<String> inInterceptorNames = new HashSet<String>();
     protected Set<String> outInterceptorNames = new HashSet<String>();
     protected abstract Logger getLogger();
+    
 
     @Deprecated
     // It will be removed in Camel 3.0
@@ -116,6 +126,13 @@ public abstract class AbstractDataFormatFeature extends AbstractFeature {
         }        
     }
     
+    protected void removeFaultInInterceptorFromClient(Client client) {
+        removeInterceptors(client.getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(client.getEndpoint().getService().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(client.getEndpoint().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(client.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+    }
+    
     public void addInIntercepters(List<Interceptor<? extends Message>> interceptors) {
         for (Interceptor<? extends Message> interceptor : interceptors) {
             inInterceptorNames.add(interceptor.getClass().getName());

http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java
index ad1147d..e45df29 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java
@@ -69,6 +69,7 @@ public class CXFMessageDataFormatFeature extends AbstractDataFormatFeature {
 
     @Override
     public void initialize(Client client, Bus bus) {
+        removeFaultInInterceptorFromClient(client);
         setupEndpoint(client.getEndpoint());
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
index 4642358..bf6ec31 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
@@ -44,11 +44,8 @@ import org.slf4j.LoggerFactory;
  */
 public class PayLoadDataFormatFeature extends AbstractDataFormatFeature {
     private static final Logger LOG = LoggerFactory.getLogger(PayLoadDataFormatFeature.class);
-    private static final Collection<Class<?>> REMOVING_FAULT_IN_INTERCEPTORS;
     private static final boolean DEFAULT_ALLOW_STREAMING;
     static {
-        REMOVING_FAULT_IN_INTERCEPTORS = new ArrayList<Class<?>>();
-        REMOVING_FAULT_IN_INTERCEPTORS.add(ClientFaultConverter.class);
         
         String s = System.getProperty("org.apache.camel.component.cxf.streaming");
         DEFAULT_ALLOW_STREAMING = s == null || Boolean.parseBoolean(s);
@@ -163,11 +160,5 @@ public class PayLoadDataFormatFeature extends AbstractDataFormatFeature {
             }
         }
     }
-    private void removeFaultInInterceptorFromClient(Client client) {
-        removeInterceptors(client.getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
-        removeInterceptors(client.getEndpoint().getService().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
-        removeInterceptors(client.getEndpoint().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
-        removeInterceptors(client.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
-    }
-
+    
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/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
index 0b7283a..5368b3e 100644
--- 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
@@ -18,6 +18,7 @@ package org.apache.camel.component.cxf;
 
 import javax.xml.ws.Endpoint;
 
+import org.apache.camel.builder.NoErrorHandlerBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.hello_world_soap_http.GreeterImpl;
 import org.junit.AfterClass;
@@ -47,6 +48,7 @@ public class CxfGreeterCXFMessageRouterTest extends AbstractCXFGreeterRouterTest
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
+                context.setErrorHandlerBuilder(new NoErrorHandlerBuilder());
                 from("cxf:bean:routerEndpoint?dataFormat=CXF_MESSAGE&publishedEndpointUrl=http://www.simple.com/services/test")
                     .to("cxf:bean:serviceEndpoint?dataFormat=CXF_MESSAGE");
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java
new file mode 100644
index 0000000..cbc809f
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java
@@ -0,0 +1,50 @@
+/**
+ * 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.hello_world_soap_http.GreeterImpl;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfGreeterCXFMessageWithoutSEIRouterTest extends CxfGreeterCXFMessageRouterTest {
+    
+    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() 
+            + "/CxfGreeterCXFMessageWithoutSEIRouterTest/SoapContext/SoapPort";
+        endpoint = Endpoint.publish(address, implementor); 
+    }
+    
+    @Override
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml
new file mode 100644
index 0000000..5d91e8d
--- /dev/null
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml
@@ -0,0 +1,47 @@
+<?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"/>
+
+
+   <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:${CXFTestSupport.port2}/CxfGreeterCXFMessageWithoutSEIRouterTest/CamelContext/RouterPort"
+    		wsdlURL="testutils/hello_world.wsdl"
+    		endpointName="s:SoapPort"
+    		serviceName="s:SOAPService"
+    	    xmlns:s="http://apache.org/hello_world_soap_http"
+    		loggingFeatureEnabled="true">
+   </cxf:cxfEndpoint>
+
+   <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:${CXFTestSupport.port1}/CxfGreeterCXFMessageWithoutSEIRouterTest/SoapContext/SoapPort"
+    		wsdlURL="testutils/hello_world.wsdl"
+    		endpointName="s:SoapPort"
+    		serviceName="s:SOAPService"
+    	xmlns:s="http://apache.org/hello_world_soap_http" >
+    	
+   </cxf:cxfEndpoint>
+
+</beans>
\ No newline at end of file