[camel] branch master updated: CAMEL-12982: Added unit test

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-12982: Added unit test

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 09fba59  CAMEL-12982: Added unit test
09fba59 is described below

commit 09fba59e7b0e16cf7680c8d9c9913abfc97b83bf
Author: Claus Ibsen <[hidden email]>
AuthorDate: Thu Dec 6 17:41:33 2018 +0100

    CAMEL-12982: Added unit test
---
 .../issues/EndpointWithRawUriParameterTest.java    | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/camel-core/src/test/java/org/apache/camel/issues/EndpointWithRawUriParameterTest.java b/camel-core/src/test/java/org/apache/camel/issues/EndpointWithRawUriParameterTest.java
index 80b5f74..50bedf6 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/EndpointWithRawUriParameterTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/EndpointWithRawUriParameterTest.java
@@ -27,6 +27,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.impl.DefaultProducer;
@@ -140,6 +141,29 @@ public class EndpointWithRawUriParameterTest extends ContextTestSupport {
         assertEquals("++def++", lines.get(1));
     }
 
+    @Test
+    public void testRawUriParameterFail() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedHeaderReceived("username", "scott");
+        getMockEndpoint("mock:result").expectedHeaderReceived("password", "foo)+bar");
+
+        template.sendBody("direct:fail", "Hello World");
+
+        // should fail as the password has + sign which gets escaped
+        getMockEndpoint("mock:result").assertIsNotSatisfied();
+    }
+
+    @Test
+    public void testRawUriParameterOk() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedHeaderReceived("username", "scott");
+        getMockEndpoint("mock:result").expectedHeaderReceived("password", "foo)+bar");
+
+        template.sendBody("direct:ok", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -158,6 +182,14 @@ public class EndpointWithRawUriParameterTest extends ContextTestSupport {
                 from("direct:rawlines")
                     .to("mycomponent:foo?lines=RAW(++abc++)&lines=RAW(++def++)")
                     .to("mock:result");
+
+                from("direct:fail")
+                    .to("mycomponent:foo?password=foo)+bar&username=scott")
+                    .to("mock:result");
+
+                from("direct:ok")
+                    .to("mycomponent:foo?password=RAW(foo)+bar)&username=scott")
+                    .to("mock:result");
             }
         };
     }