Author: ningjiang
Date: Thu Nov 27 19:43:33 2008
New Revision: 721331
URL: http://svn.apache.org/viewvc?rev=721331&view=rev
Log:
CAMEL-1124 support to setting the response code in camel-cxf component
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
(with props)
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml
(with props)
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml
(with props)
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java?rev=721331&r1=721330&r2=721331&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
Thu Nov 27 19:43:33 2008
@@ -66,7 +66,8 @@
if
(CamelTransportConstants.CONTENT_TYPE.equals(entry.getKey())) {
message.put(Message.CONTENT_TYPE, entry.getValue());
} else if (Client.REQUEST_CONTEXT.equals(entry.getKey())
- || Client.RESPONSE_CONTEXT.equals(entry.getKey()))
{
+ || Client.RESPONSE_CONTEXT.equals(entry.getKey())
+ || Message.RESPONSE_CODE.equals(entry.getKey())) {
message.put(entry.getKey(), entry.getValue());
} else {
List<String> listValue = new ArrayList<String>();
Modified:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java?rev=721331&r1=721330&r2=721331&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java
Thu Nov 27 19:43:33 2008
@@ -16,6 +16,17 @@
*/
package org.apache.camel.component.cxf;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
@@ -25,6 +36,7 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.commons.io.IOUtils;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.binding.soap.SoapFault;
@@ -101,6 +113,31 @@
}
}
+
+ public void testInvokingServiceFromHTTPURL() throws Exception {
+ URL url = new URL(ROUTER_ADDRESS);
+ URLConnection urlConnection = url.openConnection();
+ urlConnection.setDoInput(true);
+ urlConnection.setDoOutput(true);
+ urlConnection.setUseCaches(false);
+ urlConnection.setRequestProperty("Content-Type", "application/xml");
+
+ // Send POST data
+ OutputStream out = urlConnection.getOutputStream();
+ // copy the message out
+ InputStream is =
this.getClass().getResourceAsStream("SimpleSoapRequest.xml");
+ IOUtils.copy(is, out);
+ out.flush();
+ is.close();
+ // check the response code
+ try {
+ urlConnection.getInputStream();
+ fail("We except an IOException here");
+ } catch (IOException exception) {
+ assertTrue(exception.getMessage().contains("500"));
+ }
+
+ }
}
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java?rev=721331&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
Thu Nov 27 19:43:33 2008
@@ -0,0 +1,42 @@
+/**
+ * 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 org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class CxfMessageStreamExceptionTest extends
CxfMessageCustomizedExceptionTest {
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from(routerEndpointURI).process(new Processor() {
+
+ public void process(Exchange exchange) throws Exception {
+ Message out = exchange.getOut();
+
out.setBody(this.getClass().getResourceAsStream("SoapFaultMessage.xml"));
+ // set the response code here
+
out.setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
+ }
+
+ });
+ }
+ };
+ }
+}
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml?rev=721331&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml
Thu Nov 27 19:43:33 2008
@@ -0,0 +1,26 @@
+<?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.
+-->
+<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>
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SimpleSoapRequest.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml?rev=721331&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml
Thu Nov 27 19:43:33 2008
@@ -0,0 +1,28 @@
+<?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.
+-->
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <soap:Fault>
+ <faultcode>soap:Client</faultcode>
+ <faultstring>This is an exception test message</faultstring>
+ <detail>This is a detail text node</detail>
+ </soap:Fault>
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapFaultMessage.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml