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 2011/11/25 11:32:23 UTC

svn commit: r1206116 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ test/java/org/apache/camel/component/cxf/spring/ test/resources/org/apache/camel/component/cxf/spring/

Author: ningjiang
Date: Fri Nov 25 10:32:23 2011
New Revision: 1206116

URL: http://svn.apache.org/viewvc?rev=1206116&view=rev
Log:
CAMEL-4711 Supports to set the properties on the ClientFactoryBean

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1206116&r1=1206115&r2=1206116&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Fri Nov 25 10:32:23 2011
@@ -292,7 +292,7 @@ public class CxfEndpoint extends Default
             } else {
                 sfb.setProperties(getProperties());
             }
-            LOG.debug("ServerFactoryBean: {} added properties: {}", sfb, properties);
+            LOG.debug("ServerFactoryBean: {} added properties: {}", sfb, getProperties());
         }
 
         sfb.setBus(getBus());
@@ -437,6 +437,17 @@ public class CxfEndpoint extends Default
         if (getWrappedStyle() != null) {
             factoryBean.getServiceFactory().setWrapped(getWrappedStyle());
         }
+        
+        // any optional properties
+        if (getProperties() != null) {
+            if (factoryBean.getProperties() != null) {
+                // add to existing properties
+                factoryBean.getProperties().putAll(getProperties());
+            } else {
+                factoryBean.setProperties(getProperties());
+            }
+            LOG.debug("ClientFactoryBean: {} added properties: {}", factoryBean, getProperties());
+        }
 
         factoryBean.setBus(getBus());
     }

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java?rev=1206116&r1=1206115&r2=1206116&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java Fri Nov 25 10:32:23 2011
@@ -20,7 +20,10 @@ import javax.xml.namespace.QName;
 
 import org.apache.camel.component.cxf.CXFTestSupport;
 import org.apache.camel.component.cxf.CxfEndpoint;
+import org.apache.camel.component.cxf.CxfProducer;
 import org.apache.cxf.binding.soap.SoapBindingConfiguration;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.junit.Test;
 
 public class CxfEndpointBeanTest extends AbstractSpringBeanTestSupport {
@@ -63,5 +66,14 @@ public class CxfEndpointBeanTest extends
         assertEquals("We should get a right soap version", "1.2", String.valueOf(configuration.getVersion().getVersion()));
         
     }
+    
+    @Test
+    public void testPropertiesSettingOnCxfClient() throws Exception {
+        CxfEndpoint clientEndpoint = (CxfEndpoint)ctx.getBean("clientEndpoint");
+        CxfProducer producer = (CxfProducer) clientEndpoint.createProducer();
+        Client client = producer.getClient();
+        HTTPConduit conduit = (HTTPConduit)client.getConduit();
+        assertEquals("Got the wrong user name", "test", conduit.getAuthorization().getUserName());
+    }
       
 }

Modified: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml?rev=1206116&r1=1206115&r2=1206116&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml (original)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml Fri Nov 25 10:32:23 2011
@@ -41,6 +41,17 @@
 
   <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:${CXFTestSupport.port2}/CxfEndpointBeanTest/helloworld"
     serviceClass="org.apache.camel.component.cxf.HelloService"/>
+    
+  <cxf:cxfEndpoint id="clientEndpoint" address="http://localhost:${CXFTestSupport.port2}/CxfEndpointBeanTest/helloworld"
+    serviceClass="org.apache.camel.component.cxf.HelloService">
+    <cxf:properties>
+       <entry key="org.apache.cxf.configuration.security.AuthorizationPolicy" value-ref="myPolicy"/>
+    </cxf:properties>
+  </cxf:cxfEndpoint>
+  
+  <bean id="myPolicy" class="org.apache.cxf.configuration.security.AuthorizationPolicy" >
+     <property name="UserName" value="test" />
+  </bean>
 
   <cxf:cxfEndpoint id="myEndpoint" address="http://localhost:${CXFTestSupport.port3}/test"
     serviceClass="org.apache.camel.wsdl_first.Person" serviceName="${CxfEndpointBeans.serviceName}" endpointName="${CxfEndpointBeans.endpointName}"