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 2020/09/02 12:21:04 UTC

[camel-k-runtime] 02/05: chore(deps): replace commons-dbcp2 used for testing purpose with custom POJOs

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 ee690550acd863348de6b93c0daa6d92d9571a39
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 2 13:29:39 2020 +0200

    chore(deps): replace commons-dbcp2 used for testing purpose with custom POJOs
---
 camel-k-loader-groovy/pom.xml                      |  7 -------
 .../k/loader/groovy/GroovySourceLoaderTest.groovy  |  7 +++----
 .../camel/k/loader/groovy/support/MyBean.groovy}   | 24 ++++++++--------------
 .../src/test/resources/routes-with-beans.groovy    |  7 ++-----
 .../camel-k-loader-kotlin/pom.xml                  |  7 -------
 .../k/loader/kotlin/KotlinSourceLoaderTest.kt      |  6 +++---
 .../apache/camel/k/loader/kotlin/support/MyBean.kt | 22 +++++---------------
 .../src/test/resources/routes-with-beans.kts       |  7 ++-----
 pom.xml                                            |  1 -
 9 files changed, 24 insertions(+), 64 deletions(-)

diff --git a/camel-k-loader-groovy/pom.xml b/camel-k-loader-groovy/pom.xml
index 41a1daa..ba3d5b8 100644
--- a/camel-k-loader-groovy/pom.xml
+++ b/camel-k-loader-groovy/pom.xml
@@ -113,13 +113,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-dbcp2</artifactId>
-            <version>${commons-dbcp2.version}</version>
-            <scope>test</scope>
-        </dependency>
-
     </dependencies>
 
     <build>
diff --git a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoaderTest.groovy b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoaderTest.groovy
index 60163af..66ea733 100644
--- a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoaderTest.groovy
+++ b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoaderTest.groovy
@@ -24,6 +24,7 @@ import org.apache.camel.component.log.LogComponent
 import org.apache.camel.component.seda.SedaComponent
 import org.apache.camel.k.Sources
 import org.apache.camel.k.listener.RoutesConfigurer
+import org.apache.camel.k.loader.groovy.support.MyBean
 import org.apache.camel.k.loader.groovy.support.TestRuntime
 import org.apache.camel.language.bean.BeanLanguage
 import org.apache.camel.model.FromDefinition
@@ -39,8 +40,6 @@ import org.apache.camel.support.DefaultHeaderFilterStrategy
 import spock.lang.AutoCleanup
 import spock.lang.Specification
 
-import javax.sql.DataSource
-
 class GroovySourceLoaderTest extends Specification {
     @AutoCleanup
     def runtime = new TestRuntime()
@@ -129,8 +128,8 @@ class GroovySourceLoaderTest extends Specification {
 
         then:
             with(runtime.context.registry) {
-                it.findByType(DataSource).size() == 1
-                it.lookupByName('dataSource') instanceof DataSource
+                it.findByType(MyBean).size() == 1
+                it.lookupByName('myBean') instanceof MyBean
                 it.findByType(HeaderFilterStrategy).size() == 1
                 it.lookupByName('filterStrategy') instanceof DefaultHeaderFilterStrategy
                 it.lookupByName('myProcessor') instanceof Processor
diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/support/MyBean.groovy
similarity index 67%
copy from camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy
copy to camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/support/MyBean.groovy
index fe92d1a..c6a2681 100644
--- a/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy
+++ b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/support/MyBean.groovy
@@ -14,22 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-beans {
-    dataSource(org.apache.commons.dbcp2.BasicDataSource) {
-        driverClassName = "org.h2.Driver"
-        url = "jdbc:h2:mem:camel"
-        username = "sa"
-        password = ""
-    }
-    filterStrategy {
-        new org.apache.camel.support.DefaultHeaderFilterStrategy()
-    }
+package org.apache.camel.k.loader.groovy.support
+
+class MyBean {
+    private String name
 
-    myProcessor = processor {
-        it.in.body = 'value'
+    String getName() {
+        return name
     }
 
-    myPredicate = predicate {
-        false
+    void setName(String name) {
+        this.name = name
     }
-}
\ No newline at end of file
+}
diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy b/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy
index fe92d1a..183cbb1 100644
--- a/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy
+++ b/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy
@@ -15,11 +15,8 @@
  * limitations under the License.
  */
 beans {
-    dataSource(org.apache.commons.dbcp2.BasicDataSource) {
-        driverClassName = "org.h2.Driver"
-        url = "jdbc:h2:mem:camel"
-        username = "sa"
-        password = ""
+    myBean(org.apache.camel.k.loader.groovy.support.MyBean) {
+        name = "test"
     }
     filterStrategy {
         new org.apache.camel.support.DefaultHeaderFilterStrategy()
diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml b/camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml
index 478eeac..aaa29b8 100644
--- a/camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml
+++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml
@@ -113,13 +113,6 @@
             <artifactId>camel-jackson</artifactId>
             <scope>test</scope>
         </dependency>
-
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-dbcp2</artifactId>
-            <version>${commons-dbcp2.version}</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoaderTest.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoaderTest.kt
index 441c038..afeacdf 100644
--- a/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoaderTest.kt
+++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoaderTest.kt
@@ -22,6 +22,7 @@ import org.apache.camel.RuntimeCamelException
 import org.apache.camel.component.jackson.JacksonDataFormat
 import org.apache.camel.component.log.LogComponent
 import org.apache.camel.component.seda.SedaComponent
+import org.apache.camel.k.loader.kotlin.support.MyBean
 import org.apache.camel.k.loader.kotlin.support.TestRuntime
 import org.apache.camel.language.bean.BeanLanguage
 import org.apache.camel.model.ProcessDefinition
@@ -33,7 +34,6 @@ import org.apache.camel.support.DefaultHeaderFilterStrategy
 import org.assertj.core.api.Assertions
 import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.Test
-import javax.sql.DataSource
 
 class KotlinSourceLoaderTest {
 
@@ -100,8 +100,8 @@ class KotlinSourceLoaderTest {
         val runtime = TestRuntime()
         runtime.loadRoutes("classpath:routes-with-beans.kts")
 
-        assertThat(runtime.context.registry.findByType(DataSource::class.java)).hasSize(1)
-        assertThat(runtime.context.registry.lookupByName("dataSource")).isInstanceOf(DataSource::class.java)
+        assertThat(runtime.context.registry.findByType(MyBean::class.java)).hasSize(1)
+        assertThat(runtime.context.registry.lookupByName("myBean")).isInstanceOf(MyBean::class.java)
         assertThat(runtime.context.registry.findByType(DefaultHeaderFilterStrategy::class.java)).hasSize(1)
         assertThat(runtime.context.registry.lookupByName("filterStrategy")).isInstanceOf(DefaultHeaderFilterStrategy::class.java)
         assertThat(runtime.context.registry.lookupByName("myProcessor")).isInstanceOf(Processor::class.java)
diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/support/MyBean.kt
similarity index 66%
copy from camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy
copy to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/support/MyBean.kt
index fe92d1a..df82b8a 100644
--- a/camel-k-loader-groovy/src/test/resources/routes-with-beans.groovy
+++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/support/MyBean.kt
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -14,22 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-beans {
-    dataSource(org.apache.commons.dbcp2.BasicDataSource) {
-        driverClassName = "org.h2.Driver"
-        url = "jdbc:h2:mem:camel"
-        username = "sa"
-        password = ""
-    }
-    filterStrategy {
-        new org.apache.camel.support.DefaultHeaderFilterStrategy()
-    }
+package org.apache.camel.k.loader.kotlin.support
+
+class MyBean {
+    var name: String = ""
 
-    myProcessor = processor {
-        it.in.body = 'value'
-    }
 
-    myPredicate = predicate {
-        false
-    }
 }
\ No newline at end of file
diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts
index 52f596f..a6c6567 100644
--- a/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts
+++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts
@@ -15,11 +15,8 @@
  * limitations under the License.
  */
 beans {
-    bean<org.apache.commons.dbcp2.BasicDataSource>("dataSource") {
-        driverClassName = "org.h2.Driver"
-        url = "jdbc:h2:mem:camel"
-        username = "sa"
-        password = ""
+    bean<org.apache.camel.k.loader.kotlin.support.MyBean>("myBean") {
+        name = "test"
     }
 
     bean("filterStrategy") {
diff --git a/pom.xml b/pom.xml
index fec5de8..55a4e91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,6 @@
         <junit.version>5.6.2</junit.version>
         <junit-pioneer.version>0.9.0</junit-pioneer.version>
         <joor.version>0.9.13</joor.version>
-        <commons-dbcp2.version>2.7.0</commons-dbcp2.version>
         <assertj.version>3.17.1</assertj.version>
         <log4j2.version>2.13.3</log4j2.version>
         <slf4j.version>1.7.30</slf4j.version>