You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by fm...@apache.org on 2025/02/28 08:52:11 UTC
(camel-upgrade-recipes) branch main updated (2767668 -> 4d9f49b)
This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
from 2767668 Fix release script
new 588dad1 Configurations upgrade
new 8f5e0f2 Enumerate value changes in yaml file
new 4d9f49b Move spring boot related keys in spring boot project
The 3 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-spring-boot-upgrade-recipes/pom.xml | 17 ++++
.../src/main/resources/META-INF/rewrite/4.10.yaml | 1 +
.../main/resources/META-INF/rewrite/latest.yaml | 1 +
.../resources/META-INF/rewrite/properties.yaml | 39 +++++++++
.../springboot/CamelSpringBootPropertiesTest.java | 96 ++++++++++++++++++++++
.../ChangePropertyKeyWithCaseChange.java | 14 ++++
.../customRecipes/PropertiesAndYamlKeyUpdate.java | 45 ++++++++++
.../src/main/resources/META-INF/rewrite/4.10.yaml | 72 +++++++++++++++-
.../main/resources/META-INF/rewrite/latest.yaml | 1 +
.../apache/camel/upgrade/CamelUpdate410Test.java | 19 +++++
10 files changed, 304 insertions(+), 1 deletion(-)
create mode 100644 camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml
create mode 100644 camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/CamelSpringBootPropertiesTest.java
create mode 100644 camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/PropertiesAndYamlKeyUpdate.java
(camel-upgrade-recipes) 01/03: Configurations upgrade
Posted by fm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
commit 588dad1c1299b2ddcff10ed6a611d193bd56ab92
Author: Croway <fe...@gmail.com>
AuthorDate: Fri Feb 21 14:13:59 2025 +0100
Configurations upgrade
---
.../src/main/resources/META-INF/rewrite/4.10.yaml | 1 +
.../main/resources/META-INF/rewrite/latest.yaml | 1 +
.../upgrade/CamelPropertiesAndYamlUpdate.java | 151 +++++++++++++++++++++
.../upgrade/PatternMatcherChangePropertyKey.java | 127 +++++++++++++++++
.../main/resources/META-INF/rewrite/latest.yaml | 1 +
.../apache/camel/upgrade/CamelPropertiesTest.java | 91 +++++++++++++
6 files changed, 372 insertions(+)
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
index cbac268..784e03f 100644
--- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
@@ -28,6 +28,7 @@ recipeList:
- org.apache.camel.upgrade.camel45.CamelMigrationRecipe
- org.apache.camel.upgrade.camel44.CamelMigrationRecipe
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
+ - org.apache.camel.upgrade.CamelPropertiesAndYamlUpdate
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: '*camel*'
artifactId: 'camel-spring-boot-bom'
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
index 3dd3c1b..0ec8f3f 100644
--- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
@@ -30,6 +30,7 @@ recipeList:
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
- org.apache.camel.upgrade.UpgradeToJava17
- org.apache.camel.upgrade.JavaVersion17
+ - org.apache.camel.upgrade.CamelPropertiesAndYamlUpdate
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: '*camel*'
artifactId: 'camel-spring-boot-bom'
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/CamelPropertiesAndYamlUpdate.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/CamelPropertiesAndYamlUpdate.java
new file mode 100644
index 0000000..7927154
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/CamelPropertiesAndYamlUpdate.java
@@ -0,0 +1,151 @@
+/*
+ * 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.upgrade;
+
+import org.openrewrite.Recipe;
+import org.openrewrite.properties.ChangePropertyKey;
+import org.openrewrite.yaml.ChangeKey;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Recipe for updating Apache Camel configuration properties and YAML keys.
+ * <p>
+ * This recipe handles the migration of Apache Camel configuration keys according to updated
+ * naming conventions while preserving their values. It focuses on three main types of changes:
+ * <ul>
+ * <li>Converting 'camel.springboot.*' prefixes to 'camel.main.*'</li>
+ * <li>Converting 'camel.routeController.*' to lowercase 'camel.routecontroller.*'</li>
+ * <li>Moving tracing-related properties from 'camel.main' to 'camel.trace'</li>
+ * <li>Preserving specific properties that should keep the 'springboot' prefix</li>
+ * </ul>
+ *
+ */
+public class CamelPropertiesAndYamlUpdate extends Recipe {
+
+ @Override
+ public String getDisplayName() {
+ return "Change Apache Camel properties key";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Change Apache Camel properties and YAML keys leaving the value intact.";
+ }
+
+ @Override
+ public List<Recipe> getRecipeList() {
+ List<Recipe> recipes = new ArrayList<>();
+ // camel.springboot.* to camel.main.* updates
+ UpdateSpringBootToMain(recipes);
+
+ // camel.routeController.* to camel.routecontroller.* updates
+ routeController(recipes);
+ // camel.main to camel.trace
+ trace(recipes);
+
+ // Some properties need the springboot prefix, let's fix those
+ FixMainToSpringBoot(recipes);
+
+ return recipes;
+ }
+
+ private void trace(List<Recipe> recipes) {
+ fullConfigurationUpdate(recipes, Map.of(
+ "camel.main.backlogTracing", "camel.trace.enabled",
+ "camel.main.backlogTracingStandby", "camel.trace.backlogTracingStandby",
+ "camel.main.backlogTracingTemplates", "camel.trace.backlogTracingTemplates"));
+ }
+
+ private void routeController(List<Recipe> recipes) {
+ Map<String, String> oldNewProperties = new HashMap<>();
+ // Special configurations
+ oldNewProperties.putAll(Map.of(
+ "camel.main.routeControllerSuperviseEnabled", "camel.routecontroller.enabled",
+ "camel.springboot.routeControllerSuperviseEnabled", "camel.routecontroller.enabled",
+ "camel.main.backlogTracing", "camel.trace.enabled",
+ "camel.main.backlogTracingStandby", "camel.trace.backlogTracingStandby",
+ "camel.main.backlogTracingTemplates", "camel.trace.backlogTracingTemplates"
+ ));
+ // Common configurations
+ oldNewProperties.putAll(Map.of(
+ "camel.main.routeControllerInitialDelay", "camel.routecontroller.initialDelay",
+ "camel.main.routeControllerBackOffDelay", "camel.routecontroller.backOffDelay",
+ "camel.main.routeControllerBackOffMaxAttempts", "camel.routecontroller.backOffMaxAttempts",
+ "camel.main.routeControllerBackOffMaxDelay", "camel.routecontroller.backOffMaxDelay",
+ "camel.main.routeControllerBackOffMaxElapsedTime", "camel.routecontroller.backOffMaxElapsedTime",
+ "camel.main.routeControllerBackOffMultiplier", "camel.routecontroller.backOffMultiplier",
+ "camel.main.routeControllerIncludeRoutes", "camel.routecontroller.includeRoutes",
+ "camel.main.routeControllerExcludeRoutes", "camel.routecontroller.excludeRoutes",
+ "camel.main.routeControllerThreadPoolSize", "camel.routecontroller.threadPoolSize"
+ )
+ );
+
+ // sometimes, backoff is mispelled.....
+ oldNewProperties.putAll(Map.of(
+ "camel.main.routeControllerBackoffDelay", "camel.routecontroller.backOffDelay",
+ "camel.main.routeControllerBackoffMaxAttempts", "camel.routecontroller.backOffMaxAttempts",
+ "camel.main.routeControllerBackoffMaxDelay", "camel.routecontroller.backOffMaxDelay",
+ "camel.main.routeControllerBackoffMaxElapsedTime", "camel.routecontroller.backOffMaxElapsedTime",
+ "camel.main.routeControllerBackoffMultiplier", "camel.routecontroller.backOffMultiplier"
+ ));
+
+ fullConfigurationUpdate(recipes, oldNewProperties);
+ }
+
+ private static void fullConfigurationUpdate(List<Recipe> recipes, Map<String, String> oldNewProperties) {
+ for (Map.Entry<String, String> entry : oldNewProperties.entrySet()) {
+ recipes.add(
+ new ChangePropertyKey(entry.getKey(), entry.getValue(),
+ null, null)
+ );
+ recipes.add(
+ new org.openrewrite.yaml.ChangePropertyKey(
+ entry.getKey(), entry.getValue(), null, null, null)
+ );
+ }
+ }
+
+ private void FixMainToSpringBoot(List<Recipe> recipes) {
+ fullConfigurationUpdate(recipes, Map.of(
+ "camel.main.main-run-controller", "camel.springboot.main-run-controller",
+ "camel.main.include-non-singletons", "camel.springboot.include-non-singletons",
+ "camel.main.warn-on-early-shutdown", "camel.springboot.warn-on-early-shutdown",
+ "camel.main.mainRunController", "camel.springboot.main-run-controller",
+ "camel.main.includeNonSingletons", "camel.springboot.include-non-singletons",
+ "camel.main.warnOnEarlyShutdown", "camel.springboot.warn-on-early-shutdown"
+ ));
+ }
+
+ private static void UpdateSpringBootToMain(List<Recipe> recipes) {
+ recipes.add(
+ new PatternMatcherChangePropertyKey(
+ "camel.springboot", "camel.main", List.of(
+ "camel.springboot.main-run-controller",
+ "camel.springboot.include-non-singletons",
+ "camel.springboot.warn-on-early-shutdown"
+ ))
+ );
+
+ recipes.add(
+ new ChangeKey("$.camel.springboot", "main")
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/PatternMatcherChangePropertyKey.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/PatternMatcherChangePropertyKey.java
new file mode 100644
index 0000000..2eb0f63
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/PatternMatcherChangePropertyKey.java
@@ -0,0 +1,127 @@
+/*
+ * 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.upgrade;
+
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.properties.PropertiesVisitor;
+import org.openrewrite.properties.tree.Properties;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A recipe that changes property keys in property files by replacing a specified key prefix
+ * and applying CamelCase formatting to any remaining suffix.
+ */
+public class PatternMatcherChangePropertyKey extends Recipe {
+
+ @Option(displayName = "Old property key",
+ description = "The property key to rename.",
+ example = "management.metrics.binders.files.enabled")
+ String oldPropertyKey;
+
+ @Option(displayName = "New property key",
+ description = "The new name for the key identified by `oldPropertyKey`.",
+ example = "management.metrics.enable.process.files")
+ String newPropertyKey;
+
+ @Option(displayName = "Exclusions",
+ description = "Regexp for exclusions",
+ example = "camel.springboot.main-run-controller")
+ List<String> exclusions = new ArrayList<>();
+
+ public PatternMatcherChangePropertyKey() {}
+
+ public PatternMatcherChangePropertyKey(String oldPropertyKey, String newPropertyKey, List<String> exclusions) {
+ this.oldPropertyKey = oldPropertyKey;
+ this.newPropertyKey = newPropertyKey;
+ this.exclusions = exclusions == null ? new ArrayList<>() : exclusions;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Change property key and apply CamelCase format";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Change property key applying CamelCase format leaving the value intact.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return new PatternMatcherChangePropertyKey.ChangePropertyKeyVisitor<>();
+ }
+
+ public class ChangePropertyKeyVisitor<P> extends PropertiesVisitor<P> {
+ public ChangePropertyKeyVisitor() {
+ }
+
+ @Override
+ public Properties visitEntry(Properties.Entry entry, P p) {
+ for (String exclusion : exclusions) {
+ if (entry.getKey().equals(exclusion)) {
+ return super.visitEntry(entry, p);
+ }
+ }
+
+ Pattern pattern = Pattern.compile("(" + oldPropertyKey + ")" + "(.*)");
+ Matcher matcher = pattern.matcher(entry.getKey());
+ if (matcher.find()) {
+ if(matcher.group(2).startsWith(".")) {
+ entry = entry.withKey(newPropertyKey + matcher.group(2));
+ } else {
+ String newSuffix =
+ matcher.group(2).substring(0, 1).toLowerCase() + matcher.group(2).substring(1);
+
+ entry = entry.withKey(newPropertyKey + "." + newSuffix);
+ }
+ }
+
+ return super.visitEntry(entry, p);
+ }
+ }
+
+ public String getOldPropertyKey() {
+ return oldPropertyKey;
+ }
+
+ public void setOldPropertyKey(String oldPropertyKey) {
+ this.oldPropertyKey = oldPropertyKey;
+ }
+
+ public String getNewPropertyKey() {
+ return newPropertyKey;
+ }
+
+ public void setNewPropertyKey(String newPropertyKey) {
+ this.newPropertyKey = newPropertyKey;
+ }
+
+ public List<String> getExclusions() {
+ return exclusions;
+ }
+
+ public void setExclusions(List<String> exclusions) {
+ this.exclusions = exclusions;
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
index 6ffb196..88139ec 100644
--- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
@@ -29,6 +29,7 @@ recipeList:
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
- org.apache.camel.upgrade.UpgradeToJava17
- org.apache.camel.upgrade.JavaVersion17
+ - org.apache.camel.upgrade.CamelPropertiesAndYamlUpdate
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: 'org.apache.camel'
artifactId: '*'
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java
new file mode 100644
index 0000000..cfc0f7f
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.upgrade;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.properties.Assertions.properties;
+import static org.openrewrite.yaml.Assertions.yaml;
+
+public class CamelPropertiesTest implements RewriteTest {
+
+ @Test
+ void propertiesFile() {
+ rewriteRun(
+ recipeSpec -> recipeSpec.recipes(
+ new CamelPropertiesAndYamlUpdate()),
+ properties(
+ """
+ camel.main.routeControllerSuperviseEnabled=true
+ another.ignored.property=true
+ camel.springboot.name = Foo
+ camel.springboot.main-run-controller=Should be ignored!
+ camel.main.routeControllerBackOffMultiplier=5
+ camel.springboot.routeControllerInitialDelay = 5000
+ camel.springboot.routeControllerBackoffDelay = 5000
+ camel.springboot.routeControllerBackoffMaxAttempts = 10
+ """,
+ """
+ camel.routecontroller.enabled=true
+ another.ignored.property=true
+ camel.main.name = Foo
+ camel.springboot.main-run-controller=Should be ignored!
+ camel.routecontroller.backOffMultiplier=5
+ camel.routecontroller.initialDelay = 5000
+ camel.routecontroller.backOffDelay = 5000
+ camel.routecontroller.backOffMaxAttempts = 10
+ """
+ )
+ );
+ }
+
+ @Test
+ void yamlFile() {
+ rewriteRun(
+ recipeSpec -> recipeSpec.recipes(
+ new CamelPropertiesAndYamlUpdate()),
+ yaml(
+ """
+ camel:
+ springboot:
+ main-run-controller: 'Should be ignored!'
+ name: 'Foo'
+ routeControllerBackOffDelay: true
+ main:
+ routeControllerBackOffMultiplier: 5
+ another:
+ ignored:
+ property: true
+ """,
+ """
+ camel:
+ main:
+ name: 'Foo'
+ routecontroller.backOffMultiplier: 5
+ routecontroller.backOffDelay: true
+ springboot.main-run-controller: 'Should be ignored!'
+ another:
+ ignored:
+ property: true
+ """
+ )
+ );
+ }
+
+
+}
(camel-upgrade-recipes) 02/03: Enumerate value changes in yaml file
Posted by fm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
commit 8f5e0f2d6c19bf561188ca46d5dc7dbd22b3bce9
Author: Croway <fe...@gmail.com>
AuthorDate: Wed Feb 26 17:13:46 2025 +0100
Enumerate value changes in yaml file
---
.../src/main/resources/META-INF/rewrite/4.10.yaml | 2 +-
.../main/resources/META-INF/rewrite/latest.yaml | 2 +-
.../upgrade/CamelPropertiesAndYamlUpdate.java | 151 ---------------------
.../upgrade/PatternMatcherChangePropertyKey.java | 127 -----------------
.../ChangePropertyKeyWithCaseChange.java | 14 ++
.../customRecipes/PropertiesAndYamlKeyUpdate.java | 45 ++++++
.../main/resources/META-INF/rewrite/latest.yaml | 2 +-
.../resources/META-INF/rewrite/properties.yaml | 100 ++++++++++++++
.../apache/camel/upgrade/CamelPropertiesTest.java | 25 +++-
9 files changed, 183 insertions(+), 285 deletions(-)
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
index 784e03f..4c22e14 100644
--- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
@@ -28,7 +28,7 @@ recipeList:
- org.apache.camel.upgrade.camel45.CamelMigrationRecipe
- org.apache.camel.upgrade.camel44.CamelMigrationRecipe
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
- - org.apache.camel.upgrade.CamelPropertiesAndYamlUpdate
+ - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: '*camel*'
artifactId: 'camel-spring-boot-bom'
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
index 0ec8f3f..ce22485 100644
--- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
@@ -30,7 +30,7 @@ recipeList:
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
- org.apache.camel.upgrade.UpgradeToJava17
- org.apache.camel.upgrade.JavaVersion17
- - org.apache.camel.upgrade.CamelPropertiesAndYamlUpdate
+ - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: '*camel*'
artifactId: 'camel-spring-boot-bom'
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/CamelPropertiesAndYamlUpdate.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/CamelPropertiesAndYamlUpdate.java
deleted file mode 100644
index 7927154..0000000
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/CamelPropertiesAndYamlUpdate.java
+++ /dev/null
@@ -1,151 +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.upgrade;
-
-import org.openrewrite.Recipe;
-import org.openrewrite.properties.ChangePropertyKey;
-import org.openrewrite.yaml.ChangeKey;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Recipe for updating Apache Camel configuration properties and YAML keys.
- * <p>
- * This recipe handles the migration of Apache Camel configuration keys according to updated
- * naming conventions while preserving their values. It focuses on three main types of changes:
- * <ul>
- * <li>Converting 'camel.springboot.*' prefixes to 'camel.main.*'</li>
- * <li>Converting 'camel.routeController.*' to lowercase 'camel.routecontroller.*'</li>
- * <li>Moving tracing-related properties from 'camel.main' to 'camel.trace'</li>
- * <li>Preserving specific properties that should keep the 'springboot' prefix</li>
- * </ul>
- *
- */
-public class CamelPropertiesAndYamlUpdate extends Recipe {
-
- @Override
- public String getDisplayName() {
- return "Change Apache Camel properties key";
- }
-
- @Override
- public String getDescription() {
- return "Change Apache Camel properties and YAML keys leaving the value intact.";
- }
-
- @Override
- public List<Recipe> getRecipeList() {
- List<Recipe> recipes = new ArrayList<>();
- // camel.springboot.* to camel.main.* updates
- UpdateSpringBootToMain(recipes);
-
- // camel.routeController.* to camel.routecontroller.* updates
- routeController(recipes);
- // camel.main to camel.trace
- trace(recipes);
-
- // Some properties need the springboot prefix, let's fix those
- FixMainToSpringBoot(recipes);
-
- return recipes;
- }
-
- private void trace(List<Recipe> recipes) {
- fullConfigurationUpdate(recipes, Map.of(
- "camel.main.backlogTracing", "camel.trace.enabled",
- "camel.main.backlogTracingStandby", "camel.trace.backlogTracingStandby",
- "camel.main.backlogTracingTemplates", "camel.trace.backlogTracingTemplates"));
- }
-
- private void routeController(List<Recipe> recipes) {
- Map<String, String> oldNewProperties = new HashMap<>();
- // Special configurations
- oldNewProperties.putAll(Map.of(
- "camel.main.routeControllerSuperviseEnabled", "camel.routecontroller.enabled",
- "camel.springboot.routeControllerSuperviseEnabled", "camel.routecontroller.enabled",
- "camel.main.backlogTracing", "camel.trace.enabled",
- "camel.main.backlogTracingStandby", "camel.trace.backlogTracingStandby",
- "camel.main.backlogTracingTemplates", "camel.trace.backlogTracingTemplates"
- ));
- // Common configurations
- oldNewProperties.putAll(Map.of(
- "camel.main.routeControllerInitialDelay", "camel.routecontroller.initialDelay",
- "camel.main.routeControllerBackOffDelay", "camel.routecontroller.backOffDelay",
- "camel.main.routeControllerBackOffMaxAttempts", "camel.routecontroller.backOffMaxAttempts",
- "camel.main.routeControllerBackOffMaxDelay", "camel.routecontroller.backOffMaxDelay",
- "camel.main.routeControllerBackOffMaxElapsedTime", "camel.routecontroller.backOffMaxElapsedTime",
- "camel.main.routeControllerBackOffMultiplier", "camel.routecontroller.backOffMultiplier",
- "camel.main.routeControllerIncludeRoutes", "camel.routecontroller.includeRoutes",
- "camel.main.routeControllerExcludeRoutes", "camel.routecontroller.excludeRoutes",
- "camel.main.routeControllerThreadPoolSize", "camel.routecontroller.threadPoolSize"
- )
- );
-
- // sometimes, backoff is mispelled.....
- oldNewProperties.putAll(Map.of(
- "camel.main.routeControllerBackoffDelay", "camel.routecontroller.backOffDelay",
- "camel.main.routeControllerBackoffMaxAttempts", "camel.routecontroller.backOffMaxAttempts",
- "camel.main.routeControllerBackoffMaxDelay", "camel.routecontroller.backOffMaxDelay",
- "camel.main.routeControllerBackoffMaxElapsedTime", "camel.routecontroller.backOffMaxElapsedTime",
- "camel.main.routeControllerBackoffMultiplier", "camel.routecontroller.backOffMultiplier"
- ));
-
- fullConfigurationUpdate(recipes, oldNewProperties);
- }
-
- private static void fullConfigurationUpdate(List<Recipe> recipes, Map<String, String> oldNewProperties) {
- for (Map.Entry<String, String> entry : oldNewProperties.entrySet()) {
- recipes.add(
- new ChangePropertyKey(entry.getKey(), entry.getValue(),
- null, null)
- );
- recipes.add(
- new org.openrewrite.yaml.ChangePropertyKey(
- entry.getKey(), entry.getValue(), null, null, null)
- );
- }
- }
-
- private void FixMainToSpringBoot(List<Recipe> recipes) {
- fullConfigurationUpdate(recipes, Map.of(
- "camel.main.main-run-controller", "camel.springboot.main-run-controller",
- "camel.main.include-non-singletons", "camel.springboot.include-non-singletons",
- "camel.main.warn-on-early-shutdown", "camel.springboot.warn-on-early-shutdown",
- "camel.main.mainRunController", "camel.springboot.main-run-controller",
- "camel.main.includeNonSingletons", "camel.springboot.include-non-singletons",
- "camel.main.warnOnEarlyShutdown", "camel.springboot.warn-on-early-shutdown"
- ));
- }
-
- private static void UpdateSpringBootToMain(List<Recipe> recipes) {
- recipes.add(
- new PatternMatcherChangePropertyKey(
- "camel.springboot", "camel.main", List.of(
- "camel.springboot.main-run-controller",
- "camel.springboot.include-non-singletons",
- "camel.springboot.warn-on-early-shutdown"
- ))
- );
-
- recipes.add(
- new ChangeKey("$.camel.springboot", "main")
- );
- }
-}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/PatternMatcherChangePropertyKey.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/PatternMatcherChangePropertyKey.java
deleted file mode 100644
index 2eb0f63..0000000
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/PatternMatcherChangePropertyKey.java
+++ /dev/null
@@ -1,127 +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.upgrade;
-
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Option;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.properties.PropertiesVisitor;
-import org.openrewrite.properties.tree.Properties;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A recipe that changes property keys in property files by replacing a specified key prefix
- * and applying CamelCase formatting to any remaining suffix.
- */
-public class PatternMatcherChangePropertyKey extends Recipe {
-
- @Option(displayName = "Old property key",
- description = "The property key to rename.",
- example = "management.metrics.binders.files.enabled")
- String oldPropertyKey;
-
- @Option(displayName = "New property key",
- description = "The new name for the key identified by `oldPropertyKey`.",
- example = "management.metrics.enable.process.files")
- String newPropertyKey;
-
- @Option(displayName = "Exclusions",
- description = "Regexp for exclusions",
- example = "camel.springboot.main-run-controller")
- List<String> exclusions = new ArrayList<>();
-
- public PatternMatcherChangePropertyKey() {}
-
- public PatternMatcherChangePropertyKey(String oldPropertyKey, String newPropertyKey, List<String> exclusions) {
- this.oldPropertyKey = oldPropertyKey;
- this.newPropertyKey = newPropertyKey;
- this.exclusions = exclusions == null ? new ArrayList<>() : exclusions;
- }
-
- @Override
- public String getDisplayName() {
- return "Change property key and apply CamelCase format";
- }
-
- @Override
- public String getDescription() {
- return "Change property key applying CamelCase format leaving the value intact.";
- }
-
- @Override
- public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new PatternMatcherChangePropertyKey.ChangePropertyKeyVisitor<>();
- }
-
- public class ChangePropertyKeyVisitor<P> extends PropertiesVisitor<P> {
- public ChangePropertyKeyVisitor() {
- }
-
- @Override
- public Properties visitEntry(Properties.Entry entry, P p) {
- for (String exclusion : exclusions) {
- if (entry.getKey().equals(exclusion)) {
- return super.visitEntry(entry, p);
- }
- }
-
- Pattern pattern = Pattern.compile("(" + oldPropertyKey + ")" + "(.*)");
- Matcher matcher = pattern.matcher(entry.getKey());
- if (matcher.find()) {
- if(matcher.group(2).startsWith(".")) {
- entry = entry.withKey(newPropertyKey + matcher.group(2));
- } else {
- String newSuffix =
- matcher.group(2).substring(0, 1).toLowerCase() + matcher.group(2).substring(1);
-
- entry = entry.withKey(newPropertyKey + "." + newSuffix);
- }
- }
-
- return super.visitEntry(entry, p);
- }
- }
-
- public String getOldPropertyKey() {
- return oldPropertyKey;
- }
-
- public void setOldPropertyKey(String oldPropertyKey) {
- this.oldPropertyKey = oldPropertyKey;
- }
-
- public String getNewPropertyKey() {
- return newPropertyKey;
- }
-
- public void setNewPropertyKey(String newPropertyKey) {
- this.newPropertyKey = newPropertyKey;
- }
-
- public List<String> getExclusions() {
- return exclusions;
- }
-
- public void setExclusions(List<String> exclusions) {
- this.exclusions = exclusions;
- }
-}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ChangePropertyKeyWithCaseChange.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ChangePropertyKeyWithCaseChange.java
index 0d778a6..9afcf37 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ChangePropertyKeyWithCaseChange.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ChangePropertyKeyWithCaseChange.java
@@ -27,6 +27,9 @@ import org.openrewrite.Recipe;
import org.openrewrite.properties.PropertiesVisitor;
import org.openrewrite.properties.tree.Properties;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Replaces prefix with the new one and changes the suffix tp start with lower case
*/
@@ -44,6 +47,11 @@ public class ChangePropertyKeyWithCaseChange extends Recipe {
description = "The prefix to be replaced with.")
String newPrefix;
+ @Option(displayName = "Exclusions",
+ description = "Regexp for exclusions",
+ example = "camel.springboot.main-run-controller")
+ List<String> exclusions = new ArrayList<>();
+
@Override
public String getDisplayName() {
return "Change prefix of property with Camel case";
@@ -59,6 +67,12 @@ public class ChangePropertyKeyWithCaseChange extends Recipe {
return new PropertiesVisitor<>() {
@Override
public Properties visitEntry(Properties.Entry entry, ExecutionContext p) {
+ for (String exclusion : exclusions) {
+ if (entry.getKey().equals(exclusion)) {
+ return super.visitEntry(entry, p);
+ }
+ }
+
if (entry.getKey().matches(oldPropertyKey)) {
entry = entry.withKey(getKey(entry))
.withPrefix(entry.getPrefix());
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/PropertiesAndYamlKeyUpdate.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/PropertiesAndYamlKeyUpdate.java
new file mode 100644
index 0000000..e9270a3
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/PropertiesAndYamlKeyUpdate.java
@@ -0,0 +1,45 @@
+package org.apache.camel.upgrade.customRecipes;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import org.openrewrite.NlsRewrite;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.properties.ChangePropertyKey;
+
+import java.util.List;
+
+@EqualsAndHashCode(callSuper = false)
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Setter
+public class PropertiesAndYamlKeyUpdate extends Recipe {
+
+ @Option(displayName = "Old configuration key",
+ description = "The configuration key to rename.")
+ String oldPropertyKey;
+
+ @Option(displayName = "New configuration key",
+ description = "The configuration to be replaced with.")
+ String newPropertyKey;
+
+ @Override
+ public @NlsRewrite.DisplayName String getDisplayName() {
+ return "Update Apache Camel configurations keys";
+ }
+
+ @Override
+ public @NlsRewrite.Description String getDescription() {
+ return "Update Apache Camel configurations keys";
+ }
+
+ @Override
+ public List<Recipe> getRecipeList() {
+ return List.of(new ChangePropertyKey(oldPropertyKey, newPropertyKey,
+ null, null),
+ new org.openrewrite.yaml.ChangePropertyKey(
+ oldPropertyKey, newPropertyKey, null, null, null));
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
index 88139ec..41f6065 100644
--- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
@@ -29,7 +29,7 @@ recipeList:
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
- org.apache.camel.upgrade.UpgradeToJava17
- org.apache.camel.upgrade.JavaVersion17
- - org.apache.camel.upgrade.CamelPropertiesAndYamlUpdate
+ - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: 'org.apache.camel'
artifactId: '*'
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml
new file mode 100644
index 0000000..5f01b55
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml
@@ -0,0 +1,100 @@
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
+displayName: Update properties and yaml configurations file
+description: Update properties and yaml configurations file.
+recipeList:
+ - org.apache.camel.upgrade.customRecipes.ChangePropertyKeyWithCaseChange:
+ oldPropertyKey: camel.springboot(.*)
+ newPrefix: camel.main
+ exclusions:
+ - camel.springboot.main-run-controller
+ - camel.springboot.include-non-singletons
+ - camel.springboot.warn-on-early-shutdown
+ - org.openrewrite.yaml.ChangeKey:
+ oldKeyPath: $.camel.springboot
+ newKey: main
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerInitialDelay
+ newPropertyKey: camel.routecontroller.initialDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingTemplates
+ newPropertyKey: camel.trace.backlogTracingTemplates
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerThreadPoolSize
+ newPropertyKey: camel.routecontroller.threadPoolSize
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMultiplier
+ newPropertyKey: camel.routecontroller.backOffMultiplier
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracing
+ newPropertyKey: camel.trace.enabled
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerExcludeRoutes
+ newPropertyKey: camel.routecontroller.excludeRoutes
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMultiplier
+ newPropertyKey: camel.routecontroller.backOffMultiplier
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingStandby
+ newPropertyKey: camel.trace.backlogTracingStandby
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMaxAttempts
+ newPropertyKey: camel.routecontroller.backOffMaxAttempts
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.springboot.routeControllerSuperviseEnabled
+ newPropertyKey: camel.routecontroller.enabled
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerSuperviseEnabled
+ newPropertyKey: camel.routecontroller.enabled
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMaxDelay
+ newPropertyKey: camel.routecontroller.backOffMaxDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffDelay
+ newPropertyKey: camel.routecontroller.backOffDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMaxAttempts
+ newPropertyKey: camel.routecontroller.backOffMaxAttempts
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffDelay
+ newPropertyKey: camel.routecontroller.backOffDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMaxElapsedTime
+ newPropertyKey: camel.routecontroller.backOffMaxElapsedTime
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMaxDelay
+ newPropertyKey: camel.routecontroller.backOffMaxDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerIncludeRoutes
+ newPropertyKey: camel.routecontroller.includeRoutes
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMaxElapsedTime
+ newPropertyKey: camel.routecontroller.backOffMaxElapsedTime
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingTemplates
+ newPropertyKey: camel.trace.backlogTracingTemplates
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingStandby
+ newPropertyKey: camel.trace.backlogTracingStandby
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracing
+ newPropertyKey: camel.trace.enabled
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.include-non-singletons
+ newPropertyKey: camel.springboot.include-non-singletons
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.includeNonSingletons
+ newPropertyKey: camel.springboot.include-non-singletons
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.mainRunController
+ newPropertyKey: camel.springboot.main-run-controller
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.main-run-controller
+ newPropertyKey: camel.springboot.main-run-controller
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.warnOnEarlyShutdown
+ newPropertyKey: camel.springboot.warn-on-early-shutdown
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.warn-on-early-shutdown
+ newPropertyKey: camel.springboot.warn-on-early-shutdown
+
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java
index cfc0f7f..9aeb8a1 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java
@@ -19,6 +19,9 @@ package org.apache.camel.upgrade;
import org.junit.jupiter.api.Test;
import org.openrewrite.test.RewriteTest;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
import static org.openrewrite.properties.Assertions.properties;
import static org.openrewrite.yaml.Assertions.yaml;
@@ -27,8 +30,15 @@ public class CamelPropertiesTest implements RewriteTest {
@Test
void propertiesFile() {
rewriteRun(
- recipeSpec -> recipeSpec.recipes(
- new CamelPropertiesAndYamlUpdate()),
+ recipeSpec -> {
+ try {
+ recipeSpec.recipe(
+ new FileInputStream("src/main/resources/META-INF/rewrite/properties.yaml"),
+ "org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys");
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ },
properties(
"""
camel.main.routeControllerSuperviseEnabled=true
@@ -57,8 +67,15 @@ public class CamelPropertiesTest implements RewriteTest {
@Test
void yamlFile() {
rewriteRun(
- recipeSpec -> recipeSpec.recipes(
- new CamelPropertiesAndYamlUpdate()),
+ recipeSpec -> {
+ try {
+ recipeSpec.recipe(
+ new FileInputStream("src/main/resources/META-INF/rewrite/properties.yaml"),
+ "org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys");
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ },
yaml(
"""
camel:
(camel-upgrade-recipes) 03/03: Move spring boot related keys in spring boot project
Posted by fm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
commit 4d9f49b2c6ca7179cd3ab6704ddf642044bff5cc
Author: Croway <fe...@gmail.com>
AuthorDate: Wed Feb 26 17:52:44 2025 +0100
Move spring boot related keys in spring boot project
---
camel-spring-boot-upgrade-recipes/pom.xml | 17 ++++
.../src/main/resources/META-INF/rewrite/4.10.yaml | 2 +-
.../main/resources/META-INF/rewrite/latest.yaml | 2 +-
.../resources/META-INF/rewrite/properties.yaml | 39 ++++++++
.../springboot/CamelSpringBootPropertiesTest.java | 96 ++++++++++++++++++
.../src/main/resources/META-INF/rewrite/4.10.yaml | 72 +++++++++++++-
.../resources/META-INF/rewrite/properties.yaml | 100 -------------------
.../apache/camel/upgrade/CamelPropertiesTest.java | 108 ---------------------
.../apache/camel/upgrade/CamelUpdate410Test.java | 19 ++++
9 files changed, 244 insertions(+), 211 deletions(-)
diff --git a/camel-spring-boot-upgrade-recipes/pom.xml b/camel-spring-boot-upgrade-recipes/pom.xml
index 6268177..b39b277 100644
--- a/camel-spring-boot-upgrade-recipes/pom.xml
+++ b/camel-spring-boot-upgrade-recipes/pom.xml
@@ -22,6 +22,7 @@
<parent>
<groupId>org.apache.camel.upgrade</groupId>
<artifactId>camel-parent-upgrade-recipes</artifactId>
+ <relativePath>../pom.xml</relativePath>
<version>4.11.0-SNAPSHOT</version>
</parent>
@@ -42,6 +43,22 @@
<artifactId>camel-upgrade-recipes</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.openrewrite</groupId>
+ <artifactId>rewrite-yaml</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openrewrite</groupId>
+ <artifactId>rewrite-properties</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openrewrite</groupId>
+ <artifactId>rewrite-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
index 4c22e14..0b4523e 100644
--- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
@@ -28,7 +28,7 @@ recipeList:
- org.apache.camel.upgrade.camel45.CamelMigrationRecipe
- org.apache.camel.upgrade.camel44.CamelMigrationRecipe
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
- - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
+ - org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: '*camel*'
artifactId: 'camel-spring-boot-bom'
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
index ce22485..b5a906e 100644
--- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
@@ -30,7 +30,7 @@ recipeList:
- org.apache.camel.upgrade.camel40.CamelMigrationRecipe
- org.apache.camel.upgrade.UpgradeToJava17
- org.apache.camel.upgrade.JavaVersion17
- - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
+ - org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: '*camel*'
artifactId: 'camel-spring-boot-bom'
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml
new file mode 100644
index 0000000..a60a43e
--- /dev/null
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml
@@ -0,0 +1,39 @@
+---
+# Let's keep it here, yaml recipes cannot be tested across modules
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys
+displayName: Update Camel Spring Boot properties and yaml configurations file
+description: Update Camel Spring Boot properties and yaml configurations file.
+recipeList:
+ - org.apache.camel.upgrade.customRecipes.ChangePropertyKeyWithCaseChange:
+ oldPropertyKey: camel.springboot(.*)
+ newPrefix: camel.main
+ exclusions:
+ - camel.springboot.main-run-controller
+ - camel.springboot.include-non-singletons
+ - camel.springboot.warn-on-early-shutdown
+ - org.openrewrite.yaml.ChangeKey:
+ oldKeyPath: $.camel.springboot
+ newKey: main
+ - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.springboot.routeControllerSuperviseEnabled
+ newPropertyKey: camel.routecontroller.enabled
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.include-non-singletons
+ newPropertyKey: camel.springboot.include-non-singletons
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.includeNonSingletons
+ newPropertyKey: camel.springboot.include-non-singletons
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.mainRunController
+ newPropertyKey: camel.springboot.main-run-controller
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.main-run-controller
+ newPropertyKey: camel.springboot.main-run-controller
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.warnOnEarlyShutdown
+ newPropertyKey: camel.springboot.warn-on-early-shutdown
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.warn-on-early-shutdown
+ newPropertyKey: camel.springboot.warn-on-early-shutdown
\ No newline at end of file
diff --git a/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/CamelSpringBootPropertiesTest.java b/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/CamelSpringBootPropertiesTest.java
new file mode 100644
index 0000000..6e15747
--- /dev/null
+++ b/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/CamelSpringBootPropertiesTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.upgrade.springboot;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.config.Environment;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.properties.Assertions.properties;
+import static org.openrewrite.yaml.Assertions.yaml;
+
+public class CamelSpringBootPropertiesTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(Environment.builder()
+ .scanYamlResources()
+ .build()
+ .activateRecipes("org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys"));
+ }
+
+ @Test
+ void propertiesFile() {
+ rewriteRun(
+ properties(
+ """
+ camel.main.routeControllerSuperviseEnabled=true
+ another.ignored.property=true
+ camel.springboot.name = Foo
+ camel.springboot.main-run-controller=Should be ignored!
+ camel.main.routeControllerBackOffMultiplier=5
+ camel.springboot.routeControllerInitialDelay = 5000
+ camel.springboot.routeControllerBackoffDelay = 5000
+ camel.springboot.routeControllerBackoffMaxAttempts = 10
+ """,
+ """
+ camel.routecontroller.enabled=true
+ another.ignored.property=true
+ camel.main.name = Foo
+ camel.springboot.main-run-controller=Should be ignored!
+ camel.routecontroller.backOffMultiplier=5
+ camel.routecontroller.initialDelay = 5000
+ camel.routecontroller.backOffDelay = 5000
+ camel.routecontroller.backOffMaxAttempts = 10
+ """
+ )
+ );
+ }
+
+ @Test
+ void yamlFile() {
+ rewriteRun(
+ yaml(
+ """
+ camel:
+ springboot:
+ main-run-controller: 'Should be ignored!'
+ name: 'Foo'
+ routeControllerBackOffDelay: true
+ main:
+ routeControllerBackOffMultiplier: 5
+ another:
+ ignored:
+ property: true
+ """,
+ """
+ camel:
+ main:
+ name: 'Foo'
+ routecontroller.backOffMultiplier: 5
+ routecontroller.backOffDelay: true
+ springboot.main-run-controller: 'Should be ignored!'
+ another:
+ ignored:
+ property: true
+ """
+ )
+ );
+ }
+
+}
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
index 28383c6..3dbec78 100644
--- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml
@@ -31,6 +31,7 @@ recipeList:
- org.apache.camel.upgrade.camel410.XmlDsl410Recipe
- org.apache.camel.upgrade.camel410.camelSmb
- org.apache.camel.upgrade.camel410.camelAzureFiles
+ - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
---
#https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc#camel-azure-files
type: specs.openrewrite.org/v1beta/recipe
@@ -50,4 +51,73 @@ description: Renamed constants in camel-smb.
recipeList:
- org.openrewrite.java.ReplaceConstantWithAnotherConstant:
existingFullyQualifiedConstantName: org.apache.camel.component.smb.SmbConstants.SMB_FILE_PATH
- fullyQualifiedConstantName: org.apache.camel.component.smb.SmbConstants.FILE_PATH
\ No newline at end of file
+ fullyQualifiedConstantName: org.apache.camel.component.smb.SmbConstants.FILE_PATH
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
+displayName: Update properties and yaml configurations file
+description: Update properties and yaml configurations file.
+recipeList:
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerInitialDelay
+ newPropertyKey: camel.routecontroller.initialDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingTemplates
+ newPropertyKey: camel.trace.backlogTracingTemplates
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerThreadPoolSize
+ newPropertyKey: camel.routecontroller.threadPoolSize
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMultiplier
+ newPropertyKey: camel.routecontroller.backOffMultiplier
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracing
+ newPropertyKey: camel.trace.enabled
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerExcludeRoutes
+ newPropertyKey: camel.routecontroller.excludeRoutes
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMultiplier
+ newPropertyKey: camel.routecontroller.backOffMultiplier
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingStandby
+ newPropertyKey: camel.trace.backlogTracingStandby
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMaxAttempts
+ newPropertyKey: camel.routecontroller.backOffMaxAttempts
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerSuperviseEnabled
+ newPropertyKey: camel.routecontroller.enabled
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMaxDelay
+ newPropertyKey: camel.routecontroller.backOffMaxDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffDelay
+ newPropertyKey: camel.routecontroller.backOffDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMaxAttempts
+ newPropertyKey: camel.routecontroller.backOffMaxAttempts
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffDelay
+ newPropertyKey: camel.routecontroller.backOffDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackOffMaxElapsedTime
+ newPropertyKey: camel.routecontroller.backOffMaxElapsedTime
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMaxDelay
+ newPropertyKey: camel.routecontroller.backOffMaxDelay
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerIncludeRoutes
+ newPropertyKey: camel.routecontroller.includeRoutes
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.routeControllerBackoffMaxElapsedTime
+ newPropertyKey: camel.routecontroller.backOffMaxElapsedTime
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingTemplates
+ newPropertyKey: camel.trace.backlogTracingTemplates
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracingStandby
+ newPropertyKey: camel.trace.backlogTracingStandby
+ - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
+ oldPropertyKey: camel.main.backlogTracing
+ newPropertyKey: camel.trace.enabled
\ No newline at end of file
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml
deleted file mode 100644
index 5f01b55..0000000
--- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml
+++ /dev/null
@@ -1,100 +0,0 @@
-type: specs.openrewrite.org/v1beta/recipe
-name: org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys
-displayName: Update properties and yaml configurations file
-description: Update properties and yaml configurations file.
-recipeList:
- - org.apache.camel.upgrade.customRecipes.ChangePropertyKeyWithCaseChange:
- oldPropertyKey: camel.springboot(.*)
- newPrefix: camel.main
- exclusions:
- - camel.springboot.main-run-controller
- - camel.springboot.include-non-singletons
- - camel.springboot.warn-on-early-shutdown
- - org.openrewrite.yaml.ChangeKey:
- oldKeyPath: $.camel.springboot
- newKey: main
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerInitialDelay
- newPropertyKey: camel.routecontroller.initialDelay
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.backlogTracingTemplates
- newPropertyKey: camel.trace.backlogTracingTemplates
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerThreadPoolSize
- newPropertyKey: camel.routecontroller.threadPoolSize
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackOffMultiplier
- newPropertyKey: camel.routecontroller.backOffMultiplier
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.backlogTracing
- newPropertyKey: camel.trace.enabled
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerExcludeRoutes
- newPropertyKey: camel.routecontroller.excludeRoutes
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackoffMultiplier
- newPropertyKey: camel.routecontroller.backOffMultiplier
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.backlogTracingStandby
- newPropertyKey: camel.trace.backlogTracingStandby
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackOffMaxAttempts
- newPropertyKey: camel.routecontroller.backOffMaxAttempts
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.springboot.routeControllerSuperviseEnabled
- newPropertyKey: camel.routecontroller.enabled
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerSuperviseEnabled
- newPropertyKey: camel.routecontroller.enabled
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackOffMaxDelay
- newPropertyKey: camel.routecontroller.backOffMaxDelay
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackOffDelay
- newPropertyKey: camel.routecontroller.backOffDelay
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackoffMaxAttempts
- newPropertyKey: camel.routecontroller.backOffMaxAttempts
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackoffDelay
- newPropertyKey: camel.routecontroller.backOffDelay
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackOffMaxElapsedTime
- newPropertyKey: camel.routecontroller.backOffMaxElapsedTime
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackoffMaxDelay
- newPropertyKey: camel.routecontroller.backOffMaxDelay
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerIncludeRoutes
- newPropertyKey: camel.routecontroller.includeRoutes
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.routeControllerBackoffMaxElapsedTime
- newPropertyKey: camel.routecontroller.backOffMaxElapsedTime
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.backlogTracingTemplates
- newPropertyKey: camel.trace.backlogTracingTemplates
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.backlogTracingStandby
- newPropertyKey: camel.trace.backlogTracingStandby
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.backlogTracing
- newPropertyKey: camel.trace.enabled
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.include-non-singletons
- newPropertyKey: camel.springboot.include-non-singletons
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.includeNonSingletons
- newPropertyKey: camel.springboot.include-non-singletons
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.mainRunController
- newPropertyKey: camel.springboot.main-run-controller
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.main-run-controller
- newPropertyKey: camel.springboot.main-run-controller
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.warnOnEarlyShutdown
- newPropertyKey: camel.springboot.warn-on-early-shutdown
- - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate:
- oldPropertyKey: camel.main.warn-on-early-shutdown
- newPropertyKey: camel.springboot.warn-on-early-shutdown
-
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java
deleted file mode 100644
index 9aeb8a1..0000000
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java
+++ /dev/null
@@ -1,108 +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.upgrade;
-
-import org.junit.jupiter.api.Test;
-import org.openrewrite.test.RewriteTest;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-import static org.openrewrite.properties.Assertions.properties;
-import static org.openrewrite.yaml.Assertions.yaml;
-
-public class CamelPropertiesTest implements RewriteTest {
-
- @Test
- void propertiesFile() {
- rewriteRun(
- recipeSpec -> {
- try {
- recipeSpec.recipe(
- new FileInputStream("src/main/resources/META-INF/rewrite/properties.yaml"),
- "org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys");
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- },
- properties(
- """
- camel.main.routeControllerSuperviseEnabled=true
- another.ignored.property=true
- camel.springboot.name = Foo
- camel.springboot.main-run-controller=Should be ignored!
- camel.main.routeControllerBackOffMultiplier=5
- camel.springboot.routeControllerInitialDelay = 5000
- camel.springboot.routeControllerBackoffDelay = 5000
- camel.springboot.routeControllerBackoffMaxAttempts = 10
- """,
- """
- camel.routecontroller.enabled=true
- another.ignored.property=true
- camel.main.name = Foo
- camel.springboot.main-run-controller=Should be ignored!
- camel.routecontroller.backOffMultiplier=5
- camel.routecontroller.initialDelay = 5000
- camel.routecontroller.backOffDelay = 5000
- camel.routecontroller.backOffMaxAttempts = 10
- """
- )
- );
- }
-
- @Test
- void yamlFile() {
- rewriteRun(
- recipeSpec -> {
- try {
- recipeSpec.recipe(
- new FileInputStream("src/main/resources/META-INF/rewrite/properties.yaml"),
- "org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys");
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- },
- yaml(
- """
- camel:
- springboot:
- main-run-controller: 'Should be ignored!'
- name: 'Foo'
- routeControllerBackOffDelay: true
- main:
- routeControllerBackOffMultiplier: 5
- another:
- ignored:
- property: true
- """,
- """
- camel:
- main:
- name: 'Foo'
- routecontroller.backOffMultiplier: 5
- routecontroller.backOffDelay: true
- springboot.main-run-controller: 'Should be ignored!'
- another:
- ignored:
- property: true
- """
- )
- );
- }
-
-
-}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java
index e09398f..b2226de 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java
@@ -24,6 +24,7 @@ import org.openrewrite.yaml.Assertions;
import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.maven.Assertions.pomXml;
+import static org.openrewrite.properties.Assertions.properties;
import static org.openrewrite.xml.Assertions.xml;
public class CamelUpdate410Test implements RewriteTest {
@@ -173,4 +174,22 @@ public class CamelUpdate410Test implements RewriteTest {
"""));
}
+ @Test
+ void propertiesFile() {
+ rewriteRun(
+ properties(
+ """
+ camel.main.routeControllerSuperviseEnabled=true
+ another.ignored.property=true
+ camel.main.routeControllerBackOffMultiplier=5
+ """,
+ """
+ camel.routecontroller.enabled=true
+ another.ignored.property=true
+ camel.routecontroller.backOffMultiplier=5
+ """
+ )
+ );
+ }
+
}