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

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

commit d300a581370b887838ac8194a814501c8310ac92
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Fri Nov 30 11:26:32 2018 +0100

    fix pr review findings
---
 .../camel/component/knative/KnativeEnvironment.java     | 11 ++++++-----
 .../camel/component/knative/KnativeComponentTest.java   | 17 +++++++++++++++++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git 
a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java
 
b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java
index e133f4b..efef0ca 100644
--- 
a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java
+++ 
b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java
@@ -97,13 +97,14 @@ public class KnativeEnvironment {
 
     public KnativeServiceDefinition lookupServiceOrDefault(Knative.Type type, 
String name) {
         return lookupService(type, name).orElseGet(() -> {
-            final String contextPath = StringHelper.after(name, "/");
-            final String serviceName = (contextPath == null) ? name : 
StringHelper.before(name, "/");
-            final Map<String, String> meta = new HashMap<>();
+            String contextPath = StringHelper.after(name, "/");
+            String serviceName = (contextPath == null) ? name : 
StringHelper.before(name, "/");
+            Map<String, String> meta = new HashMap<>();
 
-            // namespace derived by default from env var
-            meta.put(ServiceDefinition.SERVICE_META_ZONE, "{{env:NAMESPACE}}");
+            if (type == Knative.Type.channel && 
!serviceName.endsWith(".channel")) {
+                serviceName += "-channel";
 
+            }
             if (contextPath != null) {
                 meta.put(ServiceDefinition.SERVICE_META_PATH, "/" + 
contextPath);
             }
diff --git 
a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java
 
b/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java
index 571e368..56f4df3 100644
--- 
a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java
+++ 
b/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java
@@ -283,6 +283,23 @@ public class KnativeComponentTest {
         assertThat(e1.getService()).hasFieldOrPropertyWithValue("path", 
"/my/path");
         assertThat(e1.getEndpoint()).isInstanceOf(NettyEndpoint.class);
         
assertThat(e1.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", 
"http://myEndpoint/my/path";);
+
+        //
+        // Endpoint with context path overridden by endpoint uri
+        //
+
+        KnativeEndpoint e2 = 
context.getEndpoint("knative:channel/myChannel/another/path", 
KnativeEndpoint.class);
+
+        assertThat(e2).isNotNull();
+        assertThat(e2.getService()).isNotNull();
+        assertThat(e2.getService()).hasFieldOrPropertyWithValue("name", 
"myChannel-channel");
+        assertThat(e2.getService()).hasFieldOrPropertyWithValue("type", 
Knative.Type.channel);
+        assertThat(e2.getService()).hasFieldOrPropertyWithValue("protocol", 
Knative.Protocol.http);
+        assertThat(e2.getService()).hasFieldOrPropertyWithValue("path", 
"/another/path");
+        assertThat(e2.getEndpoint()).isInstanceOf(NettyEndpoint.class);
+        
assertThat(e2.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", 
"http://myChannel-channel/another/path";);
+
+
     }
 
     @Test

Reply via email to