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 2009/06/22 13:33:38 UTC
svn commit: r787206 - in /camel/trunk/components/camel-cxf/src:
main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java
Author: ningjiang
Date: Mon Jun 22 11:33:38 2009
New Revision: 787206
URL: http://svn.apache.org/viewvc?rev=787206&view=rev
Log:
CAMEL-1736 add a header filter of the message header's name with 'Camel' perfix
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java (with props)
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.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=787206&r1=787205&r2=787206&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 Mon Jun 22 11:33:38 2009
@@ -71,6 +71,8 @@
messageHeaderFiltersMap = new HashMap<String, MessageHeaderFilter>();
addToMessageHeaderFilterMap(new SoapMessageHeaderFilter());
+ // filter headers begin with "Camel" or "org.apache.camel"
+ setOutFilterPattern("(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
}
@SuppressWarnings("unchecked")
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java?rev=787206&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java Mon Jun 22 11:33:38 2009
@@ -0,0 +1,85 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.helpers.CastUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class CxfProducerProtocalHeaderTest extends CamelTestSupport {
+ private static final String RESPONSE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ + "<soap:Body><ns1:echoResponse xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
+ + "<return xmlns=\"http://cxf.component.camel.apache.org/\">echo Hello World!</return>"
+ + "</ns1:echoResponse></soap:Body></soap:Envelope>";
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("jetty:http://localhost:9008/user").process(new Processor() {
+
+ public void process(Exchange exchange) throws Exception {
+ assertNull("We should not get the this header", exchange.getOut().getHeader("CamelCxfTest"));
+ // check the headers
+ exchange.getOut().setHeader("Content-Type", "text/xml");
+ exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200);
+ // send the response back
+ exchange.getOut().setBody(RESPONSE);
+ }
+
+ });
+ }
+ };
+ }
+
+ private Exchange sendSimpleMessage(String endpointUri) {
+ Exchange exchange = template.send(endpointUri, new Processor() {
+ public void process(final Exchange exchange) {
+ final List<String> params = new ArrayList<String>();
+ params.add("Hello World!");
+ exchange.getIn().setBody(params);
+ exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
+ // Test the CxfHeaderFilterStrategy
+ exchange.getIn().setHeader("CamelCxfTest", "test");
+ }
+ });
+ return exchange;
+
+ }
+
+ @Test
+ public void testSendMessage() {
+ Exchange exchange = sendSimpleMessage("cxf://http://localhost:9008/user"
+ + "?serviceClass=org.apache.camel.component.cxf.HelloService");
+ org.apache.camel.Message out = exchange.getOut();
+ String result = out.getBody(String.class);
+ assertEquals("reply body on Camel", "echo " + "Hello World!", result);
+ }
+
+}
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date