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/06/07 10:54:25 UTC

[camel-k-runtime] 02/02: Fix camel-k catalog generator

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

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

commit 3f5f04084abc8fc662fee6c119f6f38bf274f9cd
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Jun 5 17:38:18 2019 +0200

    Fix camel-k catalog generator
---
 .../maven/processors/CatalogProcessor_2_x.java     |   3 +-
 .../maven/processors/CatalogProcessor_3_x.java     | 193 ---------------------
 ...he.camel.k.tooling.maven.model.CatalogProcessor |   1 -
 .../maven/processors/CataloProcessor2Test.java     |   5 +-
 .../maven/processors/CataloProcessor3Test.java     | 118 -------------
 5 files changed, 6 insertions(+), 314 deletions(-)

diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java
index 69e6d00..02a3d6a 100644
--- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java
+++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java
@@ -167,7 +167,8 @@ public class CatalogProcessor_2_x implements CatalogProcessor {
             CamelArtifact artifact = new CamelArtifact();
             artifact.setGroupId("org.apache.camel.k");
             artifact.setArtifactId("camel-k-runtime-health");
-            artifact.addDependency("org.apache.camel", "camel-netty4-http");
+            artifact.addDependency("org.apache.camel", "camel-servlet");
+            artifact.addDependency("org.apache.camel.k", "camel-k-runtime-servlet");
 
             artifacts.put(artifact.getArtifactId(), artifact);
         }
diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java
deleted file mode 100644
index 8ebec01..0000000
--- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * 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.
- */
-package org.apache.camel.k.tooling.maven.processors;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import com.vdurmont.semver4j.Semver;
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.k.tooling.maven.model.CamelArtifact;
-import org.apache.camel.k.tooling.maven.model.CatalogProcessor;
-import org.apache.maven.project.MavenProject;
-
-public class CatalogProcessor_3_x implements CatalogProcessor {
-    private static final List<String> KNOWN_HTTP_URIS = Arrays.asList(
-        "ahc",
-        "ahc-ws",
-        "atmosphere-websocket",
-        "cxf",
-        "cxfrs",
-        "grpc",
-        "jetty",
-        "netty-http",
-        "netty4-http",
-        "rest",
-        "restlet",
-        "servlet",
-        "spark-rest",
-        "spring-ws",
-        "undertow",
-        "websocket"
-    );
-
-    private static final List<String> KNOWN_PASSIVE_URIS = Arrays.asList(
-        "bean",
-        "binding",
-        "browse",
-        "class",
-        "controlbus",
-        "dataformat",
-        "dataset",
-        "direct",
-        "direct-vm",
-        "language",
-        "log",
-        "mock",
-        "properties",
-        "ref",
-        "seda",
-        "stub",
-        "test",
-        "validator",
-        "vm"
-    );
-
-    @Override
-    public int getOrder() {
-        return HIGHEST;
-    }
-
-    @Override
-    public boolean accepts(CamelCatalog catalog) {
-        Semver semver = new Semver(catalog.getCatalogVersion(), Semver.SemverType.IVY);
-        return semver.isGreaterThan("2.999.999") && semver.isLowerThan("4.0.0");
-    }
-
-    @Override
-    public void process(MavenProject project, CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
-
-        // ************************
-        //
-        // camel-k-runtime-jvm
-        //
-        // ************************
-
-        {
-            CamelArtifact artifact = new CamelArtifact();
-            artifact.setGroupId("org.apache.camel.k");
-            artifact.setArtifactId("camel-k-runtime-jvm");
-            artifact.setVersion(project.getVersion());
-            artifact.addDependency("org.apache.camel", "camel-core");
-            artifact.addDependency("org.apache.camel.k", "camel-k-adapter-camel-3");
-
-            artifacts.put(artifact.getArtifactId(), artifact);
-        }
-
-        // ************************
-        //
-        // camel-k-runtime-groovy
-        //
-        // ************************
-
-        {
-            CamelArtifact artifact = new CamelArtifact();
-            artifact.setGroupId("org.apache.camel.k");
-            artifact.setArtifactId("camel-k-runtime-groovy");
-            artifact.setVersion(project.getVersion());
-            artifact.addDependency("org.apache.camel", "camel-groovy");
-
-            artifacts.put(artifact.getArtifactId(), artifact);
-        }
-
-        // ************************
-        //
-        // camel-k-runtime-kotlin
-        //
-        // ************************
-
-        {
-            CamelArtifact artifact = new CamelArtifact();
-            artifact.setGroupId("org.apache.camel.k");
-            artifact.setArtifactId("camel-k-runtime-kotlin");
-            artifact.setVersion(project.getVersion());
-
-            artifacts.put(artifact.getArtifactId(), artifact);
-        }
-
-        // ************************
-        //
-        // camel-knative
-        //
-        // ************************
-
-        {
-            CamelArtifact artifact = new CamelArtifact();
-            artifact.setGroupId("org.apache.camel.k");
-            artifact.setArtifactId("camel-knative");
-            artifact.setVersion(project.getVersion());
-            artifact.createScheme("knative").setHttp(true);
-            artifact.addDependency("org.apache.camel", "camel-netty4-http");
-
-            artifacts.put(artifact.getArtifactId(), artifact);
-        }
-
-        // ************************
-        //
-        // camel-k-runtime-health
-        //
-        // ************************
-
-        {
-            CamelArtifact artifact = new CamelArtifact();
-            artifact.setGroupId("org.apache.camel.k");
-            artifact.setArtifactId("camel-k-runtime-health");
-            artifact.addDependency("org.apache.camel", "camel-netty4-http");
-
-            artifacts.put(artifact.getArtifactId(), artifact);
-        }
-
-        // ************************
-        //
-        // camel-k-runtime-servlet
-        //
-        // ************************
-
-        {
-            CamelArtifact artifact = new CamelArtifact();
-            artifact.setGroupId("org.apache.camel.k");
-            artifact.setArtifactId("camel-k-runtime-servlet");
-            artifact.addDependency("org.apache.camel", "camel-servlet");
-
-            artifacts.put(artifact.getArtifactId(), artifact);
-        }
-
-        // ************************
-        //
-        //
-        //
-        // ************************
-
-        for (String scheme: KNOWN_HTTP_URIS) {
-            artifacts.values().forEach(artifact -> artifact.getScheme(scheme).ifPresent(s -> s.setHttp(true)));
-        }
-        for (String scheme: KNOWN_PASSIVE_URIS) {
-            artifacts.values().forEach(artifact -> artifact.getScheme(scheme).ifPresent(s -> s.setPassive(true)));
-        }
-    }
-}
diff --git a/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor b/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor
index 5a778d4..1531453 100644
--- a/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor
+++ b/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor
@@ -1,2 +1 @@
 org.apache.camel.k.tooling.maven.processors.CatalogProcessor_2_x
-org.apache.camel.k.tooling.maven.processors.CatalogProcessor_3_x
diff --git a/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java b/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java
index bd8bba6..240709d 100644
--- a/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java
+++ b/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java
@@ -97,7 +97,10 @@ public class CataloProcessor2Test extends AbstractCataloProcessorTest {
         });
         assertThat(artifactMap.get("camel-k-runtime-health")).satisfies(a -> {
             assertThat(a.getDependencies()).anyMatch(
-                d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-netty4-http")
+                d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-servlet")
+            );
+            assertThat(a.getDependencies()).anyMatch(
+                d -> d.getGroupId().equals("org.apache.camel.k") && d.getArtifactId().equals("camel-k-runtime-servlet")
             );
         });
         assertThat(artifactMap.get("camel-k-runtime-servlet")).satisfies(a -> {
diff --git a/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor3Test.java b/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor3Test.java
deleted file mode 100644
index fd4bb9c..0000000
--- a/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor3Test.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 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.
- */
-
-package org.apache.camel.k.tooling.maven.processors;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.k.tooling.maven.model.CamelArtifact;
-import org.apache.camel.k.tooling.maven.model.CatalogProcessor;
-import org.apache.maven.project.MavenProject;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CataloProcessor3Test extends AbstractCataloProcessorTest {
-
-    @Test
-    public void testAcceptHyphen(){
-        CatalogProcessor_3_x cp3 = new CatalogProcessor_3_x();
-
-        CamelCatalog catalog = versionCamelCatalog("3.0.0.acme-123456");
-
-        assertThat(cp3.accepts(catalog)).isTrue();
-    }
-
-    @Test
-    public void testAcceptEqualToLower(){
-        CatalogProcessor_3_x cp3 = new CatalogProcessor_3_x();
-
-        CamelCatalog catalog = versionCamelCatalog("3.0.0");
-
-        assertThat(cp3.accepts(catalog)).isTrue();
-    }
-
-    @Test
-    public void testAcceptLessThanLower(){
-        CatalogProcessor_3_x cp3 = new CatalogProcessor_3_x();
-
-        CamelCatalog catalog = versionCamelCatalog("2.17.0");
-
-        assertThat(cp3.accepts(catalog)).isFalse();
-    }
-
-    @Test
-    public void testAcceptEqualToHigher(){
-        CatalogProcessor_3_x cp3 = new CatalogProcessor_3_x();
-
-        CamelCatalog catalog = versionCamelCatalog("4.0.0");
-
-        assertThat(cp3.accepts(catalog)).isFalse();
-    }
-
-    @Test
-    public void testAcceptMoreThanHigher(){
-        CatalogProcessor_3_x cp3 = new CatalogProcessor_3_x();
-
-        CamelCatalog catalog = versionCamelCatalog("5.0.0");
-
-        assertThat(cp3.accepts(catalog)).isFalse();
-    }
-
-    @Test
-    public void testArtifactsEnrichment(){
-        CatalogProcessor processor = new CatalogProcessor_3_x();
-        CamelCatalog catalog = versionCamelCatalog("3.0.0");
-        Map<String, CamelArtifact> artifactMap = new HashMap<>();
-
-        assertThat(processor.accepts(catalog)).isTrue();
-        processor.process(new MavenProject(), catalog, artifactMap);
-
-
-        assertThat(artifactMap.get("camel-k-runtime-jvm")).satisfies(a -> {
-            assertThat(a.getDependencies()).anyMatch(
-                d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-core")
-            );
-            assertThat(a.getDependencies()).anyMatch(
-                d -> d.getGroupId().equals("org.apache.camel.k") && d.getArtifactId().equals("camel-k-adapter-camel-3")
-            );
-        });
-        assertThat(artifactMap.get("camel-k-runtime-groovy")).satisfies(a -> {
-            assertThat(a.getDependencies()).anyMatch(
-                d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-groovy")
-            );
-        });
-        assertThat(artifactMap.get("camel-k-runtime-health")).satisfies(a -> {
-            assertThat(a.getDependencies()).anyMatch(
-                d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-netty4-http")
-            );
-        });
-        assertThat(artifactMap.get("camel-k-runtime-servlet")).satisfies(a -> {
-            assertThat(a.getDependencies()).anyMatch(
-                d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-servlet")
-            );
-        });
-
-        assertThat(artifactMap.get("camel-knative")).satisfies(a -> {
-            assertThat(a.getDependencies()).anyMatch(
-                d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-netty4-http")
-            );
-        });
-    }
-}