You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/10/17 09:47:20 UTC

[2/2] camel git commit: CAMEL-9217: Relax uri validation check so & with ? is allowed

CAMEL-9217: Relax uri validation check so & with ? is allowed


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/63478ef2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/63478ef2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/63478ef2

Branch: refs/heads/camel-2.16.x
Commit: 63478ef2176b93da9d8609c4f22fc3906633225a
Parents: eb9a9e3
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 17 09:49:16 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 17 09:49:31 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultComponent.java |  6 ---
 .../file/FileConsumerPathWithAmpersandTest.java | 51 ++++++++++++++++++++
 .../impl/DefaultComponentValidateURITest.java   |  9 ----
 3 files changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/63478ef2/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
index c7ab7ff..c6492ea 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
@@ -196,12 +196,6 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone
      * @throws ResolveEndpointFailedException should be thrown if the URI validation failed
      */
     protected void validateURI(String uri, String path, Map<String, Object> parameters) {
-        // check for uri containing & but no ? marker
-        if (uri.contains("&") && !uri.contains("?")) {
-            throw new ResolveEndpointFailedException(uri, "Invalid uri syntax: no ? marker however the uri "
-                + "has & parameter separators. Check the uri if its missing a ? marker.");
-        }
-
         // check for uri containing double && markers without include by RAW
         if (uri.contains("&&")) {
             Pattern pattern = Pattern.compile("RAW(.*&&.*)");

http://git-wip-us.apache.org/repos/asf/camel/blob/63478ef2/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPathWithAmpersandTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPathWithAmpersandTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPathWithAmpersandTest.java
new file mode 100644
index 0000000..65bca57
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPathWithAmpersandTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+public class FileConsumerPathWithAmpersandTest extends ContextTestSupport {
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("target/file&stuff");
+        super.setUp();
+    }
+
+    public void testPathWithAmpersand() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
+        template.sendBodyAndHeader("file://target/file&stuff", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file://target/file&stuff?delete=true&initialDelay=0&delay=10").convertBodyTo(String.class).to("mock:result");
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/63478ef2/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentValidateURITest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentValidateURITest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentValidateURITest.java
index 950fa6f..14c30af 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentValidateURITest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentValidateURITest.java
@@ -30,15 +30,6 @@ public class DefaultComponentValidateURITest extends ContextTestSupport {
         assertNotNull("Should have created an endpoint", endpoint);
     }
 
-    public void testNoQuestionMarker() throws Exception {
-        try {
-            context.getEndpoint("timer://foo&fixedRate=true&delay=0&period=500");
-            fail("Should have thrown ResolveEndpointFailedException");
-        } catch (ResolveEndpointFailedException e) {
-            // ok
-        }
-    }
-
     public void testUnknownParameter() throws Exception {
         try {
             context.getEndpoint("timer://foo?delay=250&unknown=1&period=500");