You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/09/25 08:18:48 UTC

[camel-k-runtime] branch master updated (f0db6d0 -> 307d7fc)

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

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


    from f0db6d0  Merge pull request #139 from lburgazzoli/yaml-route
     new 40b645e  Add the error log when setting component property failed
     new 361370d  Removed the value from log as Luca suggested
     new d7a758b  Added test case of wrong component property and method setting
     new a819af0  Added the Apache License header
     new 307d7fc  Removed the log and polish the test cases

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../loader/groovy/dsl/ComponentConfiguration.groovy  |  5 ++++-
 .../loader/groovy/dsl/ComponentsConfiguration.groovy |  9 +++++----
 .../camel/k/loader/groovy/dsl/IntegrationTest.groovy | 20 ++++++++++++++++++++
 ...with-component-wrong-method-configuration.groovy} | 13 +++++++------
 ...th-component-wrong-property-configuration.groovy} | 13 +++++++++----
 5 files changed, 45 insertions(+), 15 deletions(-)
 copy camel-k-loader-groovy/src/test/resources/{routes-with-bindings.groovy => routes-with-component-wrong-method-configuration.groovy} (81%)
 copy camel-k-loader-groovy/src/test/resources/{routes-with-error-handler.groovy => routes-with-component-wrong-property-configuration.groovy} (84%)


[camel-k-runtime] 04/05: Added the Apache License header

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a819af0de45a1d895afdf0517a70588e882bc85e
Author: Willem Jiang <wi...@gmail.com>
AuthorDate: Sun Sep 15 20:06:33 2019 +0800

    Added the Apache License header
---
 ...utes-with-component-wrong-method-configuration.groovy | 16 ++++++++++++++++
 ...es-with-component-wrong-property-configuration.groovy | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-method-configuration.groovy b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-method-configuration.groovy
index 3242370..f2b4fb6 100644
--- a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-method-configuration.groovy
+++ b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-method-configuration.groovy
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
 import org.apache.camel.component.seda.SedaComponent
 
 context {
diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
index 0efb194..7dfa916 100644
--- a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
+++ b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
 import org.apache.camel.component.seda.SedaComponent
 
 context {


[camel-k-runtime] 03/05: Added test case of wrong component property and method setting

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d7a758bee4bb9e5def658f815b5a2e74de5d0847
Author: Willem Jiang <wi...@gmail.com>
AuthorDate: Sun Sep 15 19:57:29 2019 +0800

    Added test case of wrong component property and method setting
---
 .../loader/groovy/dsl/ComponentsConfiguration.groovy |  6 ++++--
 .../camel/k/loader/groovy/dsl/IntegrationTest.groovy | 20 ++++++++++++++++++++
 ...-with-component-wrong-method-configuration.groovy | 13 +++++++++++++
 ...ith-component-wrong-property-configuration.groovy | 13 +++++++++++++
 4 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy
index 65698ea..a5f67d7 100644
--- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy
+++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy
@@ -18,6 +18,7 @@ package org.apache.camel.k.loader.groovy.dsl
 
 import org.apache.camel.CamelContext
 import org.apache.camel.Component
+import org.apache.camel.support.PropertyBindingSupport
 
 class ComponentsConfiguration {
     private final CamelContext context
@@ -48,10 +49,10 @@ class ComponentsConfiguration {
         }
 
         if (type.isAssignableFrom(component.class)) {
-            callable.resolveStrategy = Closure.DELEGATE_FIRST
+            // Just make sure the closure context is belong to component
+            callable.resolveStrategy = Closure.DELEGATE_ONLY
             callable.delegate = new ComponentConfiguration(component)
             callable.call()
-
             return
         }
 
@@ -81,4 +82,5 @@ class ComponentsConfiguration {
 
         throw new MissingMethodException(name, this, args)
     }
+
 }
diff --git a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationTest.groovy b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationTest.groovy
index a6f5e55..d95745b 100644
--- a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationTest.groovy
+++ b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationTest.groovy
@@ -22,6 +22,7 @@ import org.apache.camel.component.log.LogComponent
 import org.apache.camel.component.seda.SedaComponent
 import org.apache.camel.impl.DefaultCamelContext
 import org.apache.camel.k.Runtime
+import org.apache.camel.k.listener.RoutesConfigurer
 import org.apache.camel.model.ModelCamelContext
 import org.apache.camel.processor.FatalFallbackErrorHandler
 import org.apache.camel.processor.SendProcessor
@@ -31,6 +32,7 @@ import org.apache.camel.support.DefaultHeaderFilterStrategy
 import spock.lang.Specification
 
 import javax.sql.DataSource
+import java.util.concurrent.atomic.AtomicBoolean
 
 import static org.apache.camel.k.listener.RoutesConfigurer.forRoutes
 
@@ -106,6 +108,24 @@ class IntegrationTest extends Specification {
             }
     }
 
+    def "load integration with component error property configuration"()  {
+        when:
+            forRoutes('classpath:routes-with-component-wrong-property-configuration.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
+        then:
+            def e =  thrown org.apache.camel.RuntimeCamelException
+            assert e.message.contains("No such property: queueNumber for class: org.apache.camel.component.seda.SedaComponent")
+
+    }
+
+    def "load integration with component error method configuration"()  {
+        when:
+        forRoutes('classpath:routes-with-component-wrong-method-configuration.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
+        then:
+        def e =  thrown org.apache.camel.RuntimeCamelException
+        assert e.message.contains("No signature of method: org.apache.camel.component.seda.SedaComponent.queueNumber()")
+
+    }
+
     def "load integration with error handler"()  {
         when:
             forRoutes('classpath:routes-with-error-handler.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-method-configuration.groovy b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-method-configuration.groovy
new file mode 100644
index 0000000..3242370
--- /dev/null
+++ b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-method-configuration.groovy
@@ -0,0 +1,13 @@
+import org.apache.camel.component.seda.SedaComponent
+
+context {
+    components {
+        mySeda(SedaComponent) {
+            // a wrong method name
+            queueNumber 33
+        }
+    }
+}
+
+from('timer:tick')
+        .to('log:info')
diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
new file mode 100644
index 0000000..0efb194
--- /dev/null
+++ b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
@@ -0,0 +1,13 @@
+import org.apache.camel.component.seda.SedaComponent
+
+context {
+    components {
+        mySeda(SedaComponent) {
+            // a wrong property name
+            queueNumber = 33
+        }
+    }
+}
+
+from('timer:tick')
+        .to('log:info')


[camel-k-runtime] 01/05: Add the error log when setting component property failed

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 40b645e782d67dad35ca11a3d6126aca89ceceba
Author: Willem Jiang <wi...@gmail.com>
AuthorDate: Sat Sep 7 17:02:06 2019 +0800

    Add the error log when setting component property failed
---
 .../apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
index 8380c60..8799d8b 100644
--- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
+++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
@@ -18,8 +18,11 @@ package org.apache.camel.k.loader.groovy.dsl
 
 import org.apache.camel.ExtendedCamelContext
 import org.apache.camel.support.PropertyBindingSupport
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
 
 class ComponentConfiguration {
+    private static final Logger LOG = LoggerFactory.getLogger(ComponentConfiguration.class);
     private final org.apache.camel.Component component
 
     ComponentConfiguration(org.apache.camel.Component component) {
@@ -49,13 +52,15 @@ class ComponentConfiguration {
         }
 
         if (!PropertyBindingSupport.build().withCamelContext(component.camelContext).withTarget(component).withProperty(name, value).bind()) {
+            LOG.error("Cannot set the component {} property {} with {}", component.class.getName(), name, value)
             throw new MissingMethodException(name, this.component.class, args as Object[])
         }
     }
 
     def propertyMissing(String name, value) {
         if (!PropertyBindingSupport.build().withCamelContext(component.camelContext).withTarget(component).withProperty(name, value).bind()) {
-            throw new MissingMethodException(name, this.component.class, value)
+            LOG.error("Cannot set the component {} property {} with {}", component.class.getName(), name, value)
+            throw new MissingPropertyException(name, this.component.class)
         }
     }
 


[camel-k-runtime] 02/05: Removed the value from log as Luca suggested

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 361370de2449fca9db182251fa6216cb97b566c2
Author: Willem Jiang <wi...@gmail.com>
AuthorDate: Sun Sep 8 09:20:34 2019 +0800

    Removed the value from log as Luca suggested
---
 .../apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
index 8799d8b..63b4fbf 100644
--- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
+++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
@@ -52,14 +52,14 @@ class ComponentConfiguration {
         }
 
         if (!PropertyBindingSupport.build().withCamelContext(component.camelContext).withTarget(component).withProperty(name, value).bind()) {
-            LOG.error("Cannot set the component {} property {} with {}", component.class.getName(), name, value)
+            LOG.error("Cannot set the component {} property {}", component.class.getName(), name)
             throw new MissingMethodException(name, this.component.class, args as Object[])
         }
     }
 
     def propertyMissing(String name, value) {
         if (!PropertyBindingSupport.build().withCamelContext(component.camelContext).withTarget(component).withProperty(name, value).bind()) {
-            LOG.error("Cannot set the component {} property {} with {}", component.class.getName(), name, value)
+            LOG.error("Cannot set the component {} property {}", component.class.getName(), name)
             throw new MissingPropertyException(name, this.component.class)
         }
     }


[camel-k-runtime] 05/05: Removed the log and polish the test cases

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 307d7fc766401d9aa7ceed2397431c9ed9a0e82e
Author: Willem Jiang <wi...@gmail.com>
AuthorDate: Mon Sep 23 16:56:52 2019 +0800

    Removed the log and polish the test cases
---
 .../apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy   | 2 --
 .../apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy  | 5 ++---
 .../routes-with-component-wrong-property-configuration.groovy        | 3 +--
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
index 63b4fbf..dd1432c 100644
--- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
+++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentConfiguration.groovy
@@ -52,14 +52,12 @@ class ComponentConfiguration {
         }
 
         if (!PropertyBindingSupport.build().withCamelContext(component.camelContext).withTarget(component).withProperty(name, value).bind()) {
-            LOG.error("Cannot set the component {} property {}", component.class.getName(), name)
             throw new MissingMethodException(name, this.component.class, args as Object[])
         }
     }
 
     def propertyMissing(String name, value) {
         if (!PropertyBindingSupport.build().withCamelContext(component.camelContext).withTarget(component).withProperty(name, value).bind()) {
-            LOG.error("Cannot set the component {} property {}", component.class.getName(), name)
             throw new MissingPropertyException(name, this.component.class)
         }
     }
diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy
index a5f67d7..4a5dff3 100644
--- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy
+++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/ComponentsConfiguration.groovy
@@ -18,7 +18,6 @@ package org.apache.camel.k.loader.groovy.dsl
 
 import org.apache.camel.CamelContext
 import org.apache.camel.Component
-import org.apache.camel.support.PropertyBindingSupport
 
 class ComponentsConfiguration {
     private final CamelContext context
@@ -29,8 +28,8 @@ class ComponentsConfiguration {
 
     def component(String name, @DelegatesTo(ComponentConfiguration) Closure<?> callable) {
         def component = context.getComponent(name, true, false)
-
-        callable.resolveStrategy = Closure.DELEGATE_FIRST
+        // Just make sure the closure context is belong to component
+        callable.resolveStrategy = Closure.DELEGATE_ONLY
         callable.delegate = new ComponentConfiguration(component)
         callable.call()
     }
diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
index 7dfa916..07a7422 100644
--- a/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
+++ b/camel-k-loader-groovy/src/test/resources/routes-with-component-wrong-property-configuration.groovy
@@ -14,11 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import org.apache.camel.component.seda.SedaComponent
 
 context {
     components {
-        mySeda(SedaComponent) {
+        seda {
             // a wrong property name
             queueNumber = 33
         }