You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/03/03 12:43:19 UTC

(camel) branch main updated: Revert routes-loader should use marker file name as-is without the dot to dash hack

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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new f67077c92cb Revert routes-loader should use marker file name as-is without the dot to dash hack
f67077c92cb is described below

commit f67077c92cb380f5f8a8c7324628f41448ebb261
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 3 13:42:58 2024 +0100

    Revert routes-loader should use marker file name as-is without the dot to dash hack
---
 .../camel/routes-loader/{camel.xml => camel-xml}   |  0
 .../apache/camel/dsl/xml/io/XmlLoadAppTest.java    | 24 +++++++++++++++++++
 .../apache/camel/dsl/xml/io/camel-app11.camel.xml  | 27 ++++++++++++++++++++++
 .../camel/routes-loader/{camel.xml => camel-xml}   |  0
 .../routes-loader/{kamelet.yaml => kamelet-yaml}   |  0
 .../camel/maven/packaging/SpiGeneratorMojo.java    |  3 ++-
 6 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/dsl/camel-xml-io-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel.xml b/dsl/camel-xml-io-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel-xml
similarity index 100%
rename from dsl/camel-xml-io-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel.xml
rename to dsl/camel-xml-io-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel-xml
diff --git a/dsl/camel-xml-io-dsl/src/test/java/org/apache/camel/dsl/xml/io/XmlLoadAppTest.java b/dsl/camel-xml-io-dsl/src/test/java/org/apache/camel/dsl/xml/io/XmlLoadAppTest.java
index 83700f09df1..2422651160e 100644
--- a/dsl/camel-xml-io-dsl/src/test/java/org/apache/camel/dsl/xml/io/XmlLoadAppTest.java
+++ b/dsl/camel-xml-io-dsl/src/test/java/org/apache/camel/dsl/xml/io/XmlLoadAppTest.java
@@ -277,4 +277,28 @@ public class XmlLoadAppTest {
         }
     }
 
+    @Test
+    public void testLoadCamelAppCamelXmlExt() throws Exception {
+        try (DefaultCamelContext context = new DefaultCamelContext()) {
+            context.start();
+
+            Resource resource = PluginHelper.getResourceLoader(context).resolveResource(
+                    "/org/apache/camel/dsl/xml/io/camel-app11.camel.xml");
+
+            RoutesLoader routesLoader = PluginHelper.getRoutesLoader(context);
+            routesLoader.preParseRoute(resource, false);
+            routesLoader.loadRoutes(resource);
+
+            assertNotNull(context.getRoute("r11"), "Loaded r11 route should be there");
+            assertEquals(1, context.getRoutes().size());
+
+            // test that loaded route works
+            MockEndpoint y11 = context.getEndpoint("mock:y11", MockEndpoint.class);
+            y11.expectedBodiesReceived("Hi World");
+            context.createProducerTemplate().sendBody("direct:x11", "Hi World");
+            y11.assertIsSatisfied();
+
+            context.stop();
+        }
+    }
 }
diff --git a/dsl/camel-xml-io-dsl/src/test/resources/org/apache/camel/dsl/xml/io/camel-app11.camel.xml b/dsl/camel-xml-io-dsl/src/test/resources/org/apache/camel/dsl/xml/io/camel-app11.camel.xml
new file mode 100644
index 00000000000..bfae9cb76b8
--- /dev/null
+++ b/dsl/camel-xml-io-dsl/src/test/resources/org/apache/camel/dsl/xml/io/camel-app11.camel.xml
@@ -0,0 +1,27 @@
+<?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.
+
+-->
+<camel xmlns:s="http://www.springframework.org/schema/beans">
+
+    <route id="r11">
+        <from uri="direct:x11"/>
+        <to uri="mock:y11"/>
+    </route>
+
+</camel>
diff --git a/dsl/camel-xml-jaxb-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel.xml b/dsl/camel-xml-jaxb-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel-xml
similarity index 100%
rename from dsl/camel-xml-jaxb-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel.xml
rename to dsl/camel-xml-jaxb-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/camel-xml
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/kamelet.yaml b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/kamelet-yaml
similarity index 100%
rename from dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/kamelet.yaml
rename to dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/kamelet-yaml
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
index 2224b044b29..8dee2695138 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
@@ -163,7 +163,8 @@ public class SpiGeneratorMojo extends AbstractGeneratorMojo {
     }
 
     private String sanitizeFileName(String fileName) {
-        return fileName.replaceAll("[^A-Za-z0-9+-/.]", "-");
+        // dot should be replaced with dash (camel.yaml -> camel-yaml) for marker files
+        return fileName.replaceAll("[^A-Za-z0-9+-/]", "-").replace('.', '-');
     }
 
     private boolean isLocal(String className) {