Author: ningjiang
Date: Wed May  6 04:56:14 2009
New Revision: 772054

URL: http://svn.apache.org/viewvc?rev=772054&view=rev
Log:
CAMEL-1586 added the unit test of checking the content-type header on the wire

Modified:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java?rev=772054&r1=772053&r2=772054&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
 Wed May  6 04:56:14 2009
@@ -63,6 +63,11 @@
         getOutFilter().add(Message.PROTOCOL_HEADERS);
         getInFilter().add(Message.PROTOCOL_HEADERS);
         
+        // Since the DefaultCxfBinding deal with the content-type separately.
+        // We need to filter this header
+        getOutFilter().add("content-type");
+        getInFilter().add("content-type");
+        
         // initialize message header filter map with default SOAP filter
         messageHeaderFiltersMap = new HashMap<String, MessageHeaderFilter>();
         addToMessageHeaderFilterMap(new SoapMessageHeaderFilter());

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java?rev=772054&r1=772053&r2=772054&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
 Wed May  6 04:56:14 2009
@@ -18,6 +18,9 @@
 
 import java.util.Map;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
@@ -38,12 +41,30 @@
         result.expectedMessageCount(1);
         HelloService client = getCXFClient();
         client.echo("hello world");
-        assertMockEndpointsSatisfied();
+        assertMockEndpointsSatisfied();        
         Map context = 
(Map)result.assertExchangeReceived(0).getIn().getHeaders().get("ResponseContext");
         Map protocalHeaders = (Map) 
context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
         assertEquals("Should get the content type", 
protocalHeaders.get("content-type").toString(), "[text/xml; charset=utf-8]");
-        assertEquals("Should get the response code ", 
context.get("org.apache.cxf.message.Message.RESPONSE_CODE"), 200);
-        // get the content type directly from the message header
-        assertEquals("Should get the content type", 
result.assertExchangeReceived(0).getIn().getHeaders().get("content-type"), 
"text/xml; charset=utf-8");        
+        assertEquals("Should get the response code ", 
context.get("org.apache.cxf.message.Message.RESPONSE_CODE"), 200);        
+        assertEquals("Should get the content type", 
result.assertExchangeReceived(0).getIn().getHeaders().get("content.type"), 
"text/xml; charset=utf-8");        
+    }
+    
+    public void testTheContentTypeOnTheWire() throws Exception {
+        Exchange exchange = template.send(ROUTER_ADDRESS,  new Processor() {
+
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("<soap:Envelope 
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\";>" 
+                                         + "<soap:Body><ns1:echo 
xmlns:ns1=\"http://cxf.component.camel.apache.org/\";>"
+                                         + "<arg0 
xmlns=\"http://cxf.component.camel.apache.org/\";>hello world</arg0>"
+                                         + 
"</ns1:echo></soap:Body></soap:Envelope>");
+            }
+
+        });
+        
+        assertNotNull("We should get the content type here", 
exchange.getOut().getHeader("Content-Type"));
+        assertEquals("Get wrong content type", "text/xml; charset=utf-8", 
exchange.getOut().getHeader("Content-Type"));
+        String response = exchange.getOut().getBody(String.class);        
+        assertNotNull("Response should not be null", response);
+        assertTrue("We should get right return result", response.indexOf("echo 
hello world") > 0);
     }
 }


Reply via email to