Author: davsclaus
Date: Thu Mar 14 10:10:37 2013
New Revision: 1456381
URL: http://svn.apache.org/r1456381
Log:
Added test based on user forum issue
Added:
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeEncodedPathTest.java
- copied, changed from r1456345,
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java
Copied:
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeEncodedPathTest.java
(from r1456345,
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java)
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeEncodedPathTest.java?p2=camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeEncodedPathTest.java&p1=camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java&r1=1456345&r2=1456381&rev=1456381&view=diff
==============================================================================
---
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java
(original)
+++
camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeEncodedPathTest.java
Thu Mar 14 10:10:37 2013
@@ -20,30 +20,19 @@ import java.io.ByteArrayInputStream;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
-public class HttpBridgeRouteTest extends BaseJettyTest {
+public class HttpBridgeEncodedPathTest extends BaseJettyTest {
private int port1;
private int port2;
@Test
public void testHttpClient() throws Exception {
- String response = template.requestBodyAndHeader("http://localhost:" +
port2 + "/test/hello",
- new ByteArrayInputStream("This is a test".getBytes()),
"Content-Type", "application/xml", String.class);
- assertEquals("Get a wrong response", "/", response);
-
- response = template.requestBody("http://localhost:" + port1 +
"/hello/world", "hello", String.class);
- assertEquals("Get a wrong response", "/hello/world", response);
-
- try {
- template.requestBody("http://localhost:" + port2 + "/hello/world",
"hello", String.class);
- fail("Expect exception here!");
- } catch (Exception ex) {
- assertTrue("We should get a RuntimeCamelException", ex instanceof
RuntimeCamelException);
- }
+ String response = template.requestBodyAndHeader("http://localhost:" +
port2 + "/test/hello?param1=%2B447777111222",
+ new ByteArrayInputStream("This is a test".getBytes()),
"Content-Type", "text/plain", String.class);
+ assertEquals("Get a wrong response", "param1=+447777111222", response);
}
protected RouteBuilder createRouteBuilder() throws Exception {
@@ -56,9 +45,13 @@ public class HttpBridgeRouteTest extends
Processor serviceProc = new Processor() {
public void process(Exchange exchange) throws Exception {
- // get the request URL and copy it to the request body
- String uri =
exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
- exchange.getOut().setBody(uri);
+ // %2B becomes decoded to a space
+ assertEquals(" 447777111222",
exchange.getIn().getHeader("param1"));
+ // and in the http query %20 becomes a + sign
+ assertEquals("param1=+447777111222",
exchange.getIn().getHeader(Exchange.HTTP_QUERY));
+
+ // send back the query
+
exchange.getOut().setBody(exchange.getIn().getHeader(Exchange.HTTP_QUERY));
}
};
from("jetty:http://localhost:" + port2 + "/test/hello")