camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-9217: Relax uri validation check so & with ? is allowed
Date Sat, 17 Oct 2015 07:47:19 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x eb9a9e332 -> 63478ef21
  refs/heads/master a3520ddd5 -> e7ac45b61


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/e7ac45b6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e7ac45b6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e7ac45b6

Branch: refs/heads/master
Commit: e7ac45b614564b33f5c5c7f8fb2c156df4f18283
Parents: a3520dd
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Oct 17 09:49:16 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Oct 17 09:49:16 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/e7ac45b6/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/e7ac45b6/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/e7ac45b6/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");


Mime
View raw message