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/03/24 16:16:17 UTC

[camel-k-runtime] 03/07: Improve it for camel-k-maven-plugin

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 ebc2c819dbed24b7f2eac587214bc951b3757736
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Fri Mar 20 16:06:58 2020 +0100

    Improve it for camel-k-maven-plugin
---
 tooling/camel-k-maven-plugin/pom.xml               | 24 +++++++++++--
 .../src/it/generate-catalog-main/verify.groovy     | 39 ++++++++++++----------
 .../src/it/generate-catalog-quarkus/verify.groovy  | 37 +++++++++++---------
 .../src/it/generate-rest-dsl-from-v2/verify.groovy | 16 +++++----
 .../src/it/generate-rest-dsl-from-v3/verify.groovy | 21 ++++++------
 5 files changed, 84 insertions(+), 53 deletions(-)

diff --git a/tooling/camel-k-maven-plugin/pom.xml b/tooling/camel-k-maven-plugin/pom.xml
index e8497a1..f011d1c 100644
--- a/tooling/camel-k-maven-plugin/pom.xml
+++ b/tooling/camel-k-maven-plugin/pom.xml
@@ -230,6 +230,9 @@
         <configuration>
           <scriptVariables>
             <runtimeVersion>${project.version}</runtimeVersion>
+            <camelVersion>${camel.version}</camelVersion>
+            <camelQuarkusVersion>${camel-quarkus.version}</camelQuarkusVersion>
+            <quarkusVersion>${quarkus.version}</quarkusVersion>
           </scriptVariables>
           <pomIncludes>
             <pomInclude>generate-catalog-main/pom.xml</pomInclude>
@@ -258,9 +261,24 @@
         </executions>
         <dependencies>
           <dependency>
-            <groupId>org.yaml</groupId>
-            <artifactId>snakeyaml</artifactId>
-            <version>1.25</version>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy</artifactId>
+            <version>${groovy.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-yaml</artifactId>
+            <version>${groovy.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-json</artifactId>
+            <version>${groovy.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-xml</artifactId>
+            <version>${groovy.version}</version>
           </dependency>
         </dependencies>
       </plugin>
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy
index f9ebcef..570e81d 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy
+++ b/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy
@@ -14,25 +14,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-def source  = new File(basedir, "catalog.yaml")
-def catalog = new org.yaml.snakeyaml.Yaml().load(new FileInputStream(source))
 
-assert catalog.spec.runtime.version == runtimeVersion
-assert catalog.spec.runtime.applicationClass == 'org.apache.camel.k.main.Application'
+new File(basedir, "catalog.yaml").withReader {
+    def catalog = new groovy.yaml.YamlSlurper().parse(it)
 
-assert catalog.spec.runtime.capabilities['health'].dependencies[0].groupId == 'org.apache.camel.k'
-assert catalog.spec.runtime.capabilities['health'].dependencies[0].artifactId == 'camel-k-runtime-health'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[0].groupId == 'org.apache.camel'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[0].artifactId == 'camel-rest'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[1].groupId == 'org.apache.camel.k'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[1].artifactId == 'camel-k-runtime-http'
+    assert catalog.spec.runtime.version == runtimeVersion
+    assert catalog.spec.runtime.applicationClass == 'org.apache.camel.k.main.Application'
+    assert catalog.spec.runtime.metadata['camel.version'] == camelVersion
+    assert catalog.spec.runtime.metadata['quarkus.version'] == quarkusVersion
+    assert catalog.spec.runtime.metadata['camel-quarkus.version'] == camelQuarkusVersion
 
-assert catalog.metadata.labels['camel.apache.org/runtime.version'] == runtimeVersion
+    assert catalog.spec.runtime.capabilities['health'].dependencies[0].groupId == 'org.apache.camel.k'
+    assert catalog.spec.runtime.capabilities['health'].dependencies[0].artifactId == 'camel-k-runtime-health'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[0].groupId == 'org.apache.camel'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[0].artifactId == 'camel-rest'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[1].groupId == 'org.apache.camel.k'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[1].artifactId == 'camel-k-runtime-http'
 
-assert catalog.spec.artifacts['camel-knative'].dependencies.size == 3
-assert catalog.spec.artifacts['camel-knative'].dependencies.find { it.groupId == 'org.apache.camel.k' && it.artifactId == 'camel-knative-api'}
-assert catalog.spec.artifacts['camel-knative'].dependencies.find { it.groupId == 'org.apache.camel.k' && it.artifactId == 'camel-knative'}
-assert catalog.spec.artifacts['camel-knative'].dependencies.find { it.groupId == 'org.apache.camel.k' && it.artifactId == 'camel-knative-http'}
+    assert catalog.metadata.labels['camel.apache.org/runtime.version'] == runtimeVersion
 
-assert catalog.spec.artifacts['camel-knative'].schemes.size == 1
-assert catalog.spec.artifacts['camel-knative'].schemes[0].id == 'knative'
+    assert catalog.spec.artifacts['camel-knative'].dependencies.size == 3
+    assert catalog.spec.artifacts['camel-knative'].dependencies.find { it.groupId == 'org.apache.camel.k' && it.artifactId == 'camel-knative-api'}
+    assert catalog.spec.artifacts['camel-knative'].dependencies.find { it.groupId == 'org.apache.camel.k' && it.artifactId == 'camel-knative'}
+    assert catalog.spec.artifacts['camel-knative'].dependencies.find { it.groupId == 'org.apache.camel.k' && it.artifactId == 'camel-knative-http'}
+
+    assert catalog.spec.artifacts['camel-knative'].schemes.size == 1
+    assert catalog.spec.artifacts['camel-knative'].schemes[0].id == 'knative'
+}
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
index 0236404..af9d3db 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
+++ b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
@@ -14,23 +14,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-def source  = new File(basedir, "catalog.yaml")
-def catalog = new org.yaml.snakeyaml.Yaml().load(new FileInputStream(source))
 
-assert catalog.spec.runtime.version == runtimeVersion
-assert catalog.spec.runtime.applicationClass == 'io.quarkus.runner.GeneratedMain'
+new File(basedir, "catalog.yaml").withReader {
+    def catalog = new groovy.yaml.YamlSlurper().parse(it)
 
-assert catalog.spec.runtime.capabilities['health'].dependencies[0].groupId == 'org.apache.camel.quarkus'
-assert catalog.spec.runtime.capabilities['health'].dependencies[0].artifactId == 'camel-quarkus-microprofile-health'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[0].groupId == 'org.apache.camel.quarkus'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[0].artifactId == 'camel-quarkus-rest'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[1].groupId == 'org.apache.camel.quarkus'
-assert catalog.spec.runtime.capabilities['rest'].dependencies[1].artifactId == 'camel-quarkus-platform-http'
+    assert catalog.spec.runtime.version == runtimeVersion
+    assert catalog.spec.runtime.applicationClass == 'io.quarkus.runner.GeneratedMain'
+    assert catalog.spec.runtime.metadata['camel.version'] == camelVersion
+    assert catalog.spec.runtime.metadata['quarkus.version'] == quarkusVersion
+    assert catalog.spec.runtime.metadata['camel-quarkus.version'] == camelQuarkusVersion
 
-assert catalog.metadata.labels['camel.apache.org/runtime.version'] == runtimeVersion
+    assert catalog.spec.runtime.capabilities['health'].dependencies[0].groupId == 'org.apache.camel.quarkus'
+    assert catalog.spec.runtime.capabilities['health'].dependencies[0].artifactId == 'camel-quarkus-microprofile-health'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[0].groupId == 'org.apache.camel.quarkus'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[0].artifactId == 'camel-quarkus-rest'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[1].groupId == 'org.apache.camel.quarkus'
+    assert catalog.spec.runtime.capabilities['rest'].dependencies[1].artifactId == 'camel-quarkus-platform-http'
 
-assert catalog.spec.artifacts['camel-knative'].dependencies.size == 1
-assert catalog.spec.artifacts['camel-knative'].dependencies[0].groupId == 'org.apache.camel.k'
-assert catalog.spec.artifacts['camel-knative'].dependencies[0].artifactId == 'camel-k-quarkus-knative'
-assert catalog.spec.artifacts['camel-knative'].schemes.size == 1
-assert catalog.spec.artifacts['camel-knative'].schemes[0].id == 'knative'
+    assert catalog.metadata.labels['camel.apache.org/runtime.version'] == runtimeVersion
+
+    assert catalog.spec.artifacts['camel-knative'].dependencies.size == 1
+    assert catalog.spec.artifacts['camel-knative'].dependencies[0].groupId == 'org.apache.camel.k'
+    assert catalog.spec.artifacts['camel-knative'].dependencies[0].artifactId == 'camel-k-quarkus-knative'
+    assert catalog.spec.artifacts['camel-knative'].schemes.size == 1
+    assert catalog.spec.artifacts['camel-knative'].schemes[0].id == 'knative'
+}
\ No newline at end of file
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/verify.groovy
index c17d402..55386da 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/verify.groovy
+++ b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/verify.groovy
@@ -15,11 +15,13 @@
  * limitations under the License.
  */
 
-def source  = new File(basedir, "document.xml")
-def document = new XmlSlurper().parse(source)
 
-assert document.rest.@path == '/camel/'
-assert document.rest.get.size() == 1
-assert document.rest.get[0].@id == 'greeting-api'
-assert document.rest.get[0].@uri == '/greetings/{name}'
-assert document.rest.get[0].to.@uri == 'direct:greeting-api'
\ No newline at end of file
+new File(basedir, "document.xml").withReader {
+    def document = new groovy.util.XmlSlurper().parse(it)
+
+    assert document.rest.@path == '/camel/'
+    assert document.rest.get.size() == 1
+    assert document.rest.get[0].@id == 'greeting-api'
+    assert document.rest.get[0].@uri == '/greetings/{name}'
+    assert document.rest.get[0].to.@uri == 'direct:greeting-api'
+}
\ No newline at end of file
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/verify.groovy
index 30e90e0..b5d010d 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/verify.groovy
+++ b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/verify.groovy
@@ -15,14 +15,15 @@
  * limitations under the License.
  */
 
-def source  = new File(basedir, "document.xml")
-def document = new XmlSlurper().parse(source)
+new File(basedir, "document.xml").withReader {
+    def document = new groovy.util.XmlSlurper().parse(it)
 
-assert document.rest.@path == '/v1'
-assert document.rest.get.size() == 2
-assert document.rest.get.find { it.@id == 'listPets' }.@uri == '/pets'
-assert document.rest.get.find { it.@id == 'listPets' }.to.@uri == 'direct:listPets'
-assert document.rest.get.find { it.@id == 'showPetById' }.@uri == '/pets/{petId}'
-assert document.rest.get.find { it.@id == 'showPetById' }.to.@uri == 'direct:showPetById'
-assert document.rest.post.find { it.@id == 'createPets' }.@uri == '/pets'
-assert document.rest.post.find { it.@id == 'createPets' }.to.@uri == 'direct:createPets'
+    assert document.rest.@path == '/v1'
+    assert document.rest.get.size() == 2
+    assert document.rest.get.find { it.@id == 'listPets' }.@uri == '/pets'
+    assert document.rest.get.find { it.@id == 'listPets' }.to.@uri == 'direct:listPets'
+    assert document.rest.get.find { it.@id == 'showPetById' }.@uri == '/pets/{petId}'
+    assert document.rest.get.find { it.@id == 'showPetById' }.to.@uri == 'direct:showPetById'
+    assert document.rest.post.find { it.@id == 'createPets' }.@uri == '/pets'
+    assert document.rest.post.find { it.@id == 'createPets' }.to.@uri == 'direct:createPets'
+}