camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r827794 - in /camel/trunk/components/camel-cxf/src/test: java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml
Date Tue, 20 Oct 2009 21:10:08 GMT
Author: wtam
Date: Tue Oct 20 21:10:08 2009
New Revision: 827794

URL: http://svn.apache.org/viewvc?rev=827794&view=rev
Log:
add soap header filter that uses no service class config

Modified:
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java?rev=827794&r1=827793&r2=827794&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java
Tue Oct 20 21:10:08 2009
@@ -34,6 +34,7 @@
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.Holder;
 
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
@@ -43,6 +44,7 @@
 import org.apache.camel.component.cxf.CxfConstants;
 import org.apache.camel.component.cxf.CxfEndpoint;
 import org.apache.camel.component.cxf.CxfHeaderFilterStrategy;
+import org.apache.camel.component.cxf.CxfPayload;
 import org.apache.camel.component.cxf.MessageHeaderFilter;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.cxf.binding.soap.SoapHeader;
@@ -51,6 +53,7 @@
 import org.apache.cxf.headers.Header.Direction;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.outofband.header.OutofBandHeader;
@@ -349,6 +352,43 @@
         assertTrue("Expected in band response header *not* to propagate but did",
                    header.value == null);
     }
+    
+    @Test
+    public void testInoutHeaderCXFClientNoServiceClassNoRelay() throws Exception {
+        QName qname = QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SOAPHeaderInfo");
+        String uri = "cxf:bean:routerNoRelayNoServiceClassEndpoint?headerFilterStrategy=#dropAllMessageHeadersStrategy";
+        String requestHeader = "<ns2:SOAPHeaderInfo xmlns:ns2=\"http://apache.org/camel/"

+            + "component/cxf/soap/headers\"><originator>CxfSoapHeaderRoutePropagationTest.testInOutHeader
Requestor" 
+            + "</originator><message>Invoking CxfSoapHeaderRoutePropagationTest.testInOutHeader()
Request" 
+            +   "</message></ns2:SOAPHeaderInfo>";
+        String requestBody = "<ns2:inoutHeader xmlns:ns2=\"http://apache.org/camel/component/cxf/soap/headers\">"

+            + "<requestType>CXF user</requestType></ns2:inoutHeader>";
+        List<Element> elements = new ArrayList<Element>();
+        elements.add(DOMUtils.readXml(new StringReader(requestBody)).getDocumentElement());
+        final List<SoapHeader> headers = new ArrayList<SoapHeader>();
+        headers.add(new SoapHeader(qname,
+                                   DOMUtils.readXml(new StringReader(requestHeader)).getDocumentElement()));
+        final CxfPayload<SoapHeader> cxfPayload = new CxfPayload<SoapHeader>(headers,
elements);
+        
+        Exchange exchange = template.send(uri, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody(cxfPayload);
+                exchange.getIn().setHeader(Header.HEADER_LIST, headers);
+            }
+
+        });
+
+        CxfPayload<?> out = exchange.getOut().getBody(CxfPayload.class);
+        assertEquals(1, out.getBody().size());
+
+        assertEquals(0, out.getHeaders().size());
+        
+        String response = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
+            + "<ns2:inoutHeaderResponse xmlns:ns2=\"http://apache.org/camel/" 
+            + "component/cxf/soap/headers\"><responseType>pass</responseType>"

+            + "</ns2:inoutHeaderResponse>";
+        assertEquals(response, XMLUtils.toString(out.getBody().get(0)));
+    }
 
     @Test
     public void testMessageHeadersRelaysSpringContext() throws Exception {

Modified: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml?rev=827794&r1=827793&r2=827794&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml
(original)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml
Tue Oct 20 21:10:08 2009
@@ -46,7 +46,7 @@
 		    <ref bean="logInbound"/>
 		</cxf:inInterceptors>	
 		<cxf:outInterceptors>
-		    <ref bean="loggingOutInterceptor"/>
+		    <ref bean="logOutbound"/>
 		</cxf:outInterceptors>	
   </cxf:cxfEndpoint> 
   
@@ -62,6 +62,17 @@
           <entry key="dataFormat" value="PAYLOAD"/>
       </cxf:properties>    
   </cxf:cxfEndpoint> 
+  
+    <cxf:cxfEndpoint id="routerNoRelayNoServiceClassEndpoint" 
+                   address="http://localhost:7002/HeaderService"
+                   endpointName="tns:SoapPortNoRelay"
+                   serviceName="tns:HeaderService"
+                   wsdlURL="soap_header.wsdl"
+                   xmlns:tns="http://apache.org/camel/component/cxf/soap/headers">   
          
+      <cxf:properties>
+          <entry key="dataFormat" value="PAYLOAD"/>
+      </cxf:properties>    
+  </cxf:cxfEndpoint> 
 
   <cxf:cxfEndpoint id="serviceRelayEndpoint" 
                    address="http://localhost:9091/HeaderService/"
@@ -83,7 +94,7 @@
 		    <ref bean="logInbound"/>
 		</cxf:inInterceptors>	
         <cxf:outInterceptors>
-		    <ref bean="loggingOutInterceptor"/>
+		    <ref bean="logOutbound"/>
 		</cxf:outInterceptors>	
   </cxf:cxfEndpoint>  
 
@@ -100,6 +111,17 @@
       </cxf:properties>        
   </cxf:cxfEndpoint>
   
+    <cxf:cxfEndpoint id="serviceNoRelayNoServiceClassEndpoint" 
+                   address="http://localhost:7070/HeaderService/"
+                   endpointName="tns:SoapPortNoRelay"
+                   serviceName="tns:HeaderService"
+                   wsdlURL="soap_header.wsdl"
+                   xmlns:tns="http://apache.org/camel/component/cxf/soap/headers">
+      <cxf:properties>
+          <entry key="dataFormat" value="PAYLOAD"/>
+      </cxf:properties>        
+  </cxf:cxfEndpoint>
+  
   <cxf:cxfEndpoint id="serviceExtraRelays" 
                    address="http://localhost:6060/HeaderService/"
                    serviceClass="org.apache.camel.component.cxf.soap.headers.HeaderTester"
@@ -163,6 +185,11 @@
       <!-- END SNIPPET: noRelayRoute -->
       
       <route>
+          <from uri="cxf:bean:routerNoRelayNoServiceClassEndpoint?headerFilterStrategy=#dropAllMessageHeadersStrategy"/>
         
+          <to uri="cxf:bean:serviceNoRelayNoServiceClassEndpoint?headerFilterStrategy=#dropAllMessageHeadersStrategy"/>
+      </route>
+      
+      <route>
           <from uri="cxf:bean:serviceExtraRelays?headerFilterStrategy=#customMessageFilterStrategy"/>
           <to uri="mock:result"/>
       </route>
@@ -170,6 +197,6 @@
     
     <bean id="InsertRequestOutHeaderProcessor" class="org.apache.camel.component.cxf.soap.headers.CxfMessageHeadersRelayTest$InsertRequestOutHeaderProcessor"
/>
     <bean id="InsertResponseOutHeaderProcessor" class="org.apache.camel.component.cxf.soap.headers.CxfMessageHeadersRelayTest$InsertResponseOutHeaderProcessor"
/>
-    <bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"
/>         
+    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
        
     <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
 </beans>



Mime
View raw message