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/03 20:17:04 UTC

[camel-k-runtime] branch master updated (a38446e -> 91e8a02)

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 a38446e  Update to Camel RC1 #134
     new 7a5d455  chore(test): remove dependencies on runtime from camel-k-loader-js
     new c50b70a  chore(test): remove dependencies on runtime from camel-k-loader-groovy
     new 31585ab  chore(test): remove dependencies on runtime from camel-k-loader-java
     new 643aa35  chore(test): remove dependencies on runtime from camel-k-runtime-health
     new b149f83  chore(test): remove dependencies on runtime from camel-k-runtime-servlet
     new 6682fcc  chore(test): remove dependencies on runtime from camel-k-loader-kotlin
     new 6339b52  chore(test): move runtime test to camel-k-runtime-main
     new 91e8a02  chore: fix CS

The 8 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:
 camel-k-loader-groovy/pom.xml                      |   5 -
 .../k/loader/groovy/dsl/IntegrationTest.groovy     | 136 +++++++++------------
 .../groovy/dsl/extension/LogExtensionTest.groovy   |  18 +--
 camel-k-loader-java/pom.xml                        |   5 -
 .../camel/k/loader/java/RoutesLoaderTest.java      |  27 ----
 camel-k-loader-js/pom.xml                          |   5 -
 .../camel/k/loader/js/dsl/IntegrationTest.java     | 128 ++++++++++---------
 camel-k-loader-kotlin/pom.xml                      |   8 +-
 .../camel/k/loader/kotlin/dsl/IntegrationTest.kt   | 124 ++++++++-----------
 .../src/main/java/org/apache/camel/k/Runtime.java  |   8 ++
 camel-k-runtime-health/pom.xml                     |   5 -
 camel-k-runtime-main/pom.xml                       |  26 ++++
 .../test/java/org/apache/camel/k/main}/MyBean.java |   2 +-
 .../apache/camel/k/main}/MyRoutesWithBeans.java    |   6 +-
 .../java/org/apache/camel/k/main/RuntimeTest.java  | 103 +++++++++++-----
 .../src/test/resources/MyRoutesWithBeans.java      |   4 +-
 .../src/test/resources/rests.xml                   |   0
 .../src/test/resources/routes-with-expression.xml  |   5 +-
 .../src/test/resources/routes.xml                  |   0
 camel-k-runtime-servlet/pom.xml                    |   5 -
 20 files changed, 303 insertions(+), 317 deletions(-)
 rename {camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java => camel-k-runtime-main/src/test/java/org/apache/camel/k/main}/MyBean.java (96%)
 rename {camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java => camel-k-runtime-main/src/test/java/org/apache/camel/k/main}/MyRoutesWithBeans.java (86%)
 rename {camel-k-loader-java => camel-k-runtime-main}/src/test/resources/MyRoutesWithBeans.java (89%)
 copy {camel-k-loader-xml => camel-k-runtime-main}/src/test/resources/rests.xml (100%)
 copy camel-k-loader-xml/src/test/resources/routes.xml => camel-k-runtime-main/src/test/resources/routes-with-expression.xml (89%)
 copy {camel-k-loader-xml => camel-k-runtime-main}/src/test/resources/routes.xml (100%)


[camel-k-runtime] 08/08: chore: fix CS

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 91e8a02c3e56daab1d0fcac537168ac2d99ab931
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 17:39:17 2019 +0200

    chore: fix CS
---
 .../src/test/java/org/apache/camel/k/main/RuntimeTest.java              | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
index 13abd05..d4ec536 100644
--- a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
+++ b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
@@ -66,7 +66,7 @@ public class RuntimeTest {
 
     @Test
     void testLoadRouteAndRest() throws Exception {
-            runtime.addListener(new ContextConfigurer());
+        runtime.addListener(new ContextConfigurer());
         runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes.xml", "classpath:rests.xml"));
         runtime.addListener(Runtime.Phase.Started, r -> {
             CamelContext context = r.getCamelContext();


[camel-k-runtime] 01/08: chore(test): remove dependencies on runtime from camel-k-loader-js

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 7a5d455eeeea0ea5b940483193089e08b7ed9639
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 13:53:18 2019 +0200

    chore(test): remove dependencies on runtime from camel-k-loader-js
---
 camel-k-loader-js/pom.xml                          |   5 -
 .../camel/k/loader/js/dsl/IntegrationTest.java     | 128 +++++++++++----------
 2 files changed, 68 insertions(+), 65 deletions(-)

diff --git a/camel-k-loader-js/pom.xml b/camel-k-loader-js/pom.xml
index 89c6eee..34f1acc 100644
--- a/camel-k-loader-js/pom.xml
+++ b/camel-k-loader-js/pom.xml
@@ -53,11 +53,6 @@
         <!-- ******************************* -->
 
         <dependency>
-            <groupId>org.apache.camel.k</groupId>
-            <artifactId>camel-k-runtime-main</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-undertow</artifactId>
             <scope>test</scope>
diff --git a/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/dsl/IntegrationTest.java b/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/dsl/IntegrationTest.java
index 4e14a29..156f0af 100644
--- a/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/dsl/IntegrationTest.java
+++ b/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/dsl/IntegrationTest.java
@@ -18,11 +18,12 @@ package org.apache.camel.k.loader.js.dsl;
 
 import java.util.List;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
 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.k.main.ApplicationRuntime;
 import org.apache.camel.model.FromDefinition;
 import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.RouteDefinition;
@@ -30,91 +31,98 @@ import org.apache.camel.model.TransformDefinition;
 import org.apache.camel.model.rest.GetVerbDefinition;
 import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.spi.RestConfiguration;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class IntegrationTest {
-    @Test
-    public void testComponentConfiguration() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-component-configuration.js"));
-        runtime.addListener(Runtime.Phase.Started, r -> {
-            SedaComponent seda = r.getCamelContext().getComponent("seda", SedaComponent.class);
+    private CamelContext context;
+    private Runtime runtime;
 
-            assertThat(seda).isNotNull();
-            assertThat(seda).hasFieldOrPropertyWithValue("queueSize", 1234);
+    @BeforeEach
+    public void setUp() {
+        this.context = new DefaultCamelContext();
+        this.runtime = Runtime.of(context);
+    }
 
-            runtime.stop();
-        });
+    @AfterEach
+    public void shutDown() {
+        if (this.context != null) {
+            this.context.stop();
+        }
+    }
 
-        runtime.run();
+    private void configureRoutes(String... routes) {
+        RoutesConfigurer.forRoutes(routes).accept(Runtime.Phase.ConfigureRoutes, runtime);
     }
 
     @Test
-    public void testRestConfiguration() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-rest-configuration.js"));
-        runtime.addListener(Runtime.Phase.Started, r -> {
-            RestConfiguration conf = r.getCamelContext().getRestConfiguration();
+    public void testComponentConfiguration() {
+        configureRoutes(
+            "classpath:routes-with-component-configuration.js"
+        );
 
-            assertThat(conf).isNotNull();
-            assertThat(conf).hasFieldOrPropertyWithValue("component", "undertow");
-            assertThat(conf).hasFieldOrPropertyWithValue("port", 1234);
+        SedaComponent seda = context.getComponent("seda", SedaComponent.class);
 
-            runtime.stop();
-        });
+        assertThat(seda).isNotNull();
+        assertThat(seda).hasFieldOrPropertyWithValue("queueSize", 1234);
+    }
+    @Test
+    public void testRestConfiguration() {
+        configureRoutes(
+            "classpath:routes-with-rest-configuration.js"
+        );
+
+        RestConfiguration conf = context.getRestConfiguration();
 
-        runtime.run();
+        assertThat(conf).isNotNull();
+        assertThat(conf).hasFieldOrPropertyWithValue("component", "undertow");
+        assertThat(conf).hasFieldOrPropertyWithValue("port", 1234);
     }
 
     @Test
-    public void testRestDSL() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-rest-dsl.js"));
-        runtime.addListener(Runtime.Phase.Started, r -> {
-            ModelCamelContext mcc = r.getCamelContext().adapt(ModelCamelContext.class);
-            List<RestDefinition> rests = mcc.getRestDefinitions();
-            List<RouteDefinition> routes = mcc.getRouteDefinitions();
-
-            assertThat(rests).hasSize(1);
-            assertThat(rests).first().hasFieldOrPropertyWithValue("produces", "text/plain");
-            assertThat(rests).first().satisfies(definition -> {
-                assertThat(definition.getVerbs()).hasSize(1);
-                assertThat(definition.getVerbs()).first().isInstanceOfSatisfying(GetVerbDefinition.class, get -> {
-                    assertThat(get).hasFieldOrPropertyWithValue("uri", "/say/hello");
-                });
+    public void testRestDSL() {
+        configureRoutes(
+            "classpath:routes-with-rest-dsl.js"
+        );
+
+        ModelCamelContext mcc = context.adapt(ModelCamelContext.class);
+        List<RestDefinition> rests = mcc.getRestDefinitions();
+        List<RouteDefinition> routes = mcc.getRouteDefinitions();
+
+        assertThat(rests).hasSize(1);
+        assertThat(rests).first().hasFieldOrPropertyWithValue("produces", "text/plain");
+        assertThat(rests).first().satisfies(definition -> {
+            assertThat(definition.getVerbs()).hasSize(1);
+            assertThat(definition.getVerbs()).first().isInstanceOfSatisfying(GetVerbDefinition.class, get -> {
+                assertThat(get).hasFieldOrPropertyWithValue("uri", "/say/hello");
             });
+        });
 
-            assertThat(routes).hasSize(1);
-            assertThat(routes).first().satisfies(definition -> {
-                assertThat(definition.getInput()).isInstanceOf(FromDefinition.class);
-                assertThat(definition.getOutputs()).hasSize(1);
-                assertThat(definition.getOutputs()).first().satisfies(output -> {
-                    assertThat(output).isInstanceOf(TransformDefinition.class);
-                });
+        assertThat(routes).hasSize(1);
+        assertThat(routes).first().satisfies(definition -> {
+            assertThat(definition.getInput()).isInstanceOf(FromDefinition.class);
+            assertThat(definition.getOutputs()).hasSize(1);
+            assertThat(definition.getOutputs()).first().satisfies(output -> {
+                assertThat(output).isInstanceOf(TransformDefinition.class);
             });
-
-            runtime.stop();
         });
-
-        runtime.run();
     }
 
     @Test
-    public void testProcessors() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-processors.js"));
-        runtime.addListener(Runtime.Phase.Started, r -> {
-            ProducerTemplate template = r.getCamelContext().createProducerTemplate();
+    public void testProcessors() {
+        configureRoutes(
+            "classpath:routes-with-processors.js"
+        );
 
-            assertThat(template.requestBody("direct:arrow", "")).isEqualTo("arrow");
-            assertThat(template.requestBody("direct:wrapper", "")).isEqualTo("wrapper");
-            assertThat(template.requestBody("direct:function", "")).isEqualTo("function");
+        context.start();
 
-            runtime.stop();
-        });
+        ProducerTemplate template = context.createProducerTemplate();
 
-        runtime.run();
+        assertThat(template.requestBody("direct:arrow", "")).isEqualTo("arrow");
+        assertThat(template.requestBody("direct:wrapper", "")).isEqualTo("wrapper");
+        assertThat(template.requestBody("direct:function", "")).isEqualTo("function");
     }
 }


[camel-k-runtime] 03/08: chore(test): remove dependencies on runtime from camel-k-loader-java

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 31585abddb4513fa09ef0bf19bd18f282b8776c3
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 14:13:18 2019 +0200

    chore(test): remove dependencies on runtime from camel-k-loader-java
---
 camel-k-loader-java/pom.xml                        |  5 ----
 .../camel/k/loader/java/RoutesLoaderTest.java      | 27 ----------------------
 2 files changed, 32 deletions(-)

diff --git a/camel-k-loader-java/pom.xml b/camel-k-loader-java/pom.xml
index 693d84e..cd82333 100644
--- a/camel-k-loader-java/pom.xml
+++ b/camel-k-loader-java/pom.xml
@@ -49,11 +49,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.camel.k</groupId>
-            <artifactId>camel-k-runtime-main</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-main</artifactId>
             <scope>test</scope>
diff --git a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java b/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java
index 3db52d4..ed72296 100644
--- a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java
+++ b/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java
@@ -23,10 +23,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.k.RoutesLoader;
-import org.apache.camel.k.Runtime;
 import org.apache.camel.k.Source;
-import org.apache.camel.k.listener.RoutesConfigurer;
-import org.apache.camel.k.main.ApplicationRuntime;
 import org.apache.camel.k.support.RuntimeSupport;
 import org.apache.camel.model.ProcessDefinition;
 import org.apache.camel.model.RouteDefinition;
@@ -92,30 +89,6 @@ public class RoutesLoaderTest {
         assertThat(context.getRestConfigurations().iterator().next()).hasFieldOrPropertyWithValue("component", "restlet");
     }
 
-    @Test
-    public void testLoadJavaClassWithBeans() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:" + MyRoutesWithBeans.class.getName() + ".class"));
-        runtime.addListener(Runtime.Phase.Started, r ->  runtime.stop());
-        runtime.run();
-
-        assertThat(runtime.getRegistry().lookupByName("my-bean")).isInstanceOfSatisfying(MyBean.class, b -> {
-            assertThat(b).hasFieldOrPropertyWithValue("name", "my-bean-name");
-        });
-    }
-
-    @Test
-    public void testLoadJavaSourceWithBeans() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:MyRoutesWithBeans.java"));
-        runtime.addListener(Runtime.Phase.Started, r ->  runtime.stop());
-        runtime.run();
-
-        assertThat(runtime.getRegistry().lookupByName("my-bean")).isInstanceOfSatisfying(MyBean.class, b -> {
-            assertThat(b).hasFieldOrPropertyWithValue("name", "my-bean-name");
-        });
-    }
-
     @ParameterizedTest
     @MethodSource("parameters")
     public void testLoaders(String location, Class<? extends RoutesLoader> type) throws Exception {


[camel-k-runtime] 05/08: chore(test): remove dependencies on runtime from camel-k-runtime-servlet

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 b149f8327a05a3102105df441b86be7ca50342cb
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 14:41:08 2019 +0200

    chore(test): remove dependencies on runtime from camel-k-runtime-servlet
---
 camel-k-runtime-servlet/pom.xml | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/camel-k-runtime-servlet/pom.xml b/camel-k-runtime-servlet/pom.xml
index 41a8f60..9df6913 100644
--- a/camel-k-runtime-servlet/pom.xml
+++ b/camel-k-runtime-servlet/pom.xml
@@ -72,11 +72,6 @@
         <!-- ****************************** -->
 
         <dependency>
-            <groupId>org.apache.camel.k</groupId>
-            <artifactId>camel-k-runtime-main</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-test</artifactId>
             <scope>test</scope>


[camel-k-runtime] 07/08: chore(test): move runtime test to camel-k-runtime-main

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 6339b52498d671f28b95965d39e41206324eda4f
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 14:42:38 2019 +0200

    chore(test): move runtime test to camel-k-runtime-main
---
 .../src/main/java/org/apache/camel/k/Runtime.java  |   8 ++
 camel-k-runtime-main/pom.xml                       |  26 ++++++
 .../test/java/org/apache/camel/k/main}/MyBean.java |   2 +-
 .../apache/camel/k/main}/MyRoutesWithBeans.java    |   6 +-
 .../java/org/apache/camel/k/main/RuntimeTest.java  | 103 ++++++++++++++-------
 .../src/test/resources/MyRoutesWithBeans.java      |   4 +-
 camel-k-runtime-main/src/test/resources/rests.xml  |  27 ++++++
 .../src/test/resources/routes-with-expression.xml  |  28 ++++++
 camel-k-runtime-main/src/test/resources/routes.xml |  25 +++++
 9 files changed, 191 insertions(+), 38 deletions(-)

diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java
index 34ca0d2..c90fb5c 100644
--- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.k;
 
+import java.util.Map;
 import java.util.Properties;
 
 import org.apache.camel.CamelContext;
@@ -41,6 +42,13 @@ public interface Runtime extends HasCamelContext {
         getRegistry().bind("properties", pc);
     }
 
+    default void setProperties(Map<String, String> properties) {
+        Properties p = new Properties();
+        p.putAll(properties);
+
+        setProperties(p);
+    }
+
     default void addRoutes(RoutesBuilder builder) {
         try {
             getCamelContext().addRoutes(builder);
diff --git a/camel-k-runtime-main/pom.xml b/camel-k-runtime-main/pom.xml
index 2953855..87a55a7 100644
--- a/camel-k-runtime-main/pom.xml
+++ b/camel-k-runtime-main/pom.xml
@@ -104,6 +104,32 @@
             <artifactId>camel-properties</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-endpointdsl</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-bean</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel.k</groupId>
+            <artifactId>camel-k-loader-js</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.k</groupId>
+            <artifactId>camel-k-loader-xml</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.k</groupId>
+            <artifactId>camel-k-loader-java</artifactId>
+            <scope>test</scope>
+        </dependency>
 
         <dependency>
             <groupId>org.junit.jupiter</groupId>
diff --git a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyBean.java b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyBean.java
similarity index 96%
rename from camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyBean.java
rename to camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyBean.java
index 94a1834..2069e08 100644
--- a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyBean.java
+++ b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyBean.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.k.loader.java;
+package org.apache.camel.k.main;
 
 public class MyBean {
     private final String name;
diff --git a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyRoutesWithBeans.java b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyRoutesWithBeans.java
similarity index 86%
rename from camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyRoutesWithBeans.java
rename to camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyRoutesWithBeans.java
index 15db22b..a42b9f1 100644
--- a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyRoutesWithBeans.java
+++ b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyRoutesWithBeans.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.k.loader.java;
+package org.apache.camel.k.main;
 
 import org.apache.camel.BindToRegistry;
 import org.apache.camel.builder.RouteBuilder;
@@ -28,7 +28,7 @@ public class MyRoutesWithBeans extends RouteBuilder {
     }
 
     @BindToRegistry("my-bean")
-    public org.apache.camel.k.loader.java.MyBean createMyBean() {
-        return new org.apache.camel.k.loader.java.MyBean("my-bean-name");
+    public org.apache.camel.k.main.MyBean createMyBean() {
+        return new org.apache.camel.k.main.MyBean("my-bean-name");
     }
 }
\ No newline at end of file
diff --git a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
index b5eca85..13abd05 100644
--- a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
+++ b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
@@ -24,57 +24,96 @@ import org.apache.camel.k.Runtime;
 import org.apache.camel.k.listener.ContextConfigurer;
 import org.apache.camel.k.listener.RoutesConfigurer;
 import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.util.CollectionHelper;
 import org.apache.camel.util.ObjectHelper;
-import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class RuntimeTest {
-    @Disabled
+    private ApplicationRuntime runtime;
+
+    @BeforeEach
+    public void setUp() {
+        runtime = new ApplicationRuntime();
+    }
+
+    @AfterEach
+    public void cleanUp() throws Exception {
+        if (runtime != null) {
+            runtime.stop();
+        }
+    }
     @Test
     void testLoadMultipleRoutes() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
+        runtime.addListener(new ContextConfigurer());
+        runtime.addListener(RoutesConfigurer.forRoutes("classpath:r1.js", "classpath:r2.mytype?language=js"));
+        runtime.addListener(Runtime.Phase.Started, r -> {
+            CamelContext context = r.getCamelContext();
+            List<Route> routes = context.getRoutes();
 
-        try {
-            runtime.addListener(new ContextConfigurer());
-            runtime.addListener(RoutesConfigurer.forRoutes("classpath:r1.js", "classpath:r2.mytype?language=js"));
-            runtime.addListener(Runtime.Phase.Started, r -> {
-                CamelContext context = r.getCamelContext();
-                List<Route> routes = context.getRoutes();
+            assertThat(routes).hasSize(2);
+            assertThat(routes).anyMatch(p -> ObjectHelper.equal("r1", p.getId()));
+            assertThat(routes).anyMatch(p -> ObjectHelper.equal("r2", p.getId()));
 
-                assertThat(routes).hasSize(2);
-                assertThat(routes).anyMatch(p -> ObjectHelper.equal("r1", p.getId()));
-                assertThat(routes).anyMatch(p -> ObjectHelper.equal("r2", p.getId()));
+            runtime.stop();
+        });
+
+        runtime.run();
+    }
+
+    @Test
+    void testLoadRouteAndRest() throws Exception {
+            runtime.addListener(new ContextConfigurer());
+        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes.xml", "classpath:rests.xml"));
+        runtime.addListener(Runtime.Phase.Started, r -> {
+            CamelContext context = r.getCamelContext();
 
-                runtime.stop();
-            });
+            assertThat(context.adapt(ModelCamelContext.class).getRouteDefinitions()).isNotEmpty();
+            assertThat(context.adapt(ModelCamelContext.class).getRestDefinitions()).isNotEmpty();
 
-            runtime.run();
-        } finally {
             runtime.stop();
-        }
+        });
+
+        runtime.run();
     }
 
-    @Disabled
     @Test
-    void testLoadRouteAndRest() throws Exception {
+    void testLoadRouteWithExpression() throws Exception {
+        runtime.setProperties(CollectionHelper.mapOf(
+            "the.body", "10"
+        ));
+
+        runtime.addListener(new ContextConfigurer());
+        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-expression.xml"));
+        runtime.addListener(Runtime.Phase.Started, r -> runtime.stop());
+        runtime.run();
+    }
+
+
+    @Test
+    public void testLoadJavaClassWithBeans() throws Exception {
         ApplicationRuntime runtime = new ApplicationRuntime();
-        try {
-            runtime.addListener(new ContextConfigurer());
-            runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes.xml", "classpath:rests.xml"));
-            runtime.addListener(Runtime.Phase.Started, r -> {
-                CamelContext context = r.getCamelContext();
+        runtime.addListener(RoutesConfigurer.forRoutes("classpath:" + MyRoutesWithBeans.class.getName() + ".class"));
+        runtime.addListener(Runtime.Phase.Started, r ->  runtime.stop());
+        runtime.run();
 
-                assertThat(context.adapt(ModelCamelContext.class).getRouteDefinitions()).isNotEmpty();
-                assertThat(context.adapt(ModelCamelContext.class).getRestDefinitions()).isNotEmpty();
+        assertThat(runtime.getRegistry().lookupByName("my-bean")).isInstanceOfSatisfying(MyBean.class, b -> {
+            assertThat(b).hasFieldOrPropertyWithValue("name", "my-bean-name");
+        });
+    }
 
-                runtime.stop();
-            });
+    @Test
+    public void testLoadJavaSourceWithBeans() throws Exception {
+        ApplicationRuntime runtime = new ApplicationRuntime();
+        runtime.addListener(RoutesConfigurer.forRoutes("classpath:MyRoutesWithBeans.java"));
+        runtime.addListener(Runtime.Phase.Started, r ->  runtime.stop());
+        runtime.run();
 
-            runtime.run();
-        } finally {
-            runtime.stop();
-        }
+        assertThat(runtime.getRegistry().lookupByName("my-bean")).isInstanceOfSatisfying(MyBean.class, b -> {
+            assertThat(b).hasFieldOrPropertyWithValue("name", "my-bean-name");
+        });
     }
 }
diff --git a/camel-k-loader-java/src/test/resources/MyRoutesWithBeans.java b/camel-k-runtime-main/src/test/resources/MyRoutesWithBeans.java
similarity index 89%
rename from camel-k-loader-java/src/test/resources/MyRoutesWithBeans.java
rename to camel-k-runtime-main/src/test/resources/MyRoutesWithBeans.java
index f232dd6..530fe17 100644
--- a/camel-k-loader-java/src/test/resources/MyRoutesWithBeans.java
+++ b/camel-k-runtime-main/src/test/resources/MyRoutesWithBeans.java
@@ -27,7 +27,7 @@ public class MyRoutesWithBeans extends RouteBuilder {
     }
 
     @BindToRegistry("my-bean")
-    public org.apache.camel.k.loader.java.MyBean createMyBean() {
-        return new org.apache.camel.k.loader.java.MyBean("my-bean-name");
+    public org.apache.camel.k.main.MyBean createMyBean() {
+        return new org.apache.camel.k.main.MyBean("my-bean-name");
     }
 }
\ No newline at end of file
diff --git a/camel-k-runtime-main/src/test/resources/rests.xml b/camel-k-runtime-main/src/test/resources/rests.xml
new file mode 100644
index 0000000..40ecfb1
--- /dev/null
+++ b/camel-k-runtime-main/src/test/resources/rests.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+    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.
+
+-->
+<rests xmlns="http://camel.apache.org/schema/spring">
+  <rest path="/camel/">
+    <get id="greeting-api" uri="/greetings/{name}">
+      <param dataType="string" name="name" required="true" type="path"/>
+      <to uri="direct:greeting-api"/>
+    </get>
+  </rest>
+</rests>
diff --git a/camel-k-runtime-main/src/test/resources/routes-with-expression.xml b/camel-k-runtime-main/src/test/resources/routes-with-expression.xml
new file mode 100644
index 0000000..dc1090d
--- /dev/null
+++ b/camel-k-runtime-main/src/test/resources/routes-with-expression.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<routes xmlns="http://camel.apache.org/schema/spring">
+  <route>
+    <from uri="timer:tick"/>
+    <filter>
+      <simple>in.body == {{the.body}}</simple>
+      <to uri="log:info"/>
+    </filter>
+  </route>
+</routes>
\ No newline at end of file
diff --git a/camel-k-runtime-main/src/test/resources/routes.xml b/camel-k-runtime-main/src/test/resources/routes.xml
new file mode 100644
index 0000000..2dbe048
--- /dev/null
+++ b/camel-k-runtime-main/src/test/resources/routes.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<routes xmlns="http://camel.apache.org/schema/spring">
+  <route>
+    <from uri="timer:tick"/>
+    <to uri="log:info"/>
+  </route>
+</routes>
\ No newline at end of file


[camel-k-runtime] 04/08: chore(test): remove dependencies on runtime from camel-k-runtime-health

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 643aa3574bdd342ae784a4f933e239d2a9da0031
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 14:40:54 2019 +0200

    chore(test): remove dependencies on runtime from camel-k-runtime-health
---
 camel-k-runtime-health/pom.xml | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/camel-k-runtime-health/pom.xml b/camel-k-runtime-health/pom.xml
index f58ecb6..d2590c9 100644
--- a/camel-k-runtime-health/pom.xml
+++ b/camel-k-runtime-health/pom.xml
@@ -65,11 +65,6 @@
             <artifactId>camel-properties</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel.k</groupId>
-            <artifactId>camel-k-runtime-main</artifactId>
-            <scope>test</scope>
-        </dependency>
 
         <dependency>
             <groupId>org.junit.jupiter</groupId>


[camel-k-runtime] 06/08: chore(test): remove dependencies on runtime from camel-k-loader-kotlin

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 6682fcce7ed25e770e3850b0fb041b0900517cfc
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 14:41:49 2019 +0200

    chore(test): remove dependencies on runtime from camel-k-loader-kotlin
---
 camel-k-loader-kotlin/pom.xml                      |   8 +-
 .../camel/k/loader/kotlin/dsl/IntegrationTest.kt   | 124 +++++++++------------
 2 files changed, 54 insertions(+), 78 deletions(-)

diff --git a/camel-k-loader-kotlin/pom.xml b/camel-k-loader-kotlin/pom.xml
index f9e500d..03e9542 100644
--- a/camel-k-loader-kotlin/pom.xml
+++ b/camel-k-loader-kotlin/pom.xml
@@ -78,11 +78,6 @@
         <!-- ******************************* -->
 
         <dependency>
-            <groupId>org.apache.camel.k</groupId>
-            <artifactId>camel-k-runtime-main</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-timer</artifactId>
             <scope>test</scope>
@@ -163,6 +158,9 @@
                 <artifactId>kotlin-maven-plugin</artifactId>
                 <groupId>org.jetbrains.kotlin</groupId>
                 <version>${kotlin.version}</version>
+                <configuration>
+                    <jvmTarget>${maven.compiler.target}</jvmTarget>
+                </configuration>
                 <executions>
                     <execution>
                         <id>compile</id>
diff --git a/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt b/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt
index 7336c7d..8f274e0 100644
--- a/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt
+++ b/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt
@@ -20,112 +20,90 @@ import org.apache.camel.Predicate
 import org.apache.camel.Processor
 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.k.main.ApplicationRuntime
+import org.apache.camel.k.listener.RoutesConfigurer.forRoutes
 import org.apache.camel.model.ModelCamelContext
 import org.apache.camel.processor.FatalFallbackErrorHandler
-import org.apache.camel.spi.ExchangeFormatter
 import org.apache.camel.support.DefaultHeaderFilterStrategy
 import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.Test
-import java.util.concurrent.atomic.AtomicInteger
-import java.util.concurrent.atomic.AtomicReference
 import javax.sql.DataSource
 
 class IntegrationTest {
     @Test
     fun `load integration with rest`() {
-        var runtime = ApplicationRuntime()
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-rest.kts"))
-        runtime.addListener(Runtime.Phase.Started) { runtime.stop() }
-        runtime.run()
-
-        assertThat(runtime.camelContext.restConfiguration.host).isEqualTo("my-host")
-        assertThat(runtime.camelContext.restConfiguration.port).isEqualTo(9192)
-        assertThat(runtime.camelContext.getRestConfiguration("undertow", false).host).isEqualTo("my-undertow-host")
-        assertThat(runtime.camelContext.getRestConfiguration("undertow", false).port).isEqualTo(9193)
-        assertThat(runtime.camelContext.adapt(ModelCamelContext::class.java).restDefinitions.size).isEqualTo(1)
-        assertThat(runtime.camelContext.adapt(ModelCamelContext::class.java).restDefinitions[0].path).isEqualTo("/my/path")
+        val context = DefaultCamelContext()
+        val runtime = Runtime.of(context)
+
+        forRoutes("classpath:routes-with-rest.kts").accept(Runtime.Phase.ConfigureRoutes, runtime)
+
+        assertThat(context.restConfiguration.host).isEqualTo("my-host")
+        assertThat(context.restConfiguration.port).isEqualTo(9192)
+        assertThat(context.getRestConfiguration("undertow", false).host).isEqualTo("my-undertow-host")
+        assertThat(context.getRestConfiguration("undertow", false).port).isEqualTo(9193)
+        assertThat(context.adapt(ModelCamelContext::class.java).restDefinitions.size).isEqualTo(1)
+        assertThat(context.adapt(ModelCamelContext::class.java).restDefinitions[0].path).isEqualTo("/my/path")
     }
 
     @Test
     fun `load integration with beans`() {
-        var runtime = ApplicationRuntime()
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-beans.kts"))
-        runtime.addListener(Runtime.Phase.Started) { runtime.stop() }
-        runtime.run()
-
-        assertThat(runtime.camelContext.registry.findByType(DataSource::class.java)).hasSize(1)
-        assertThat(runtime.camelContext.registry.lookupByName("dataSource")).isInstanceOf(DataSource::class.java)
-        assertThat(runtime.camelContext.registry.findByType(DefaultHeaderFilterStrategy::class.java)).hasSize(1)
-        assertThat(runtime.camelContext.registry.lookupByName("filterStrategy")).isInstanceOf(DefaultHeaderFilterStrategy::class.java)
-        assertThat(runtime.camelContext.registry.lookupByName("myProcessor")).isInstanceOf(Processor::class.java)
-        assertThat(runtime.camelContext.registry.lookupByName("myPredicate")).isInstanceOf(Predicate::class.java)
+        val context = DefaultCamelContext()
+        val runtime = Runtime.of(context)
+
+        forRoutes("classpath:routes-with-beans.kts").accept(Runtime.Phase.ConfigureRoutes, runtime)
+
+        assertThat(context.registry.findByType(DataSource::class.java)).hasSize(1)
+        assertThat(context.registry.lookupByName("dataSource")).isInstanceOf(DataSource::class.java)
+        assertThat(context.registry.findByType(DefaultHeaderFilterStrategy::class.java)).hasSize(1)
+        assertThat(context.registry.lookupByName("filterStrategy")).isInstanceOf(DefaultHeaderFilterStrategy::class.java)
+        assertThat(context.registry.lookupByName("myProcessor")).isInstanceOf(Processor::class.java)
+        assertThat(context.registry.lookupByName("myPredicate")).isInstanceOf(Predicate::class.java)
     }
 
     @Test
     fun `load integration with binding`() {
-        var runtime = ApplicationRuntime()
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-bindings.kts"))
-        runtime.addListener(Runtime.Phase.Started) { runtime.stop() }
-        runtime.run()
+        val context = DefaultCamelContext()
+        val runtime = Runtime.of(context)
+
+        forRoutes("classpath:routes-with-bindings.kts").accept(Runtime.Phase.ConfigureRoutes, runtime)
 
-        assertThat(runtime.camelContext.registry.lookupByName("my-entry")).isEqualTo("myRegistryEntry1")
-        assertThat(runtime.camelContext.registry.lookupByName("my-proc")).isInstanceOf(Processor::class.java)
+        assertThat(context.registry.lookupByName("my-entry")).isEqualTo("myRegistryEntry1")
+        assertThat(context.registry.lookupByName("my-proc")).isInstanceOf(Processor::class.java)
     }
 
     @Test
     fun `load integration with component configuration`() {
-        val sedaSize = AtomicInteger()
-        val sedaConsumers = AtomicInteger()
-        val mySedaSize = AtomicInteger()
-        val mySedaConsumers = AtomicInteger()
-        val format = AtomicReference<ExchangeFormatter>()
-
-        var runtime = ApplicationRuntime()
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-component-configuration.kts"))
-        runtime.addListener(Runtime.Phase.Started) {
-            val seda = runtime.camelContext.getComponent("seda", SedaComponent::class.java)
-            val mySeda = runtime.camelContext.getComponent("mySeda", SedaComponent::class.java)
-            val log = runtime.camelContext.getComponent("log", LogComponent::class.java)
-
-            sedaSize.set(seda!!.queueSize)
-            sedaConsumers.set(seda.concurrentConsumers)
-            mySedaSize.set(mySeda!!.queueSize)
-            mySedaConsumers.set(mySeda.concurrentConsumers)
-            format.set(log!!.exchangeFormatter)
-
-            runtime.stop()
-        }
+        val context = DefaultCamelContext()
+        val runtime = Runtime.of(context)
+
+        forRoutes("classpath:routes-with-component-configuration.kts").accept(Runtime.Phase.ConfigureRoutes, runtime)
 
-        runtime.run()
+        val seda = context.getComponent("seda", SedaComponent::class.java)
+        val mySeda = context.getComponent("mySeda", SedaComponent::class.java)
+        val log = context.getComponent("log", LogComponent::class.java)
 
-        assertThat(sedaSize.get()).isEqualTo(1234)
-        assertThat(sedaConsumers.get()).isEqualTo(12)
-        assertThat(mySedaSize.get()).isEqualTo(4321)
-        assertThat(mySedaConsumers.get()).isEqualTo(21)
-        assertThat(format.get()).isNotNull
+        assertThat(seda.queueSize).isEqualTo(1234)
+        assertThat(seda.concurrentConsumers).isEqualTo(12)
+        assertThat(mySeda.queueSize).isEqualTo(4321)
+        assertThat(mySeda.concurrentConsumers).isEqualTo(21)
+        assertThat(log.exchangeFormatter).isNotNull
     }
 
     @Test
     fun `load integration with error handler`() {
-        var onExceptions = mutableListOf<Processor>()
+        val context = DefaultCamelContext()
+        val runtime = Runtime.of(context)
 
-        var runtime = ApplicationRuntime()
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-error-handler.kts"))
-        runtime.addListener(Runtime.Phase.Started) {
-            assertThat(it.camelContext.routes).hasSize(1)
-            assertThat(it.camelContext.routes[0].routeContext.getOnException("my-on-exception")).isNotNull
+        forRoutes("classpath:routes-with-error-handler.kts").accept(Runtime.Phase.ConfigureRoutes, runtime)
 
-            onExceptions.add(it.camelContext.routes[0].routeContext.getOnException("my-on-exception"))
+        context.start()
 
-            runtime.stop()
+        try {
+            assertThat(context.routes).hasSize(1)
+            assertThat(context.routes[0].routeContext.getOnException("my-on-exception")).isInstanceOf(FatalFallbackErrorHandler::class.java)
+        } finally {
+            context.stop()
         }
-
-        runtime.run()
-
-        assertThat(onExceptions).hasSize(1)
-        assertThat(onExceptions).first().isInstanceOf(FatalFallbackErrorHandler::class.java)
     }
 }
\ No newline at end of file


[camel-k-runtime] 02/08: chore(test): remove dependencies on runtime from camel-k-loader-groovy

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 c50b70a8d782db1cab3c0bf3989d091d42e1f88c
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 3 14:07:38 2019 +0200

    chore(test): remove dependencies on runtime from camel-k-loader-groovy
---
 camel-k-loader-groovy/pom.xml                      |   5 -
 .../k/loader/groovy/dsl/IntegrationTest.groovy     | 136 +++++++++------------
 .../groovy/dsl/extension/LogExtensionTest.groovy   |  18 +--
 3 files changed, 66 insertions(+), 93 deletions(-)

diff --git a/camel-k-loader-groovy/pom.xml b/camel-k-loader-groovy/pom.xml
index 0589a7b..4ff0534 100644
--- a/camel-k-loader-groovy/pom.xml
+++ b/camel-k-loader-groovy/pom.xml
@@ -70,11 +70,6 @@
         <!-- ******************************* -->
 
         <dependency>
-            <groupId>org.apache.camel.k</groupId>
-            <artifactId>camel-k-runtime-main</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-main</artifactId>
             <scope>test</scope>
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 695c952..a6f5e55 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
@@ -20,9 +20,9 @@ import org.apache.camel.Predicate
 import org.apache.camel.Processor
 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.k.main.ApplicationRuntime
+import org.apache.camel.model.ModelCamelContext
 import org.apache.camel.processor.FatalFallbackErrorHandler
 import org.apache.camel.processor.SendProcessor
 import org.apache.camel.processor.channel.DefaultChannel
@@ -31,114 +31,92 @@ import org.apache.camel.support.DefaultHeaderFilterStrategy
 import spock.lang.Specification
 
 import javax.sql.DataSource
-import java.util.concurrent.atomic.AtomicInteger
-import java.util.concurrent.atomic.AtomicReference
+
+import static org.apache.camel.k.listener.RoutesConfigurer.forRoutes
 
 class IntegrationTest extends Specification {
+
+    private ModelCamelContext context
+    private Runtime runtime
+
+    def setup() {
+        this.context = new DefaultCamelContext()
+        this.runtime = Runtime.of(context)
+    }
+
+
+    def cleanup() {
+        if (this.context != null) {
+            this.context.stop()
+        }
+    }
+
     def "load integration with rest"()  {
         when:
-            def runtime = new ApplicationRuntime()
-            runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-rest.groovy'))
-            runtime.addListener(Runtime.Phase.Started, { runtime.stop() })
-            runtime.run()
+            forRoutes('classpath:routes-with-rest.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
 
         then:
-            runtime.camelContext.restConfiguration.host == 'my-host'
-            runtime.camelContext.restConfiguration.port == 9192
-            runtime.camelContext.getRestConfiguration('undertow', false).host == 'my-undertow-host'
-            runtime.camelContext.getRestConfiguration('undertow', false).port == 9193
-            runtime.camelContext.restDefinitions.size() == 1
-            runtime.camelContext.restDefinitions[0].path == '/my/path'
+            context.restConfiguration.host == 'my-host'
+            context.restConfiguration.port == 9192
+            context.getRestConfiguration('undertow', false).host == 'my-undertow-host'
+            context.getRestConfiguration('undertow', false).port == 9193
+            context.restDefinitions.size() == 1
+            context.restDefinitions[0].path == '/my/path'
     }
 
     def "load integration with beans"()  {
         when:
-            def runtime = new ApplicationRuntime()
-            runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-beans.groovy'))
-            runtime.addListener(Runtime.Phase.Started, { runtime.stop() })
-            runtime.run()
+            forRoutes('classpath:routes-with-beans.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
 
         then:
-            runtime.camelContext.registry.findByType(DataSource).size() == 1
-            runtime.camelContext.registry.lookupByName('dataSource') instanceof DataSource
-            runtime.camelContext.registry.findByType(HeaderFilterStrategy).size() == 1
-            runtime.camelContext.registry.lookupByName('filterStrategy') instanceof DefaultHeaderFilterStrategy
+            context.registry.findByType(DataSource).size() == 1
+            context.registry.lookupByName('dataSource') instanceof DataSource
+            context.registry.findByType(HeaderFilterStrategy).size() == 1
+            context.registry.lookupByName('filterStrategy') instanceof DefaultHeaderFilterStrategy
 
-            runtime.camelContext.registry.lookupByName('myProcessor') instanceof Processor
-            runtime.camelContext.registry.lookupByName('myPredicate') instanceof Predicate
+            context.registry.lookupByName('myProcessor') instanceof Processor
+            context.registry.lookupByName('myPredicate') instanceof Predicate
     }
 
     def "load integration with bindings"()  {
         when:
-            def runtime = new ApplicationRuntime()
-            runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-bindings.groovy'))
-            runtime.addListener(Runtime.Phase.Started, { runtime.stop() })
-            runtime.run()
+            forRoutes('classpath:routes-with-bindings.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
 
         then:
-            runtime.camelContext.registry.lookupByName('myEntry1') == 'myRegistryEntry1'
-            runtime.camelContext.registry.lookupByName('myEntry2') == 'myRegistryEntry2'
-            runtime.camelContext.registry.lookupByName('myEntry3') instanceof Processor
+            context.registry.lookupByName('myEntry1') == 'myRegistryEntry1'
+            context.registry.lookupByName('myEntry2') == 'myRegistryEntry2'
+            context.registry.lookupByName('myEntry3') instanceof Processor
     }
 
     def "load integration with component configuration"()  {
-        given:
-            def sedaSize = new AtomicInteger()
-            def sedaConsumers = new AtomicInteger()
-            def mySedaSize = new AtomicInteger()
-            def mySedaConsumers = new AtomicInteger()
-            def format = new AtomicReference()
-
         when:
-            def runtime = new ApplicationRuntime()
-            runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-component-configuration.groovy'))
-            runtime.addListener(Runtime.Phase.Started, {
-                def seda = it.camelContext.getComponent('seda', SedaComponent)
-                def mySeda = it.camelContext.getComponent('mySeda', SedaComponent)
-                def log = it.camelContext.getComponent('log', LogComponent)
-
-                assert seda != null
-                assert mySeda != null
-                assert log != null
-
-                sedaSize = seda.queueSize
-                sedaConsumers = seda.concurrentConsumers
-                mySedaSize = mySeda.queueSize
-                mySedaConsumers = mySeda.concurrentConsumers
-                format = log.exchangeFormatter
-
-                runtime.stop()
-            })
-
-            runtime.run()
+            forRoutes('classpath:routes-with-component-configuration.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
+
         then:
-            sedaSize == 1234
-            sedaConsumers == 12
-            mySedaSize == 4321
-            mySedaConsumers == 21
-            format != null
+            with(context.getComponent('seda', SedaComponent)) {
+                queueSize == 1234
+                concurrentConsumers == 12
+            }
+            with(context.getComponent('mySeda', SedaComponent)) {
+                queueSize == 4321
+                concurrentConsumers == 21
+            }
+            with(context.getComponent('log', LogComponent)) {
+                exchangeFormatter != null
+            }
     }
 
     def "load integration with error handler"()  {
-        given:
-            def onExceptions = []
         when:
-            def runtime = new ApplicationRuntime()
-            runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-error-handler.groovy'))
-            runtime.addListener(Runtime.Phase.Started, {
-                it.camelContext.routes?.size() == 1
-                it.camelContext.routes[0].routeContext.getOnException('my-on-exception') != null
-
-                onExceptions << it.camelContext.routes[0].routeContext.getOnException('my-on-exception')
+            forRoutes('classpath:routes-with-error-handler.groovy').accept(Runtime.Phase.ConfigureRoutes, runtime)
 
-                runtime.stop()
-            })
-            runtime.run()
+            context.start()
         then:
-            onExceptions.size() == 1
-            onExceptions[0] instanceof FatalFallbackErrorHandler
+            context.routes?.size() == 1
+            context.routes[0].routeContext.getOnException('my-on-exception') != null
+            context.routes[0].routeContext.getOnException('my-on-exception') instanceof FatalFallbackErrorHandler
 
-            def eh = onExceptions[0] as FatalFallbackErrorHandler
+            def eh = context.routes[0].routeContext.getOnException('my-on-exception')  as FatalFallbackErrorHandler
             def ch = eh.processor as DefaultChannel
 
             ch.output instanceof SendProcessor
diff --git a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/extension/LogExtensionTest.groovy b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/extension/LogExtensionTest.groovy
index be463a0..a5a4b5e 100644
--- a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/extension/LogExtensionTest.groovy
+++ b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/dsl/extension/LogExtensionTest.groovy
@@ -25,19 +25,19 @@ class LogExtensionTest extends Specification {
 
     def "invoke extension method - formatter"()  {
         given:
-        def ctx = new DefaultCamelContext()
+            def ctx = new DefaultCamelContext()
 
         when:
-        def log = new LogComponent()
-        log.formatter {
-            "body: $it.in.body"
-        }
+            def log = new LogComponent()
+            log.formatter {
+                "body: $it.in.body"
+            }
 
-        def ex = new DefaultExchange(ctx)
-        ex.in.body = 'hello'
-        def result = log.exchangeFormatter.format(ex)
+            def ex = new DefaultExchange(ctx)
+            ex.in.body = 'hello'
+            def result = log.exchangeFormatter.format(ex)
 
         then:
-        result == 'body: hello'
+            result == 'body: hello'
     }
 }