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 de600b1 CAMEL-14859: Fix input uri for NormalizedUri (#3715)
de600b1 is described below
commit de600b1ab0aa3dc3b6041ee851ce361c72a2b875
Author: Benjamin Graf <[email protected]>
AuthorDate: Tue Apr 7 09:43:08 2020 +0200
CAMEL-14859: Fix input uri for NormalizedUri (#3715)
---
core/camel-endpointdsl/pom.xml | 5 +++
.../builder/endpoint/AbstractEndpointBuilder.java | 4 +-
.../camel/builder/endpoint/NormalizedUriTest.java | 48 ++++++++++++++++++++++
3 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/core/camel-endpointdsl/pom.xml b/core/camel-endpointdsl/pom.xml
index 163b496..e1a68ad 100644
--- a/core/camel-endpointdsl/pom.xml
+++ b/core/camel-endpointdsl/pom.xml
@@ -98,6 +98,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
diff --git
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
index f935a0a..3517f9c 100644
---
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
+++
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
@@ -85,11 +85,11 @@ public class AbstractEndpointBuilder {
params.put("hash", Integer.toHexString(remaining.hashCode()));
}
if (params.isEmpty()) {
- answer = new NormalizedUri(scheme + ":" + path);
+ answer = new NormalizedUri(scheme + "://" + path);
} else {
try {
String query = URISupport.createQueryString(params);
- answer = new NormalizedUri(scheme + ":" + path + "?" + query);
+ answer = new NormalizedUri(scheme + "://" + path + "?" +
query);
} catch (URISyntaxException e) {
throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
diff --git
a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/NormalizedUriTest.java
b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/NormalizedUriTest.java
new file mode 100644
index 0000000..bf6ad1a
--- /dev/null
+++
b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/NormalizedUriTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.builder.endpoint;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class NormalizedUriTest extends CamelTestSupport {
+
+ @EndpointInject(value = "mock:result")
+ private MockEndpoint result;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new EndpointRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from(direct("test")).to(mock("result"));
+ }
+ };
+ }
+
+ @Test
+ public void test() throws Exception {
+ template.sendBody("direct:test", null);
+ MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
+ resultEndpoint.expectedMessageCount(1);
+ assertMockEndpointsSatisfied();
+ assertEquals(result, resultEndpoint);
+ }
+}