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/12/28 10:31:52 UTC
svn commit: r1225149 - in /camel/branches/camel-2.7.x: ./
components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
Author: ningjiang
Date: Wed Dec 28 09:31:52 2011
New Revision: 1225149
URL: http://svn.apache.org/viewvc?rev=1225149&view=rev
Log:
Merged revisions 1225143 via svnmerge from
https://svn.apache.org/repos/asf/camel/branches/camel-2.8.x
................
r1225143 | ningjiang | 2011-12-28 16:33:33 +0800 (Wed, 28 Dec 2011) | 9 lines
Merged revisions 1225078 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r1225078 | ningjiang | 2011-12-28 11:06:36 +0800 (Wed, 28 Dec 2011) | 1 line
CAMEL-4835 camel-cxfrs should support to look up the CXF message from the camel message header
........
................
Modified:
camel/branches/camel-2.7.x/ (props changed)
camel/branches/camel-2.7.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
camel/branches/camel-2.7.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 28 09:31:52 2011
@@ -1,2 +1,2 @@
-/camel/branches/camel-2.8.x:1170965,1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226,1189704,1199138,1199732,1199766,1199807,1200867,1201638-1201639,1202171,1202222,1202662,1204355,1205709,1208933,1210779,1210916,1211366,1211774,1211814,1213201,1213531,1214058,1214648,1220717,1221574,1222020,1222077,1224676,1225137
-/camel/trunk:1146608,1146903,1147216,1170956,1171396,1174565,1175321,1176274,1176781-1176782,1177394,1177945,1177948,1180597,1187221,1189693,1199137,1199703,1199739,1199804,1200861,1201623,1201637,1202167,1202215,1202659,1204338,1205412,1208930,1210771,1210830,1211363,1211773,1211811,1213197,1213219,1213526,1214639,1220711,1221566,1222006,1222066,1224674,1225077
+/camel/branches/camel-2.8.x:1170965,1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226,1189704,1199138,1199732,1199766,1199807,1200867,1201638-1201639,1202171,1202222,1202662,1204355,1205709,1208933,1210779,1210916,1211366,1211774,1211814,1213201,1213531,1214058,1214648,1220717,1221574,1222020,1222077,1224676,1225137,1225143
+/camel/trunk:1146608,1146903,1147216,1170956,1171396,1174565,1175321,1176274,1176781-1176782,1177394,1177945,1177948,1180597,1187221,1189693,1199137,1199703,1199739,1199804,1200861,1201623,1201637,1202167,1202215,1202659,1204338,1205412,1208930,1210771,1210830,1211363,1211773,1211811,1213197,1213219,1213526,1214639,1220711,1221566,1222006,1222066,1224674,1225077-1225078
Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.7.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java?rev=1225149&r1=1225148&r2=1225149&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java (original)
+++ camel/branches/camel-2.7.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java Wed Dec 28 09:31:52 2011
@@ -120,6 +120,8 @@ public class DefaultCxfRsBinding impleme
camelMessage.setHeader(CxfConstants.OPERATION_NAME, method.getName());
+ camelMessage.setHeader(CxfConstants.CAMEL_CXF_MESSAGE, cxfMessage);
+
camelMessage.setBody(new MessageContentsList(paramArray));
}
Modified: camel/branches/camel-2.7.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java?rev=1225149&r1=1225148&r2=1225149&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java (original)
+++ camel/branches/camel-2.7.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java Wed Dec 28 09:31:52 2011
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import javax.servlet.ServletRequest;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
@@ -36,6 +37,7 @@ import org.apache.camel.component.cxf.ut
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
@@ -71,6 +73,21 @@ public class CxfRsConsumerTest extends C
// We just put the response Object into the out message body
exchange.getOut().setBody(customer);
} else {
+ if ("/customerservice/customers/400".equals(path)) {
+ // We return the remote client IP address this time
+ org.apache.cxf.message.Message cxfMessage = inMessage.getHeader(CxfConstants.CAMEL_CXF_MESSAGE, org.apache.cxf.message.Message.class);
+ ServletRequest request = (ServletRequest) cxfMessage.get("HTTP.REQUEST");
+ String remoteAddress = request.getRemoteAddr();
+ Response r = Response.status(200).entity("The remoteAddress is " + remoteAddress).build();
+ exchange.getOut().setBody(r);
+ return;
+ }
+ if ("/customerservice/customers/123".equals(path)) {
+ // send a customer response back
+ Response r = Response.status(200).entity("customer response back!").build();
+ exchange.getOut().setBody(r);
+ return;
+ }
if ("/customerservice/customers/456".equals(path)) {
Response r = Response.status(404).entity("Can't found the customer with uri " + path).build();
throw new WebApplicationException(r);
@@ -97,14 +114,30 @@ public class CxfRsConsumerTest extends C
};
}
// END SNIPPET: example
+
+ private void invokeGetCustomer(String uri, String expect) throws Exception {
+ HttpGet get = new HttpGet(uri);
+ get.addHeader("Accept" , "application/json");
+ HttpClient httpclient = new DefaultHttpClient();
+
+ try {
+ HttpResponse response = httpclient.execute(get);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals(expect,
+ EntityUtils.toString(response.getEntity()));
+ } finally {
+ httpclient.getConnectionManager().shutdown();
+ }
+ }
@Test
public void testGetCustomer() throws Exception {
- URL url = new URL("http://localhost:9000/rest/customerservice/customers/126");
-
- InputStream in = url.openStream();
- assertEquals("{\"Customer\":{\"id\":126,\"name\":\"Willem\"}}", CxfUtils.getStringFromInputStream(in));
-
+ invokeGetCustomer("http://localhost:9000/rest/customerservice/customers/126",
+ "{\"Customer\":{\"id\":126,\"name\":\"Willem\"}}");
+ invokeGetCustomer("http://localhost:9000/rest/customerservice/customers/123",
+ "customer response back!");
+ invokeGetCustomer("http://localhost:9000/rest/customerservice/customers/400",
+ "The remoteAddress is 127.0.0.1");
}
@Test