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/02/21 03:50:12 UTC

svn commit: r1448493 - in /camel/trunk: components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/ tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/ tests/camel-blueprint-cxf-test/src/test/resources/org...

Author: ningjiang
Date: Thu Feb 21 02:50:12 2013
New Revision: 1448493

URL: http://svn.apache.org/r1448493
Log:
CAMEL-6089 fix the NPE issue across the camel-cxf blueprint config with thanks to Aki

Added:
    camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Test.java
    camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Beans.xml
Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/EndpointDefinitionParser.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/EndpointDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/EndpointDefinitionParser.java?rev=1448493&r1=1448492&r2=1448493&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/EndpointDefinitionParser.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/EndpointDefinitionParser.java Thu Feb 21 02:50:12 2013
@@ -74,13 +74,13 @@ public class EndpointDefinitionParser ex
                 Metadata map = parseMapData(context, endpointConfig, elem);
                 endpointConfig.addProperty(name, map);
             } else if ("binding".equals(name)) {
-                setFirstChildAsProperty(element, context, endpointConfig, "bindingConfig");
+                setFirstChildAsProperty(elem, context, endpointConfig, "bindingConfig");
             } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                 || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                 Metadata list = parseListData(context, endpointConfig, elem);
                 endpointConfig.addProperty(name, list);
             } else {
-                setFirstChildAsProperty(element, context, endpointConfig, name);
+                setFirstChildAsProperty(elem, context, endpointConfig, name);
             }
 
             elem = DOMUtils.getNextElement(elem);

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java?rev=1448493&r1=1448492&r2=1448493&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientDefinitionParser.java Thu Feb 21 02:50:12 2013
@@ -63,7 +63,7 @@ public class RsClientDefinitionParser ex
                 Metadata map = parseMapData(context, beanMetadata, elem);
                 beanMetadata.addProperty(name, map);
             } else if ("binding".equals(name)) {
-                setFirstChildAsProperty(element, context, beanMetadata, "bindingConfig");
+                setFirstChildAsProperty(elem, context, beanMetadata, "bindingConfig");
             } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                 || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                 Metadata list = parseListData(context, beanMetadata, elem);
@@ -79,7 +79,7 @@ public class RsClientDefinitionParser ex
                 value.setObject(resources);
                 beanMetadata.addProperty(name, value);
             } else {
-                setFirstChildAsProperty(element, context, beanMetadata, name);
+                setFirstChildAsProperty(elem, context, beanMetadata, name);
             }
         } 
  

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java?rev=1448493&r1=1448492&r2=1448493&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerDefinitionParser.java Thu Feb 21 02:50:12 2013
@@ -65,7 +65,7 @@ public class RsServerDefinitionParser ex
                 Metadata map = parseMapData(context, beanMetadata, elem);
                 beanMetadata.addProperty(name, map);
             } else if ("binding".equals(name)) {
-                setFirstChildAsProperty(element, context, beanMetadata, "bindingConfig");
+                setFirstChildAsProperty(elem, context, beanMetadata, "bindingConfig");
             } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                 || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                 Metadata list = parseListData(context, beanMetadata, elem);
@@ -80,7 +80,7 @@ public class RsServerDefinitionParser ex
                 value.setObject(resources);
                 beanMetadata.addProperty(name, value);
             } else {
-                setFirstChildAsProperty(element, context, beanMetadata, name);
+                setFirstChildAsProperty(elem, context, beanMetadata, name);
             }
         } 
  

Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Test.java?rev=1448493&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Test.java (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Test.java Thu Feb 21 02:50:12 2013
@@ -0,0 +1,82 @@
+/**
+ * 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.cxf.blueprint;
+
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.camel.component.cxf.CXFTestSupport;
+import org.apache.camel.component.cxf.CxfEndpoint;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.apache.cxf.binding.BindingConfiguration;
+import org.apache.cxf.binding.soap.SoapBindingConfiguration;
+import org.apache.hello_world_soap_http.Greeter;
+
+import org.junit.Test;
+
+public class CxfConsumerSoap12Test extends CamelBlueprintTestSupport {
+    private static final QName SERVICE_NAME = new QName("http://apache.org/hello_world_soap_http",
+                                                "SOAPService");
+    private static final QName PORT_NAME = new QName("http://apache.org/hello_world_soap_http",
+                                                "SoapPort");
+
+    @Override
+    protected Properties useOverridePropertiesWithPropertiesComponent() {
+        Properties extra = new Properties();
+        extra.put("router.address", "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerSoap12Test/router");
+        return extra;
+    }
+    
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Beans.xml";
+    }
+
+    @Test
+    public void testCxfEndpointBeanDefinitionParser() {
+        CxfEndpoint routerEndpoint = context.getEndpoint("routerEndpoint", CxfEndpoint.class);
+        assertEquals("Got the wrong endpoint address", routerEndpoint.getAddress(),
+                     "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerSoap12Test/router");
+        assertEquals("Got the wrong endpont service class", 
+                     "org.apache.hello_world_soap_http.Greeter", 
+                     routerEndpoint.getServiceClass().getName());
+        BindingConfiguration binding = routerEndpoint.getBindingConfig();
+        assertTrue("Got no soap binding", binding instanceof SoapBindingConfiguration);
+        assertEquals("Got the wrong soap version", "http://schemas.xmlsoap.org/wsdl/soap12/",
+                     ((SoapBindingConfiguration)binding).getVersion().getBindingId());
+        assertTrue("Mtom not enabled", ((SoapBindingConfiguration)binding).isMtomEnabled());
+    }
+
+    @Test
+    public void testInvokeGreeter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
+        Service service = Service.create(SERVICE_NAME);
+        service.addPort(PORT_NAME , "http://www.w3.org/2003/05/soap/bindings/HTTP/", 
+                        "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerSoap12Test/router");
+        Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
+        
+        greeter.greetMeOneWay("test");
+        
+        assertMockEndpointsSatisfied();
+    }
+}

Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Beans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Beans.xml?rev=1448493&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Beans.xml (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfConsumerSoap12Beans.xml Thu Feb 21 02:50:12 2013
@@ -0,0 +1,57 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xmlns:camel="http://camel.apache.org/schema/blueprint"
+           xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
+           xmlns:soap="http://cxf.apache.org/blueprint/bindings/soap"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+           xmlns:s="http://cxf.apache.org/hello_world_soap_http"
+           xsi:schemaLocation="
+             http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
+             http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
+             http://cxf.apache.org/blueprint/bindings/soap http://cxf.apache.org/schemas/configuration/blueprint/soap.xsd
+             http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+  <!-- blueprint property placeholders -->
+  <cm:property-placeholder persistent-id="my-placeholders">
+    <cm:default-properties>
+      <cm:property name="router.address" value="http://localhost:9000/routerEndpoint" />
+    </cm:default-properties>
+  </cm:property-placeholder>
+  
+  <cxf:cxfEndpoint id="routerEndpoint" address="{{router.address}}"
+      serviceClass="org.apache.hello_world_soap_http.Greeter">
+    <cxf:properties>
+      <entry key="dataFormat" value="PAYLOAD"/>
+      <entry key="org.apache.cxf.oneway.robust" value="true"/>
+    </cxf:properties>
+    <cxf:binding>
+      <soap:soapBinding mtomEnabled="true" version="1.2"/>
+    </cxf:binding>
+  </cxf:cxfEndpoint>
+
+  <camel:camelContext id="camel">
+    <camel:route>
+      <camel:from uri="cxf:bean:routerEndpoint?synchronous=true" />
+      <camel:to uri="mock:result" />
+    </camel:route>
+  </camel:camelContext>
+
+</blueprint>