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 2010/04/29 09:54:32 UTC
svn commit: r939224 - in /camel/trunk/components:
camel-http/src/main/java/org/apache/camel/component/http/
camel-jetty/src/test/java/org/apache/camel/component/jetty/
Author: ningjiang
Date: Thu Apr 29 07:54:32 2010
New Revision: 939224
URL: http://svn.apache.org/viewvc?rev=939224&view=rev
Log:
CAMEL-2679 Fixed the unit tests failures which are caused by tthe recent change of DefaultHttpBinding
Modified:
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=939224&r1=939223&r2=939224&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java Thu Apr 29 07:54:32 2010
@@ -310,6 +310,10 @@ public class DefaultHttpBinding implemen
} else {
// otherwise use input stream and we need to cache it first
InputStream is = HttpConverter.toInputStream(request);
+ if (is == null) {
+ return is;
+ }
+ // convert the input stream to StreamCache
try {
CachedOutputStream cos = new CachedOutputStream(httpMessage.getExchange());
IOHelper.copy(is, cos);
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java?rev=939224&r1=939223&r2=939224&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java Thu Apr 29 07:54:32 2010
@@ -78,7 +78,9 @@ public class HttpConverterTest extends C
ServletInputStream sis = HttpConverter.toServletInputStream(msg);
assertNotNull(sis);
- String s = exchange.getContext().getTypeConverter().convertTo(String.class, sis);
+ // The ServletInputStream should be cached and you can't read message here
+ assertTrue(sis.available() == 0);
+ String s = msg.getBody(String.class);
assertEquals("Hello World", s);
}
@@ -101,7 +103,7 @@ public class HttpConverterTest extends C
public void process(Exchange exchange) throws Exception {
HttpMessage msg = exchange.getIn(HttpMessage.class);
- InputStream sis = HttpConverter.toInputStream(msg);
+ InputStream sis = msg.getBody(InputStream.class);
assertNotNull(sis);
String s = exchange.getContext().getTypeConverter().convertTo(String.class, sis);
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java?rev=939224&r1=939223&r2=939224&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java Thu Apr 29 07:54:32 2010
@@ -182,11 +182,11 @@ public class HttpRouteTest extends Camel
Processor procParameters = new Processor() {
public void process(Exchange exchange) throws Exception {
- HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
- String value = req.getParameter("request");
- String requestValue = exchange.getIn().getHeader("request", String.class);
+ // As the request input stream is cached by DefaultHttpBinding,
+ // HttpServletRequest can't get the parameters of post message
+ String value = exchange.getIn().getHeader("request", String.class);
if (value != null) {
- assertEquals("We should get the same request header value from message", value, requestValue);
+ assertNotNull("The value of the parameter should not be null", value);
exchange.getOut().setBody(value);
} else {
exchange.getOut().setBody("Can't get a right parameter");