You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/12/07 07:31:07 UTC

[camel] 01/04: CAMEL-12982: Added unit test

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

acosentino pushed a commit to branch sandbox/camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 056416636b1e22f2ec279a50c9945724e7c60277
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 6 17:41:33 2018 +0100

    CAMEL-12982: Added unit test
    
    Conflicts:
    	camel-core/src/test/java/org/apache/camel/issues/EndpointWithRawUriParameterTest.java
---
 .../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 8f3e2aa..8fa2c4f 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.support.DefaultComponent;
 import org.apache.camel.support.DefaultEndpoint;
 import org.apache.camel.support.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");
             }
         };
     }