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 2026/06/24 09:46:20 UTC
(camel-upgrade-recipes) branch main updated: Upgrade camel to 4.18.3 and 4.20.0 (first part)
This is an automated email from the ASF dual-hosted git repository.
Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
The following commit(s) were added to refs/heads/main by this push:
new 570c07c Upgrade camel to 4.18.3 and 4.20.0 (first part)
570c07c is described below
commit 570c07c73c0bdf1961ce8e678e197dd286226022
Author: Jiri Ondrusek <on...@gmail.com>
AuthorDate: Mon Jun 1 09:37:20 2026 +0200
Upgrade camel to 4.18.3 and 4.20.0 (first part)
Co-Authored-By: JinyuChen97 <as...@gmail.com>
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../src/main/resources/META-INF/rewrite/4.21.yaml | 24 +
.../main/resources/META-INF/rewrite/latest.yaml | 2 +-
.../springboot/UpgradeSpringBoot3To4Test.java | 38 +-
camel-upgrade-recipes/pom.xml | 13 +
.../upgrade/camel40/java/CamelHttpRecipe.java | 3 -
.../camel40/yaml/CamelYamlStepsInFromRecipe.java | 4 -
.../camel/upgrade/camel41/CamelCoreRecipe.java | 3 -
.../apache/camel/upgrade/camel41/XmlDslRecipe.java | 1 -
.../upgrade/camel419/XmlDsl419SagaRecipe.java | 5 +-
.../camel421/RemoveReifierStrategyImport.java | 79 +++
.../RemoveZooWordEmbeddingPredictorImport.java | 80 +++
.../upgrade/camel421/RenameHeaderInJavaMethod.java | 131 +++++
.../camel421/RenameHeaderInSimpleExpression.java | 132 +++++
.../upgrade/camel421/RenameHeaderInXmlDsl.java | 113 ++++
.../upgrade/camel421/RenameHeaderInYamlDsl.java | 131 +++++
.../camel421/RenameHeaderPrefixInJavaMethod.java | 135 +++++
.../RenameHeaderPrefixInSimpleExpression.java | 133 +++++
.../camel421/RenameHeaderPrefixInXmlDsl.java | 116 ++++
.../camel421/RenameHeaderPrefixInYamlDsl.java | 134 +++++
.../upgrade/camel421/RenameHeaderPrefixes.java | 113 ++++
.../camel/upgrade/camel421/RenameHeaders.java | 147 ++++++
.../camel/upgrade/camel47/Java47Recipes.java | 2 -
.../MoveGetterToExtendedCamelContext.java | 9 -
.../customRecipes/MoveGetterToPluginHelper.java | 5 -
.../ReplacePropertyInDataFormatXml.java | 6 +-
.../main/resources/META-INF/rewrite/4.18.1.yaml | 50 ++
.../main/resources/META-INF/rewrite/4.18.3.yaml | 300 +++++++++++
.../src/main/resources/META-INF/rewrite/4.18.yaml | 80 +++
.../META-INF/rewrite/{latest.yaml => 4.18LTS.yaml} | 18 +-
.../src/main/resources/META-INF/rewrite/4.19.yaml | 5 +-
.../src/main/resources/META-INF/rewrite/4.21.yaml | 428 +++++++++++++++
.../main/resources/META-INF/rewrite/examples.yml | 254 +++++++++
.../main/resources/META-INF/rewrite/latest.yaml | 1 +
.../src/main/resources/versions.properties | 1 +
.../org/apache/camel/upgrade/CamelTestUtil.java | 43 +-
.../apache/camel/upgrade/CamelUpdate418Test.java | 144 ++++-
.../apache/camel/upgrade/CamelUpdate418_1Test.java | 153 ++++++
.../apache/camel/upgrade/CamelUpdate418_3Test.java | 577 ++++++++++++++++++++
.../apache/camel/upgrade/CamelUpdate419Test.java | 101 +---
.../apache/camel/upgrade/CamelUpdate421Test.java | 586 +++++++++++++++++++++
.../camel421/RenameHeaderInJavaMethodTest.java | 254 +++++++++
.../RenameHeaderInSimpleExpressionTest.java | 245 +++++++++
.../upgrade/camel421/RenameHeaderInXmlDslTest.java | 204 +++++++
.../camel421/RenameHeaderInYamlDslTest.java | 235 +++++++++
.../RenameHeaderPrefixInJavaMethodTest.java | 291 ++++++++++
.../RenameHeaderPrefixInSimpleExpressionTest.java | 249 +++++++++
.../camel421/RenameHeaderPrefixInXmlDslTest.java | 206 ++++++++
.../camel421/RenameHeaderPrefixInYamlDslTest.java | 233 ++++++++
.../camel/upgrade/camel421/RenameHeadersTest.java | 89 ++++
.../upgrade/suites/CamelUpdate410LtsTestSuite.java | 6 +-
.../upgrade/suites/CamelUpdate418LtsTestSuite.java | 59 +++
.../CamelUpdate410LtsVersionTest.java | 2 +-
.../CamelUpdate418LtsVersionTest.java} | 12 +-
.../CamelUpdateLatestVersionTest.java | 2 +-
pom.xml | 3 +-
release_notes.adoc | 156 ++++++
56 files changed, 6370 insertions(+), 176 deletions(-)
diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.21.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.21.yaml
new file mode 100644
index 0000000..1f275dd
--- /dev/null
+++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.21.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.CamelSpringBootMigrationRecipe
+displayName: Migrates Camel Spring Boot applications to Camel Spring Boot 4.21
+description: Migrates Camel Spring Boot applications to Camel Spring Boot 4.21.
+recipeList:
+ - org.apache.camel.upgrade.camel420.CamelSpringBootMigrationRecipe
+ - org.apache.camel.upgrade.camel421.CamelMigrationRecipe
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 a103901..e35f85a 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
@@ -21,7 +21,7 @@ displayName: Migrate to Apache Camel Spring Boot @camel-latest-version@
description: >-
Migrate applications to Apache Camel Spring Boot @camel-latest-version@ and Spring Boot @spring-boot-version@
recipeList:
- - org.apache.camel.upgrade.camel420.CamelSpringBootMigrationRecipe
+ - org.apache.camel.upgrade.camel421.CamelSpringBootMigrationRecipe
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: '*camel*'
artifactId: 'camel-spring-boot-bom'
diff --git a/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/UpgradeSpringBoot3To4Test.java b/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/UpgradeSpringBoot3To4Test.java
index 8a22c1e..09405b6 100644
--- a/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/UpgradeSpringBoot3To4Test.java
+++ b/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/UpgradeSpringBoot3To4Test.java
@@ -17,6 +17,7 @@
package org.apache.camel.upgrade.springboot;
import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
import org.openrewrite.config.Environment;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
@@ -33,8 +34,9 @@ class UpgradeSpringBoot3To4Test implements RewriteTest {
.activateRecipes("org.apache.camel.upgrade.spring.UpgradeSpringBoot3To4"));
}
+ @DocumentExample
@Test
- void javaVersionNotDowngraded() {
+ void javaVersionUpgradedFromOlder() {
rewriteRun(
//language=xml
pomXml(
@@ -45,22 +47,10 @@ class UpgradeSpringBoot3To4Test implements RewriteTest {
<artifactId>test</artifactId>
<version>1.0.0</version>
<properties>
- <java.version>21</java.version>
- <maven.compiler.source>21</maven.compiler.source>
- <maven.compiler.target>21</maven.compiler.target>
- <maven.compiler.release>21</maven.compiler.release>
+ <java.version>11</java.version>
</properties>
</project>
- """
- )
- );
- }
-
- @Test
- void javaVersionUpgradedFromOlder() {
- rewriteRun(
- //language=xml
- pomXml(
+ """,
"""
<project>
<modelVersion>4.0.0</modelVersion>
@@ -68,10 +58,19 @@ class UpgradeSpringBoot3To4Test implements RewriteTest {
<artifactId>test</artifactId>
<version>1.0.0</version>
<properties>
- <java.version>11</java.version>
+ <java.version>17</java.version>
</properties>
</project>
- """,
+ """
+ )
+ );
+ }
+
+ @Test
+ void javaVersionNotDowngraded() {
+ rewriteRun(
+ //language=xml
+ pomXml(
"""
<project>
<modelVersion>4.0.0</modelVersion>
@@ -79,7 +78,10 @@ class UpgradeSpringBoot3To4Test implements RewriteTest {
<artifactId>test</artifactId>
<version>1.0.0</version>
<properties>
- <java.version>17</java.version>
+ <java.version>21</java.version>
+ <maven.compiler.source>21</maven.compiler.source>
+ <maven.compiler.target>21</maven.compiler.target>
+ <maven.compiler.release>21</maven.compiler.release>
</properties>
</project>
"""
diff --git a/camel-upgrade-recipes/pom.xml b/camel-upgrade-recipes/pom.xml
index c49e2e8..aacf790 100644
--- a/camel-upgrade-recipes/pom.xml
+++ b/camel-upgrade-recipes/pom.xml
@@ -73,6 +73,11 @@
<artifactId>rewrite-maven</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.openrewrite.recipe</groupId>
+ <artifactId>rewrite-java-dependencies</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-yaml</artifactId>
@@ -604,6 +609,14 @@
<outputDirectory>${rewrite-tmp-classpath}</outputDirectory>
</artifactItem>
+ <!-- AWS SDK S3 for camel-aws2-s3 type migration tests -->
+ <artifactItem>
+ <groupId>software.amazon.awssdk</groupId>
+ <artifactId>s3</artifactId>
+ <version>2.20.0</version>
+ <outputDirectory>${rewrite-tmp-classpath}</outputDirectory>
+ </artifactItem>
+
</artifactItems>
</configuration>
</execution>
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/java/CamelHttpRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/java/CamelHttpRecipe.java
index 81d8a9a..3a2b3be 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/java/CamelHttpRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/java/CamelHttpRecipe.java
@@ -28,9 +28,6 @@ import org.openrewrite.java.tree.J;
public class CamelHttpRecipe extends Recipe {
- private static final String SET_CREDENTIALS = "org.apache.http.impl.client.BasicCredentialsProvider setCredentials(..)";
- private static final String SCOPE_ANY = "AuthScope.ANY";
-
@Override
public String getDisplayName() {
return "Camel Http Extension changes";
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/yaml/CamelYamlStepsInFromRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/yaml/CamelYamlStepsInFromRecipe.java
index a85d81f..60762fd 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/yaml/CamelYamlStepsInFromRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/yaml/CamelYamlStepsInFromRecipe.java
@@ -30,8 +30,6 @@ import org.openrewrite.yaml.format.IndentsVisitor;
import org.openrewrite.yaml.style.IndentsStyle;
import org.openrewrite.yaml.tree.Yaml;
-import java.util.List;
-
/**
* Fixes following yaml change.
*
@@ -58,8 +56,6 @@ import java.util.List;
* </pre>
*/
public class CamelYamlStepsInFromRecipe extends Recipe {
-
- private static final String[] PATHS_TO_PRE_CHECK = new String[] { "route.from" };
private static final JsonPathMatcher MATCHER_WITHOUT_ROUTE = new JsonPathMatcher("$.steps");
private static final JsonPathMatcher MATCHER_WITH_ROUTE = new JsonPathMatcher("$.route.steps");
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/CamelCoreRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/CamelCoreRecipe.java
index 39d8c75..1c9cae0 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/CamelCoreRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/CamelCoreRecipe.java
@@ -31,9 +31,6 @@ import java.util.regex.Pattern;
* <a href="https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core" >documentation</a>.
*/
public class CamelCoreRecipe extends Recipe {
-
- private static final String M_TO = "org.apache.camel.model.ProcessorDefinition to(..)";
- private static final String M_FROM = "org.apache.camel.model.ProcessorDefinition from(..)";
private static final String AWS2_URL_WITH_QUEUE_REGEXP = "(aws2-sns://[a-zA-z]+?.*)queueUrl=https://(.+)";
private static final Pattern AWS2_URL_WITH_QUEUE_URL = Pattern.compile(AWS2_URL_WITH_QUEUE_REGEXP);
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/XmlDslRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/XmlDslRecipe.java
index 54610f3..0bfa9c1 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/XmlDslRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel41/XmlDslRecipe.java
@@ -26,7 +26,6 @@ import org.openrewrite.marker.Markers;
import org.openrewrite.xml.XPathMatcher;
import org.openrewrite.xml.tree.Xml;
-import java.util.List;
import java.util.Optional;
/**
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel419/XmlDsl419SagaRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel419/XmlDsl419SagaRecipe.java
index 70829d3..a37bb74 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel419/XmlDsl419SagaRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel419/XmlDsl419SagaRecipe.java
@@ -24,7 +24,6 @@ import org.openrewrite.internal.ListUtils;
import org.openrewrite.xml.XPathMatcher;
import org.openrewrite.xml.tree.Xml;
-import java.util.List;
import java.util.Optional;
/**
@@ -97,7 +96,7 @@ public class XmlDsl419SagaRecipe extends Recipe {
t = t.withContent(ListUtils.flatMap(t.getContent(), content ->
content instanceof Xml.Tag && elementName.equals(((Xml.Tag) content).getName()) ? null : content));
- t = t.withAttributes(ListUtils.concat(t.getAttributes(), new Xml.Attribute(
+ return t.withAttributes(ListUtils.concat(t.getAttributes(), new Xml.Attribute(
org.openrewrite.Tree.randomId(),
" ",
org.openrewrite.marker.Markers.EMPTY,
@@ -111,8 +110,6 @@ public class XmlDsl419SagaRecipe extends Recipe {
uri
)
)));
-
- return t;
}
};
}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RemoveReifierStrategyImport.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RemoveReifierStrategyImport.java
new file mode 100644
index 0000000..01bfe60
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RemoveReifierStrategyImport.java
@@ -0,0 +1,79 @@
+/*
+ * 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.camel421;
+
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.JavaIsoVisitor;
+import org.openrewrite.java.tree.J;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RemoveReifierStrategyImport extends Recipe {
+
+ @Override
+ public String getDisplayName() {
+ return "Remove ReifierStrategy import";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Removes import for org.apache.camel.spi.ReifierStrategy which is no longer in use.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return new JavaIsoVisitor<ExecutionContext>() {
+ @Override
+ public J.CompilationUnit visitCompilationUnit(J.CompilationUnit cu, ExecutionContext ctx) {
+ J.CompilationUnit c = super.visitCompilationUnit(cu, ctx);
+
+ // Find and remove the ReifierStrategy import
+ List<J.Import> imports = new ArrayList<>(c.getImports());
+ int removedIndex = -1;
+ for (int i = 0; i < imports.size(); i++) {
+ String importType = imports.get(i).getQualid().printTrimmed(getCursor());
+ if ("org.apache.camel.spi.ReifierStrategy".equals(importType)) {
+ removedIndex = i;
+ imports.remove(i);
+ break;
+ }
+ }
+
+ if (removedIndex >= 0 && !imports.isEmpty()) {
+ // If we removed the first import and there are more imports,
+ // clean up the prefix of the new first import
+ if (removedIndex == 0) {
+ J.Import firstImport = imports.get(0);
+ String prefix = firstImport.getPrefix().getWhitespace();
+ // Remove leading newlines
+ String cleanedPrefix = prefix.replaceFirst("^\\n+", "");
+ imports.set(0, firstImport.withPrefix(firstImport.getPrefix().withWhitespace(cleanedPrefix)));
+ }
+ c = c.withImports(imports);
+ } else if (removedIndex >= 0) {
+ // All imports removed
+ c = c.withImports(imports);
+ }
+
+ return c;
+ }
+ };
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RemoveZooWordEmbeddingPredictorImport.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RemoveZooWordEmbeddingPredictorImport.java
new file mode 100644
index 0000000..3f23c54
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RemoveZooWordEmbeddingPredictorImport.java
@@ -0,0 +1,80 @@
+/*
+ * 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.camel421;
+
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.JavaIsoVisitor;
+import org.openrewrite.java.tree.J;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RemoveZooWordEmbeddingPredictorImport extends Recipe {
+
+ @Override
+ public String getDisplayName() {
+ return "Remove ZooWordEmbeddingPredictor import";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Removes import for ZooWordEmbeddingPredictor which has been removed from camel-djl. The underlying MXNet engine is discontinued and the zoo model never loaded successfully.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return new JavaIsoVisitor<ExecutionContext>() {
+ @Override
+ public J.CompilationUnit visitCompilationUnit(J.CompilationUnit cu, ExecutionContext ctx) {
+ J.CompilationUnit c = super.visitCompilationUnit(cu, ctx);
+
+ // Find and remove the ZooWordEmbeddingPredictor import
+ List<J.Import> imports = new ArrayList<>(c.getImports());
+ int removedIndex = -1;
+ for (int i = 0; i < imports.size(); i++) {
+ String importType = imports.get(i).getQualid().printTrimmed(getCursor());
+ // The class could be in different packages, so we check the simple name
+ if (importType.endsWith(".ZooWordEmbeddingPredictor")) {
+ removedIndex = i;
+ imports.remove(i);
+ break;
+ }
+ }
+
+ if (removedIndex >= 0 && !imports.isEmpty()) {
+ // If we removed the first import and there are more imports,
+ // clean up the prefix of the new first import
+ if (removedIndex == 0) {
+ J.Import firstImport = imports.get(0);
+ String prefix = firstImport.getPrefix().getWhitespace();
+ // Remove leading newlines
+ String cleanedPrefix = prefix.replaceFirst("^\\n+", "");
+ imports.set(0, firstImport.withPrefix(firstImport.getPrefix().withWhitespace(cleanedPrefix)));
+ }
+ c = c.withImports(imports);
+ } else if (removedIndex >= 0) {
+ // All imports removed
+ c = c.withImports(imports);
+ }
+
+ return c;
+ }
+ };
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInJavaMethod.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInJavaMethod.java
new file mode 100644
index 0000000..0a847a5
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInJavaMethod.java
@@ -0,0 +1,131 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelJavaVisitor;
+import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.tree.J;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Renames header references in Message.setHeader() and Message.getHeader() method calls.
+ * This recipe only migrates string literals appearing as the first argument to these methods,
+ * ensuring safe transformation without false positives.
+ */
+public class RenameHeaderInJavaMethod extends Recipe {
+
+ @Option(displayName = "Old header name",
+ description = "The old header name to replace (as string literal)",
+ example = "kafka.TOPIC")
+ String oldHeaderName;
+
+ @Option(displayName = "New header name",
+ description = "The new header name to use",
+ example = "CamelKafkaTopic")
+ String newHeaderName;
+
+ public RenameHeaderInJavaMethod() {
+ }
+
+ public RenameHeaderInJavaMethod(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ public void setOldHeaderName(String oldHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ }
+
+ public void setNewHeaderName(String newHeaderName) {
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header in .setHeader()/.getHeader() calls";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header references in Message.setHeader() and Message.getHeader() method calls. " +
+ "Only migrates string literals in safe contexts. Does NOT migrate dynamic header names or Map.get() calls.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return RecipesUtil.newVisitor(new RenameHeaderVisitor(oldHeaderName, newHeaderName));
+ }
+
+ private static class RenameHeaderVisitor extends AbstractCamelJavaVisitor {
+ private static final String MATCHER_SET_HEADER_2_ARGS = "org.apache.camel.Message setHeader(String, Object)";
+ private static final String MATCHER_GET_HEADER_1_ARG = "org.apache.camel.Message getHeader(String)";
+ private static final String MATCHER_GET_HEADER_2_ARGS = "org.apache.camel.Message getHeader(String, Class)";
+ private static final String MATCHER_GET_HEADER_3_ARGS = "org.apache.camel.Message getHeader(String, Object, Class)";
+ private static final String MATCHER_GET_HEADER_SUPPLIER = "org.apache.camel.Message getHeader(String, java.util.function.Supplier, Class)";
+
+ private final String oldHeaderName;
+ private final String newHeaderName;
+
+ RenameHeaderVisitor(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
+ J.MethodInvocation mi = super.doVisitMethodInvocation(method, ctx);
+
+ // Check if this is a setHeader or getHeader call
+ if (matchesHeaderMethod(mi)) {
+ // Get the first argument (header name)
+ if (!mi.getArguments().isEmpty() && mi.getArguments().get(0) instanceof J.Literal) {
+ J.Literal literal = (J.Literal) mi.getArguments().get(0);
+
+ // Check if it's a string literal with the old header name
+ if (literal.getValue() instanceof String &&
+ oldHeaderName.equals(literal.getValue())) {
+
+ // Replace the string literal with the new header name
+ J.Literal newLiteral = literal.withValue(newHeaderName)
+ .withValueSource("\"" + newHeaderName + "\"");
+
+ List<org.openrewrite.java.tree.Expression> newArgs = new ArrayList<>(mi.getArguments());
+ newArgs.set(0, newLiteral);
+
+ return mi.withArguments(newArgs);
+ }
+ }
+ }
+
+ return mi;
+ }
+
+ private boolean matchesHeaderMethod(J.MethodInvocation mi) {
+ return getMethodMatcher(MATCHER_SET_HEADER_2_ARGS).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_1_ARG).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_2_ARGS).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_3_ARGS).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_SUPPLIER).matches(mi);
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInSimpleExpression.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInSimpleExpression.java
new file mode 100644
index 0000000..1089d4e
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInSimpleExpression.java
@@ -0,0 +1,132 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelJavaVisitor;
+import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.tree.J;
+
+import java.util.regex.Pattern;
+
+/**
+ * Renames header references in Simple expressions like ${header.oldName} or ${headers.oldName}.
+ * This recipe only transforms strings inside simple() method calls to avoid false positives.
+ */
+public class RenameHeaderInSimpleExpression extends Recipe {
+
+ @Option(displayName = "Old header name",
+ description = "The old header name in Simple expression",
+ example = "kafka.TOPIC")
+ String oldHeaderName;
+
+ @Option(displayName = "New header name",
+ description = "The new header name to use",
+ example = "CamelKafkaTopic")
+ String newHeaderName;
+
+ public RenameHeaderInSimpleExpression() {
+ }
+
+ public RenameHeaderInSimpleExpression(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ public void setOldHeaderName(String oldHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ }
+
+ public void setNewHeaderName(String newHeaderName) {
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header in Simple expressions";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header references in Simple expressions like ${header.oldName} → ${header.newName}. " +
+ "Only migrates expressions inside simple() method calls.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return RecipesUtil.newVisitor(new SimpleExpressionVisitor(oldHeaderName, newHeaderName));
+ }
+
+ private static class SimpleExpressionVisitor extends AbstractCamelJavaVisitor {
+ private final String oldHeaderName;
+ private final String newHeaderName;
+ private final Pattern headerPattern;
+ private final Pattern headersPattern;
+
+ SimpleExpressionVisitor(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+
+ // Escape dots in header name for regex, but keep them in the pattern
+ String escapedOldName = Pattern.quote(oldHeaderName);
+
+ // Match ${header.oldName} or ${headers.oldName}
+ this.headerPattern = Pattern.compile("(\\$\\{header\\.)" + escapedOldName + "(\\})");
+ this.headersPattern = Pattern.compile("(\\$\\{headers\\.)" + escapedOldName + "(\\})");
+ }
+
+ @Override
+ protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
+ J.MethodInvocation mi = super.doVisitMethodInvocation(method, ctx);
+
+ // Check if this is a simple() method call (any class, method name "simple")
+ if (mi.getSimpleName().equals("simple")) {
+ // Get the first argument (the Simple expression string)
+ if (!mi.getArguments().isEmpty() && mi.getArguments().get(0) instanceof J.Literal) {
+ J.Literal literal = (J.Literal) mi.getArguments().get(0);
+
+ if (literal.getValue() instanceof String) {
+ String expression = (String) literal.getValue();
+ String newExpression = expression;
+
+ // Replace ${header.oldName} with ${header.newName}
+ newExpression = headerPattern.matcher(newExpression).replaceAll("$1" + newHeaderName + "$2");
+
+ // Replace ${headers.oldName} with ${headers.newName}
+ newExpression = headersPattern.matcher(newExpression).replaceAll("$1" + newHeaderName + "$2");
+
+ // If changed, update the literal
+ if (!expression.equals(newExpression)) {
+ J.Literal newLiteral = literal.withValue(newExpression)
+ .withValueSource("\"" + newExpression + "\"");
+
+ java.util.List<org.openrewrite.java.tree.Expression> newArgs = new java.util.ArrayList<>(mi.getArguments());
+ newArgs.set(0, newLiteral);
+
+ return mi.withArguments(newArgs);
+ }
+ }
+ }
+ }
+
+ return mi;
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInXmlDsl.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInXmlDsl.java
new file mode 100644
index 0000000..9ca4d6f
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInXmlDsl.java
@@ -0,0 +1,113 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.internal.ListUtils;
+import org.openrewrite.marker.Markers;
+import org.openrewrite.xml.tree.Xml;
+
+/**
+ * Renames header references in XML DSL <setHeader name="..."> and <header name="..."> elements.
+ */
+public class RenameHeaderInXmlDsl extends Recipe {
+
+ @Option(displayName = "Old header name",
+ description = "The old header name",
+ example = "kafka.TOPIC")
+ String oldHeaderName;
+
+ @Option(displayName = "New header name",
+ description = "The new header name",
+ example = "CamelKafkaTopic")
+ String newHeaderName;
+
+ public RenameHeaderInXmlDsl() {
+ }
+
+ public RenameHeaderInXmlDsl(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ public void setOldHeaderName(String oldHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ }
+
+ public void setNewHeaderName(String newHeaderName) {
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header in XML DSL";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header references in XML DSL <setHeader name=\"...\">, <header name=\"...\">, " +
+ "and <removeHeader name=\"...\"> elements.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return new XmlHeaderVisitor(oldHeaderName, newHeaderName);
+ }
+
+ private static class XmlHeaderVisitor extends AbstractCamelXmlVisitor {
+ private final String oldHeaderName;
+ private final String newHeaderName;
+
+ XmlHeaderVisitor(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ public Xml.Tag doVisitTag(Xml.Tag tag, ExecutionContext ctx) {
+ Xml.Tag t = super.doVisitTag(tag, ctx);
+
+ // Check if this is a setHeader, header, or removeHeader tag
+ String tagName = t.getName();
+ if ("setHeader".equals(tagName) || "header".equals(tagName) || "removeHeader".equals(tagName)) {
+ // Look for the "name" attribute with oldHeaderName value
+ return t.withAttributes(ListUtils.map(t.getAttributes(), attr -> {
+ if ("name".equals(attr.getKeyAsString()) &&
+ oldHeaderName.equals(attr.getValueAsString())) {
+ // Replace with new header name
+ return attr.withValue(
+ new Xml.Attribute.Value(
+ attr.getValue().getId(),
+ "",
+ Markers.EMPTY,
+ attr.getValue().getQuote(),
+ newHeaderName
+ )
+ );
+ }
+ return attr;
+ }));
+ }
+
+ return t;
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInYamlDsl.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInYamlDsl.java
new file mode 100644
index 0000000..ea9dbe3
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderInYamlDsl.java
@@ -0,0 +1,131 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelYamlVisitor;
+import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Preconditions;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.yaml.tree.Yaml;
+
+/**
+ * Renames header references in YAML DSL setHeader.name, header.name, and removeHeader.name entries.
+ */
+public class RenameHeaderInYamlDsl extends Recipe {
+
+ @Option(displayName = "Old header name",
+ description = "The old header name",
+ example = "kafka.TOPIC")
+ String oldHeaderName;
+
+ @Option(displayName = "New header name",
+ description = "The new header name",
+ example = "CamelKafkaTopic")
+ String newHeaderName;
+
+ public RenameHeaderInYamlDsl() {
+ }
+
+ public RenameHeaderInYamlDsl(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ public void setOldHeaderName(String oldHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ }
+
+ public void setNewHeaderName(String newHeaderName) {
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header in YAML DSL";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header references in YAML DSL setHeader.name, header.name, and removeHeader.name entries.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return Preconditions.check(RecipesUtil.camelYamlDslPrecondition(),
+ new YamlHeaderVisitor(oldHeaderName, newHeaderName));
+ }
+
+ private static class YamlHeaderVisitor extends AbstractCamelYamlVisitor {
+ private final String oldHeaderName;
+ private final String newHeaderName;
+
+ YamlHeaderVisitor(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ protected void clearLocalCache() {
+ // Nothing to cache
+ }
+
+ @Override
+ public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext ctx) {
+ Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, ctx);
+
+ // Check if this is a "name" entry with the old header value
+ if ("name".equals(e.getKey().getValue()) &&
+ e.getValue() instanceof Yaml.Scalar &&
+ oldHeaderName.equals(((Yaml.Scalar) e.getValue()).getValue())) {
+
+ // Check if any parent mapping contains setHeader, header, or removeHeader
+ if (isHeaderOperation()) {
+ Yaml.Scalar scalarValue = (Yaml.Scalar) e.getValue();
+ // Replace with new header name
+ return e.withValue(scalarValue.withValue(newHeaderName));
+ }
+ }
+
+ return e;
+ }
+
+ /**
+ * Check if this entry is within a setHeader, header, or removeHeader mapping.
+ */
+ private boolean isHeaderOperation() {
+ // Walk up the cursor tree looking for a mapping with setHeader, header, or removeHeader
+ for (int i = 0; i < 10; i++) { // Check up to 10 levels up
+ Object value = getCursor().getParent(i) != null ? getCursor().getParent(i).getValue() : null;
+ if (value instanceof Yaml.Mapping) {
+ Yaml.Mapping mapping = (Yaml.Mapping) value;
+ boolean hasHeaderOp = mapping.getEntries().stream()
+ .anyMatch(e -> {
+ String key = e.getKey().getValue();
+ return "setHeader".equals(key) || "header".equals(key) || "removeHeader".equals(key);
+ });
+ if (hasHeaderOp) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInJavaMethod.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInJavaMethod.java
new file mode 100644
index 0000000..04b87de
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInJavaMethod.java
@@ -0,0 +1,135 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelJavaVisitor;
+import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.tree.J;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Renames header prefixes in Message.setHeader() and Message.getHeader() method calls.
+ * This recipe migrates string literals starting with a specific prefix to use a new prefix.
+ */
+public class RenameHeaderPrefixInJavaMethod extends Recipe {
+
+ @Option(displayName = "Old header prefix",
+ description = "The old header prefix to replace",
+ example = "SolrField.")
+ String oldPrefix;
+
+ @Option(displayName = "New header prefix",
+ description = "The new header prefix to use",
+ example = "CamelSolrField.")
+ String newPrefix;
+
+ public RenameHeaderPrefixInJavaMethod() {
+ }
+
+ public RenameHeaderPrefixInJavaMethod(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+ }
+
+ public void setOldPrefix(String oldPrefix) {
+ this.oldPrefix = oldPrefix;
+ }
+
+ public void setNewPrefix(String newPrefix) {
+ this.newPrefix = newPrefix;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header prefix in .setHeader()/.getHeader() calls";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header prefixes in Message.setHeader() and Message.getHeader() method calls. " +
+ "Only migrates string literals in safe contexts. Does NOT migrate dynamic header names or Map.get() calls.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return RecipesUtil.newVisitor(new RenameHeaderPrefixVisitor(oldPrefix, newPrefix));
+ }
+
+ private static class RenameHeaderPrefixVisitor extends AbstractCamelJavaVisitor {
+ private static final String MATCHER_SET_HEADER_2_ARGS = "org.apache.camel.Message setHeader(String, Object)";
+ private static final String MATCHER_GET_HEADER_1_ARG = "org.apache.camel.Message getHeader(String)";
+ private static final String MATCHER_GET_HEADER_2_ARGS = "org.apache.camel.Message getHeader(String, Class)";
+ private static final String MATCHER_GET_HEADER_3_ARGS = "org.apache.camel.Message getHeader(String, Object, Class)";
+ private static final String MATCHER_GET_HEADER_SUPPLIER = "org.apache.camel.Message getHeader(String, java.util.function.Supplier, Class)";
+
+ private final String oldPrefix;
+ private final String newPrefix;
+
+ RenameHeaderPrefixVisitor(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+ }
+
+ @Override
+ protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
+ J.MethodInvocation mi = super.doVisitMethodInvocation(method, ctx);
+
+ // Check if this is a setHeader or getHeader call
+ if (matchesHeaderMethod(mi)) {
+ // Get the first argument (header name)
+ if (!mi.getArguments().isEmpty() && mi.getArguments().get(0) instanceof J.Literal) {
+ J.Literal literal = (J.Literal) mi.getArguments().get(0);
+
+ // Check if it's a string literal starting with the old prefix
+ if (literal.getValue() instanceof String) {
+ String headerName = (String) literal.getValue();
+
+ if (headerName.startsWith(oldPrefix)) {
+ // Replace the prefix
+ String newHeaderName = newPrefix + headerName.substring(oldPrefix.length());
+
+ // Replace the string literal with the new header name
+ J.Literal newLiteral = literal.withValue(newHeaderName)
+ .withValueSource("\"" + newHeaderName + "\"");
+
+ List<org.openrewrite.java.tree.Expression> newArgs = new ArrayList<>(mi.getArguments());
+ newArgs.set(0, newLiteral);
+
+ return mi.withArguments(newArgs);
+ }
+ }
+ }
+ }
+
+ return mi;
+ }
+
+ private boolean matchesHeaderMethod(J.MethodInvocation mi) {
+ return getMethodMatcher(MATCHER_SET_HEADER_2_ARGS).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_1_ARG).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_2_ARGS).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_3_ARGS).matches(mi) ||
+ getMethodMatcher(MATCHER_GET_HEADER_SUPPLIER).matches(mi);
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInSimpleExpression.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInSimpleExpression.java
new file mode 100644
index 0000000..b201597
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInSimpleExpression.java
@@ -0,0 +1,133 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelJavaVisitor;
+import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.tree.J;
+
+import java.util.regex.Pattern;
+
+/**
+ * Renames header prefixes in Simple expressions like ${header.SolrField.id} → ${header.CamelSolrField.id}.
+ * This recipe only transforms strings inside simple() method calls to avoid false positives.
+ */
+public class RenameHeaderPrefixInSimpleExpression extends Recipe {
+
+ @Option(displayName = "Old header prefix",
+ description = "The old header prefix in Simple expression",
+ example = "SolrField.")
+ String oldPrefix;
+
+ @Option(displayName = "New header prefix",
+ description = "The new header prefix to use",
+ example = "CamelSolrField.")
+ String newPrefix;
+
+ public RenameHeaderPrefixInSimpleExpression() {
+ }
+
+ public RenameHeaderPrefixInSimpleExpression(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+ }
+
+ public void setOldPrefix(String oldPrefix) {
+ this.oldPrefix = oldPrefix;
+ }
+
+ public void setNewPrefix(String newPrefix) {
+ this.newPrefix = newPrefix;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header prefix in Simple expressions";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header prefixes in Simple expressions like ${header.SolrField.id} → ${header.CamelSolrField.id}. " +
+ "Only migrates expressions inside simple() method calls.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return RecipesUtil.newVisitor(new SimpleExpressionVisitor(oldPrefix, newPrefix));
+ }
+
+ private static class SimpleExpressionVisitor extends AbstractCamelJavaVisitor {
+ private final String oldPrefix;
+ private final String newPrefix;
+ private final Pattern headerPattern;
+ private final Pattern headersPattern;
+
+ SimpleExpressionVisitor(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+
+ // Escape dots in prefix for regex
+ String escapedOldPrefix = Pattern.quote(oldPrefix);
+
+ // Match ${header.SolrField.xxx} or ${headers.SolrField.xxx}
+ // Captures: group1=${header. or ${headers., group2=rest after old prefix, group3=}
+ this.headerPattern = Pattern.compile("(\\$\\{header\\.)" + escapedOldPrefix + "([^}]+)(\\})");
+ this.headersPattern = Pattern.compile("(\\$\\{headers\\.)" + escapedOldPrefix + "([^}]+)(\\})");
+ }
+
+ @Override
+ protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
+ J.MethodInvocation mi = super.doVisitMethodInvocation(method, ctx);
+
+ // Check if this is a simple() method call (any class, method name "simple")
+ if (mi.getSimpleName().equals("simple")) {
+ // Get the first argument (the Simple expression string)
+ if (!mi.getArguments().isEmpty() && mi.getArguments().get(0) instanceof J.Literal) {
+ J.Literal literal = (J.Literal) mi.getArguments().get(0);
+
+ if (literal.getValue() instanceof String) {
+ String expression = (String) literal.getValue();
+ String newExpression = expression;
+
+ // Replace ${header.SolrField.xxx} with ${header.CamelSolrField.xxx}
+ newExpression = headerPattern.matcher(newExpression).replaceAll("$1" + newPrefix + "$2$3");
+
+ // Replace ${headers.SolrField.xxx} with ${headers.CamelSolrField.xxx}
+ newExpression = headersPattern.matcher(newExpression).replaceAll("$1" + newPrefix + "$2$3");
+
+ // If changed, update the literal
+ if (!expression.equals(newExpression)) {
+ J.Literal newLiteral = literal.withValue(newExpression)
+ .withValueSource("\"" + newExpression + "\"");
+
+ java.util.List<org.openrewrite.java.tree.Expression> newArgs = new java.util.ArrayList<>(mi.getArguments());
+ newArgs.set(0, newLiteral);
+
+ return mi.withArguments(newArgs);
+ }
+ }
+ }
+ }
+
+ return mi;
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInXmlDsl.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInXmlDsl.java
new file mode 100644
index 0000000..29d0a6b
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInXmlDsl.java
@@ -0,0 +1,116 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.internal.ListUtils;
+import org.openrewrite.marker.Markers;
+import org.openrewrite.xml.tree.Xml;
+
+/**
+ * Renames header prefixes in XML DSL <setHeader name="..."> and <header name="..."> elements.
+ */
+public class RenameHeaderPrefixInXmlDsl extends Recipe {
+
+ @Option(displayName = "Old header prefix",
+ description = "The old header prefix",
+ example = "SolrField.")
+ String oldPrefix;
+
+ @Option(displayName = "New header prefix",
+ description = "The new header prefix",
+ example = "CamelSolrField.")
+ String newPrefix;
+
+ public RenameHeaderPrefixInXmlDsl() {
+ }
+
+ public RenameHeaderPrefixInXmlDsl(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+ }
+
+ public void setOldPrefix(String oldPrefix) {
+ this.oldPrefix = oldPrefix;
+ }
+
+ public void setNewPrefix(String newPrefix) {
+ this.newPrefix = newPrefix;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header prefix in XML DSL";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header prefixes in XML DSL <setHeader name=\"...\">, <header name=\"...\">, " +
+ "and <removeHeader name=\"...\"> elements.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return new XmlHeaderPrefixVisitor(oldPrefix, newPrefix);
+ }
+
+ private static class XmlHeaderPrefixVisitor extends AbstractCamelXmlVisitor {
+ private final String oldPrefix;
+ private final String newPrefix;
+
+ XmlHeaderPrefixVisitor(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+ }
+
+ @Override
+ public Xml.Tag doVisitTag(Xml.Tag tag, ExecutionContext ctx) {
+ Xml.Tag t = super.doVisitTag(tag, ctx);
+
+ // Check if this is a setHeader, header, or removeHeader tag
+ String tagName = t.getName();
+ if ("setHeader".equals(tagName) || "header".equals(tagName) || "removeHeader".equals(tagName)) {
+ // Look for the "name" attribute starting with oldPrefix
+ return t.withAttributes(ListUtils.map(t.getAttributes(), attr -> {
+ if ("name".equals(attr.getKeyAsString())) {
+ String headerName = attr.getValueAsString();
+ if (headerName != null && headerName.startsWith(oldPrefix)) {
+ // Replace the prefix
+ String newHeaderName = newPrefix + headerName.substring(oldPrefix.length());
+ return attr.withValue(
+ new Xml.Attribute.Value(
+ attr.getValue().getId(),
+ "",
+ Markers.EMPTY,
+ attr.getValue().getQuote(),
+ newHeaderName
+ )
+ );
+ }
+ }
+ return attr;
+ }));
+ }
+
+ return t;
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInYamlDsl.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInYamlDsl.java
new file mode 100644
index 0000000..77be3cd
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInYamlDsl.java
@@ -0,0 +1,134 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.AbstractCamelYamlVisitor;
+import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Option;
+import org.openrewrite.Preconditions;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.yaml.tree.Yaml;
+
+/**
+ * Renames header prefixes in YAML DSL setHeader.name, header.name, and removeHeader.name entries.
+ */
+public class RenameHeaderPrefixInYamlDsl extends Recipe {
+
+ @Option(displayName = "Old header prefix",
+ description = "The old header prefix",
+ example = "SolrField.")
+ String oldPrefix;
+
+ @Option(displayName = "New header prefix",
+ description = "The new header prefix",
+ example = "CamelSolrField.")
+ String newPrefix;
+
+ public RenameHeaderPrefixInYamlDsl() {
+ }
+
+ public RenameHeaderPrefixInYamlDsl(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+ }
+
+ public void setOldPrefix(String oldPrefix) {
+ this.oldPrefix = oldPrefix;
+ }
+
+ public void setNewPrefix(String newPrefix) {
+ this.newPrefix = newPrefix;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename header prefix in YAML DSL";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header prefixes in YAML DSL setHeader.name, header.name, and removeHeader.name entries.";
+ }
+
+ @Override
+ public TreeVisitor<?, ExecutionContext> getVisitor() {
+ return Preconditions.check(RecipesUtil.camelYamlDslPrecondition(),
+ new YamlHeaderPrefixVisitor(oldPrefix, newPrefix));
+ }
+
+ private static class YamlHeaderPrefixVisitor extends AbstractCamelYamlVisitor {
+ private final String oldPrefix;
+ private final String newPrefix;
+
+ YamlHeaderPrefixVisitor(String oldPrefix, String newPrefix) {
+ this.oldPrefix = oldPrefix;
+ this.newPrefix = newPrefix;
+ }
+
+ @Override
+ protected void clearLocalCache() {
+ // Nothing to cache
+ }
+
+ @Override
+ public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext ctx) {
+ Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, ctx);
+
+ // Check if this is a "name" entry with a value starting with oldPrefix
+ if ("name".equals(e.getKey().getValue()) &&
+ e.getValue() instanceof Yaml.Scalar) {
+ String headerName = ((Yaml.Scalar) e.getValue()).getValue();
+ if (headerName != null && headerName.startsWith(oldPrefix)) {
+
+ // Check if any parent mapping contains setHeader, header, or removeHeader
+ if (isHeaderOperation()) {
+ Yaml.Scalar scalarValue = (Yaml.Scalar) e.getValue();
+ // Replace the prefix
+ String newHeaderName = newPrefix + headerName.substring(oldPrefix.length());
+ return e.withValue(scalarValue.withValue(newHeaderName));
+ }
+ }
+ }
+
+ return e;
+ }
+
+ /**
+ * Check if this entry is within a setHeader, header, or removeHeader mapping.
+ */
+ private boolean isHeaderOperation() {
+ // Walk up the cursor tree looking for a mapping with setHeader, header, or removeHeader
+ for (int i = 0; i < 10; i++) { // Check up to 10 levels up
+ Object value = getCursor().getParent(i) != null ? getCursor().getParent(i).getValue() : null;
+ if (value instanceof Yaml.Mapping) {
+ Yaml.Mapping mapping = (Yaml.Mapping) value;
+ boolean hasHeaderOp = mapping.getEntries().stream()
+ .anyMatch(e -> {
+ String key = e.getKey().getValue();
+ return "setHeader".equals(key) || "header".equals(key) || "removeHeader".equals(key);
+ });
+ if (hasHeaderOp) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixes.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixes.java
new file mode 100644
index 0000000..8d344e8
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixes.java
@@ -0,0 +1,113 @@
+/*
+ * 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.camel421;
+
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Recipe that renames Camel header prefixes across all DSL types (Java, Simple expressions, XML, YAML).
+ * This is different from {@link RenameHeaders} which does exact matching - this recipe replaces prefixes.
+ *
+ * Example: For prefix mapping "SolrField." → "CamelSolrField."
+ * - "SolrField.id" becomes "CamelSolrField.id"
+ * - "SolrField.name" becomes "CamelSolrField.name"
+ * - "SolrParam.commit" remains unchanged (different prefix)
+ *
+ * Example YAML configuration:
+ * <pre>
+ * - org.apache.camel.upgrade.camel421.RenameHeaderPrefixes:
+ * prefixMappings:
+ * SolrField.: CamelSolrField.
+ * SolrParam.: CamelSolrParam.
+ * </pre>
+ */
+public class RenameHeaderPrefixes extends Recipe {
+
+ @Option(displayName = "Prefix mappings",
+ description = "Map of old header prefixes to new header prefixes",
+ example = "SolrField.: CamelSolrField.",
+ required = true)
+ Map<String, String> prefixMappings;
+
+ public RenameHeaderPrefixes() {
+ }
+
+ public RenameHeaderPrefixes(Map<String, String> prefixMappings) {
+ this.prefixMappings = prefixMappings;
+ }
+
+ public void setPrefixMappings(Map<String, String> prefixMappings) {
+ this.prefixMappings = prefixMappings;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename Camel header prefixes across all DSLs";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames Camel header prefixes across all DSL types: " +
+ "Java method calls (.setHeader, .getHeader), Simple expressions (${header.name}), " +
+ "XML DSL (<setHeader name=\"...\">), and YAML DSL (setHeader.name). " +
+ "Any header starting with an old prefix gets that prefix replaced with the new prefix. " +
+ "Only migrates safe contexts to avoid false positives.";
+ }
+
+ @Override
+ public List<Recipe> getRecipeList() {
+ List<Recipe> recipes = new ArrayList<>();
+
+ if (prefixMappings != null) {
+ for (Map.Entry<String, String> entry : prefixMappings.entrySet()) {
+ recipes.add(createPrefixRenameRecipe(entry.getKey(), entry.getValue()));
+ }
+ }
+
+ return recipes;
+ }
+
+ private Recipe createPrefixRenameRecipe(String oldPrefix, String newPrefix) {
+ return new Recipe() {
+ @Override
+ public String getDisplayName() {
+ return "Rename header prefix: " + oldPrefix + " → " + newPrefix;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header prefix '" + oldPrefix + "' to '" + newPrefix + "' across all DSLs";
+ }
+
+ @Override
+ public List<Recipe> getRecipeList() {
+ return Arrays.asList(
+ new RenameHeaderPrefixInJavaMethod(oldPrefix, newPrefix),
+ new RenameHeaderPrefixInSimpleExpression(oldPrefix, newPrefix),
+ new RenameHeaderPrefixInXmlDsl(oldPrefix, newPrefix),
+ new RenameHeaderPrefixInYamlDsl(oldPrefix, newPrefix)
+ );
+ }
+ };
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaders.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaders.java
new file mode 100644
index 0000000..51cbcef
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel421/RenameHeaders.java
@@ -0,0 +1,147 @@
+/*
+ * 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.camel421;
+
+import org.openrewrite.Option;
+import org.openrewrite.Recipe;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Recipe that renames Camel headers across all DSL types (Java, Simple expressions, XML, YAML).
+ * Supports both single header rename and bulk rename using a map.
+ *
+ * Example YAML configuration (bulk rename):
+ * <pre>
+ * - org.apache.camel.upgrade.camel421.RenameHeaders:
+ * headerMappings:
+ * kafka.TOPIC: CamelKafkaTopic
+ * kafka.PARTITION: CamelKafkaPartition
+ * kafka.KEY: CamelKafkaKey
+ * </pre>
+ *
+ * Example YAML configuration (single rename):
+ * <pre>
+ * - org.apache.camel.upgrade.camel421.RenameHeaders:
+ * oldHeaderName: kafka.TOPIC
+ * newHeaderName: CamelKafkaTopic
+ * </pre>
+ */
+public class RenameHeaders extends Recipe {
+
+ @Option(displayName = "Header mappings",
+ description = "Map of old header names to new header names (for bulk rename)",
+ example = "kafka.TOPIC: CamelKafkaTopic",
+ required = false)
+ Map<String, String> headerMappings;
+
+ @Option(displayName = "Old header name",
+ description = "The old header name to replace (for single rename)",
+ example = "kafka.TOPIC",
+ required = false)
+ String oldHeaderName;
+
+ @Option(displayName = "New header name",
+ description = "The new header name to use (for single rename)",
+ example = "CamelKafkaTopic",
+ required = false)
+ String newHeaderName;
+
+ public RenameHeaders() {
+ }
+
+ public RenameHeaders(Map<String, String> headerMappings) {
+ this.headerMappings = headerMappings;
+ }
+
+ public RenameHeaders(String oldHeaderName, String newHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ this.newHeaderName = newHeaderName;
+ }
+
+ public void setHeaderMappings(Map<String, String> headerMappings) {
+ this.headerMappings = headerMappings;
+ }
+
+ public void setOldHeaderName(String oldHeaderName) {
+ this.oldHeaderName = oldHeaderName;
+ }
+
+ public void setNewHeaderName(String newHeaderName) {
+ this.newHeaderName = newHeaderName;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Rename Camel header(s) across all DSLs";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames Camel header(s) from old name(s) to new name(s) across all DSL types: " +
+ "Java method calls (.setHeader, .getHeader), Simple expressions (${header.name}), " +
+ "XML DSL (<setHeader name=\"...\">), and YAML DSL (setHeader.name). " +
+ "Supports both single header rename (oldHeaderName/newHeaderName) and bulk rename (headerMappings). " +
+ "Only migrates safe contexts to avoid false positives.";
+ }
+
+ @Override
+ public List<Recipe> getRecipeList() {
+ List<Recipe> recipes = new ArrayList<>();
+
+ // Bulk rename using map
+ if (headerMappings != null) {
+ for (Map.Entry<String, String> entry : headerMappings.entrySet()) {
+ recipes.add(createHeaderRenameRecipe(entry.getKey(), entry.getValue()));
+ }
+ }
+
+ // Single rename using oldHeaderName/newHeaderName
+ if (oldHeaderName != null && newHeaderName != null) {
+ recipes.add(createHeaderRenameRecipe(oldHeaderName, newHeaderName));
+ }
+
+ return recipes;
+ }
+
+ private Recipe createHeaderRenameRecipe(String oldName, String newName) {
+ return new Recipe() {
+ @Override
+ public String getDisplayName() {
+ return "Rename header: " + oldName + " → " + newName;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Renames header '" + oldName + "' to '" + newName + "' across all DSLs";
+ }
+
+ @Override
+ public List<Recipe> getRecipeList() {
+ return Arrays.asList(
+ new RenameHeaderInJavaMethod(oldName, newName),
+ new RenameHeaderInSimpleExpression(oldName, newName),
+ new RenameHeaderInXmlDsl(oldName, newName),
+ new RenameHeaderInYamlDsl(oldName, newName)
+ );
+ }
+ };
+ }
+}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/Java47Recipes.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/Java47Recipes.java
index f859039..3382939 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/Java47Recipes.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/Java47Recipes.java
@@ -48,8 +48,6 @@ public class Java47Recipes extends Recipe {
this.c = c;
}
}
-
- private static final String MATCHER_GET_HEADER = "org.apache.camel.Message getHeader(java.lang.String, java.lang.Class)";
private static final String MATCHER_GET_IN = "org.apache.camel.Exchange getIn()";
private static final List<Triple> HEADERS_MAP = Arrays.asList(
new Triple("org.apache.camel.Message getHeader(java.lang.String, java.lang.Class)", "Exchange.HTTP_SERVLET_REQUEST", "#{any(org.apache.camel.Exchange)}.getMessage(HttpMessage.class).getRequest()"),
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToExtendedCamelContext.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToExtendedCamelContext.java
index c410401..aa661a9 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToExtendedCamelContext.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToExtendedCamelContext.java
@@ -25,20 +25,11 @@ import org.openrewrite.TreeVisitor;
import org.openrewrite.java.JavaTemplate;
import org.openrewrite.java.tree.J;
-import java.util.regex.Pattern;
-
/**
* Replaces prefix with the new one and changes the suffix tp start with lower case
*/
public class MoveGetterToExtendedCamelContext extends Recipe {
- private static final String MATCHER_GET_NAME_RESOLVER = "org.apache.camel.ExtendedCamelContext getComponentNameResolver()";
- private static final String MATCHER_GET_MODEL_JAXB_CONTEXT_FACTORY
- = "org.apache.camel.ExtendedCamelContext getModelJAXBContextFactory()";
- private static final String MATCHER_GET_MODEL_TO_XML_DUMPER = "org.apache.camel.ExtendedCamelContext getModelToXMLDumper()";
- private static final Pattern ABSTRACT_CONTEXT_TYPE = Pattern.compile("org.apache.camel.impl.engine.AbstractCamelContext");
- private static final String MATCHER_CONTEXT_GET_EXT = "org.apache.camel.CamelContext getExtension(java.lang.Class)";
-
@Option(example = "TODO Provide a usage example for the docs", displayName = "Method name",
description = "Name of the method on external camel context.")
public String oldMethodName;
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToPluginHelper.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToPluginHelper.java
index 474e9fe..6a525e4 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToPluginHelper.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/MoveGetterToPluginHelper.java
@@ -32,11 +32,6 @@ import java.util.regex.Pattern;
* Replaces prefix with the new one and changes the suffix tp start with lower case
*/
public class MoveGetterToPluginHelper extends Recipe {
-
- private static final String MATCHER_GET_NAME_RESOLVER = "org.apache.camel.ExtendedCamelContext getComponentNameResolver()";
- private static final String MATCHER_GET_MODEL_JAXB_CONTEXT_FACTORY
- = "org.apache.camel.ExtendedCamelContext getModelJAXBContextFactory()";
- private static final String MATCHER_GET_MODEL_TO_XML_DUMPER = "org.apache.camel.ExtendedCamelContext getModelToXMLDumper()";
private static final Pattern EXTERNAL_CONTEXT_TYPE = Pattern.compile("org.apache.camel.ExtendedCamelContext");
private static final String MATCHER_CONTEXT_GET_EXT = "org.apache.camel.CamelContext getExtension(java.lang.Class)";
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInDataFormatXml.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInDataFormatXml.java
index c157951..b7e5330 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInDataFormatXml.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInDataFormatXml.java
@@ -89,8 +89,8 @@ public class ReplacePropertyInDataFormatXml extends Recipe {
private Xml.Tag replacePropertyIfPossible(final Xml.Tag tag) {
return tag.withAttributes(ListUtils.map(tag.getAttributes(), attr ->
- oldPropertyKey.equals(attr.getKey().getName())
- ? attr.withKey(attr.getKey().withName(newPropertyKey))
- : attr));
+ oldPropertyKey.equals(attr.getKey().getName()) ?
+ attr.withKey(attr.getKey().withName(newPropertyKey)) :
+ attr));
}
}
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.1.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.1.yaml
new file mode 100644
index 0000000..7f93e59
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.1.yaml
@@ -0,0 +1,50 @@
+#
+# 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.
+#
+
+#####
+# Rules coming from https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html
+# Specifically changes introduced in 4.18.3 (upgrading from 4.18.1 to 4.18.3)
+#####
+
+#####
+# Update the Camel project from 4.18.1 to 4.18.3
+#####
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_1.CamelMigrationRecipe
+displayName: Migrates `camel 4.18.0` application to `camel 4.18.1`
+description: Migrates `camel 4.18.0` application to `camel 4.18.1`.
+recipeList:
+ - org.apache.camel.upgrade.camel418_1.saga
+---
+### https://camel.apache.org/manual/camel-4x-upgrade-guide-4_19.html#_saga_eip
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_1.saga
+displayName: Migrate camel-sage model configuration
+description: The Saga EIP has fixed the model for how to configure completion and compensation URIs.
+recipeList:
+ - org.apache.camel.upgrade.camel419.XmlDsl419SagaRecipe
+ - org.apache.camel.upgrade.camel419.YamlDsl419SagaRecipe
+ - org.apache.camel.upgrade.camel418_1.routePolicy
+---
+### https://camel.apache.org/manual/camel-4x-upgrade-guide-4_19.html#_camel_yaml_io_camel_xml_io
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_1.routePolicy
+displayName: Renamed routePolicy to routePolicyRef on the route node
+description: Renamed routePolicy to routePolicyRef on the route node.
+recipeList:
+ - org.apache.camel.upgrade.camel419.YamlDsl419RoutePolicyRecipe
\ No newline at end of file
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.3.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.3.yaml
new file mode 100644
index 0000000..c06218d
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.3.yaml
@@ -0,0 +1,300 @@
+#
+# 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.
+#
+
+#####
+# Rules coming from https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html
+# Specifically changes introduced in 4.18.3 (upgrading from 4.18.1 to 4.18.3)
+#####
+
+#####
+# Update the Camel project from 4.18.1 to 4.18.3
+#####
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.CamelMigrationRecipe
+displayName: Migrates `camel 4.18.1` application to `camel 4.18.3`
+description: Migrates `camel 4.18.1` application to `camel 4.18.3`.
+recipeList:
+ # Header renames
+ - org.apache.camel.upgrade.camel418_3.upgradeJGroupsHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeJiraHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeJGroupsRaftHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeShiroHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeSolrHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeGitHub2Headers
+ - org.apache.camel.upgrade.camel418_3.upgradeGoogleCloudHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeGoogleSecretManagerHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeMongoDbGridFsHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeOpenstackHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeWeb3jHeaders
+ # Partial automation - header string literals migrated, DSL accessor methods require manual update
+ - org.apache.camel.upgrade.camel418_3.upgradeLuceneHeaders
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-jgroups-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeJGroupsHeaders
+displayName: Migrate camel-jgroups header constants to new naming convention
+description: Renames JGroups header constants from JGROUPS_* to CamelJGroups* pattern only if camel-jgroups dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-jgroups
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ JGROUPS_CHANNEL_ADDRESS: CamelJGroupsChannelAddress
+ JGROUPS_DEST: CamelJGroupsDest
+ JGROUPS_SRC: CamelJGroupsSrc
+ JGROUPS_ORIGINAL_MESSAGE: CamelJGroupsOriginalMessage
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-jira-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeJiraHeaders
+displayName: Migrate camel-jira header constants to new naming convention
+description: Renames JIRA header constants to CamelJira* pattern only if camel-jira dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-jira
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ IssueAssigneeId: CamelJiraIssueAssigneeId
+ IssueAssignee: CamelJiraIssueAssignee
+ IssueComponents: CamelJiraIssueComponents
+ IssueComment: CamelJiraIssueComment
+ IssueChanged: CamelJiraIssueChanged
+ IssueKey: CamelJiraIssueKey
+ IssuePriorityId: CamelJiraIssuePriorityId
+ IssuePriorityName: CamelJiraIssuePriorityName
+ ProjectKey: CamelJiraIssueProjectKey
+ IssueSummary: CamelJiraIssueSummary
+ IssueTransitionId: CamelJiraIssueTransitionId
+ IssueTypeId: CamelJiraIssueTypeId
+ IssueTypeName: CamelJiraIssueTypeName
+ IssueWatchedIssues: CamelJiraIssueWatchedIssues
+ IssueWatchersAdd: CamelJiraIssueWatchersAdd
+ IssueWatchersRemove: CamelJiraIssueWatchersRemove
+ ParentIssueKey: CamelJiraParentIssueKey
+ ChildIssueKey: CamelJiraChildIssueKey
+ linkType: CamelJiraLinkType
+ minutesSpent: CamelJiraMinutesSpent
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-jgroups-raft
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeJGroupsRaftHeaders
+displayName: Migrate camel-jgroups-raft header constants to new naming convention
+description: Renames JGroups Raft header constants from JGROUPSRAFT_* to CamelJGroupsRaft* pattern only if camel-jgroups-raft dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-jgroups-raft
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ JGROUPSRAFT_LOG_SIZE: CamelJGroupsRaftLogSize
+ JGROUPSRAFT_COMMIT_INDEX: CamelJGroupsRaftCommitIndex
+ JGROUPSRAFT_CURRENT_TERM: CamelJGroupsRaftCurrentTerm
+ JGROUPSRAFT_IS_LEADER: CamelJGroupsRaftIsLeader
+ JGROUPSRAFT_LAST_APPLIED: CamelJGroupsRaftLastApplied
+ JGROUPSRAFT_LEADER_ADDRESS: CamelJGroupsRaftLeaderAddress
+ JGROUPSRAFT_RAFT_ID: CamelJGroupsRaftRaftId
+ JGROUPSRAFT_EVENT_TYPE: CamelJGroupsRaftEventType
+ JGROUPSRAFT_SET_OFFSET: CamelJGroupsRaftSetOffset
+ JGROUPSRAFT_SET_LENGTH: CamelJGroupsRaftSetLength
+ JGROUPSRAFT_SET_TIMEOUT: CamelJGroupsRaftSetTimeout
+ JGROUPSRAFT_SET_TIMEUNIT: CamelJGroupsRaftSetTimeUnit
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-shiro-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeShiroHeaders
+displayName: Migrate camel-shiro security header constants to new naming convention
+description: Renames Shiro security header constants from SHIRO_SECURITY_* to CamelShiroSecurity* pattern only if camel-shiro dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-shiro
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ SHIRO_SECURITY_TOKEN: CamelShiroSecurityToken
+ SHIRO_SECURITY_USERNAME: CamelShiroSecurityUsername
+ SHIRO_SECURITY_PASSWORD: CamelShiroSecurityPassword
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-solr
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeSolrHeaders
+displayName: Migrate camel-solr header prefixes to new naming convention
+description: Renames Solr header prefixes SolrField. and SolrParam. to CamelSolrField. and CamelSolrParam. when camel-solr dependency is present. Routes that reference constants symbolically continue to work without changes. Note - Because the renamed prefixes now begin with Camel, they are stripped by HeaderFilterStrategy when crossing transport boundaries. Routes that bridge external transports and want to drive Solr fields/params from headers must carry values in non-Camel-prefixed he [...]
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-solr
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaderPrefixes:
+ prefixMappings:
+ SolrField.: CamelSolrField.
+ SolrParam.: CamelSolrParam.
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-github2-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeGitHub2Headers
+displayName: Migrate camel-github2 producer header constants to new naming convention
+description: Renames GitHub2 producer header constants to CamelGitHub* pattern only if camel-github dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-github2
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ GitHubPullRequest: CamelGitHubPullRequest
+ GitHubInResponseTo: CamelGitHubInResponseTo
+ GitHubPullRequestHeadCommitSHA: CamelGitHubPullRequestHeadCommitSha
+ GitHubIssueTitle: CamelGitHubIssueTitle
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-google-functions-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeGoogleCloudHeaders
+displayName: Migrate camel-google-cloud header constants to new naming convention
+description: Renames Google Cloud header constants to CamelGoogleCloud* pattern only if camel-google-functions dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-google-functions
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ GoogleCloudFunctionsOperation: CamelGoogleCloudFunctionsOperation
+ GoogleCloudFunctionsEntryPoint: CamelGoogleCloudFunctionsEntryPoint
+ GoogleCloudFunctionsRuntime: CamelGoogleCloudFunctionsRuntime
+ GoogleCloudFunctionsSourceArchiveUrl: CamelGoogleCloudFunctionsSourceArchiveUrl
+ GoogleCloudFunctionsResponseObject: CamelGoogleCloudFunctionsResponseObject
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-google-secret-manager-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeGoogleSecretManagerHeaders
+displayName: Migrate camel-google-secret-manager header constants to new naming convention
+description: Renames Google Secret Manager header constants to CamelGoogleSecretManager* pattern only if camel-google-secret-manager dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-google-secret-manager
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ GoogleSecretManagerOperation: CamelGoogleSecretManagerOperation
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-mongodb-gridfs
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeMongoDbGridFsHeaders
+displayName: Migrate camel-mongodb-gridfs header constants to new naming convention
+description: Renames MongoDB GridFS header constants to CamelGridFs* pattern only if camel-mongodb-gridfs dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-mongodb-gridfs
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ gridfs.operation: CamelGridFsOperation
+ gridfs.metadata: CamelGridFsMetadata
+ gridfs.chunksize: CamelGridFsChunkSize
+ gridfs.objectid: CamelGridFsObjectId
+ gridfs.fileid: CamelGridFsFileId
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-lucene
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeLuceneHeaders
+displayName: Migrate camel-lucene header constants to new naming convention
+description: Renames Lucene-specific header constants to CamelLucene* pattern only if camel-lucene dependency is present. Generic header 'QUERY' is excluded to prevent false positives. Note - DSL accessor methods (returnLuceneDocs() → luceneReturnLuceneDocs()) are NOT migrated and require manual update.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-lucene
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ RETURN_LUCENE_DOCS: CamelLuceneReturnLuceneDocs
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-openstack-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeOpenstackHeaders
+displayName: Migrate camel-openstack header constants to new naming convention
+description: Renames OpenStack-specific header constants to CamelOpenstack* pattern only if camel-openstack dependency is present. Generic headers (*Id, *Name, containerName, objectName, imageRef, interfaceType, ipVersion) are excluded to prevent false positives.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-openstack
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ FlavorId: CamelOpenstackNovaFlavorId
+ RAM: CamelOpenstackNovaRam
+ VCPU: CamelOpenstackNovaVcpu
+ rxtxFactor: CamelOpenstackNovaRxtxFactor
+ AdminPassword: CamelOpenstackNovaAdminPassword
+ KeypairName: CamelOpenstackNovaKeypairName
+ volumeType: CamelOpenstackCinderVolumeType
+ isBootable: CamelOpenstackCinderIsBootable
+ diskFormat: CamelOpenstackGlanceDiskFormat
+ containerFormat: CamelOpenstackGlanceContainerFormat
+ isPublic: CamelOpenstackGlanceIsPublic
+ minRam: CamelOpenstackGlanceMinRam
+ minDisk: CamelOpenstackGlanceMinDisk
+ adminStateUp: CamelOpenstackNeutronAdminStateUp
+ networkType: CamelOpenstackNeutronNetworkType
+ physicalNetwork: CamelOpenstackNeutronPhysicalNetwork
+ segmentId: CamelOpenstackNeutronSegmentId
+ isShared: CamelOpenstackNeutronIsShared
+ isRouterExternal: CamelOpenstackNeutronIsRouterExternal
+ enableDHCP: CamelOpenstackNeutronEnableDhcp
+ cidr: CamelOpenstackNeutronCidr
+ subnetPools: CamelOpenstackNeutronSubnetPools
+ macAddress: CamelOpenstackNeutronMacAddress
+ end_marker: CamelOpenstackSwiftEndMarker
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-web3j-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418_3.upgradeWeb3jHeaders
+displayName: Migrate camel-web3j header constants to new naming convention
+description: Renames Web3j-specific header constants to CamelWeb3j* pattern only if camel-web3j dependency is present. Generic headers without clear blockchain context (ADDRESS, ADDRESSES, POSITION, SOURCE_CODE, DATABASE_NAME, KEY_NAME, CLIENT_ID, PRIORITY, TTL, ERROR_CODE, ERROR_DATA, ERROR_MESSAGE, TOPICS, FILTER_ID) are excluded to prevent false positives. Note - DSL accessor renames and operation semantics still require manual review.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-web3j
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ AT_BLOCK: CamelWeb3jAtBlock
+ FROM_ADDRESS: CamelWeb3jFromAddress
+ TO_ADDRESS: CamelWeb3jToAddress
+ BLOCK_HASH: CamelWeb3jBlockHash
+ TRANSACTION_HASH: CamelWeb3jTransactionHash
+ SHA3_HASH_OF_DATA_TO_SIGN: CamelWeb3jSha3HashOfDataToSign
+ SIGNED_TRANSACTION_DATA: CamelWeb3jSignedTransactionData
+ FULL_TRANSACTION_OBJECTS: CamelWeb3jFullTransactionObjects
+ NONCE: CamelWeb3jNonce
+ HEADER_POW_HASH: CamelWeb3jHeaderPowHash
+ MIX_DIGEST: CamelWeb3jMixDigest
+ GAS_PRICE: CamelWeb3jGasPrice
+ GAS_LIMIT: CamelWeb3jGasLimit
+ FROM_BLOCK: CamelWeb3jFromBlock
+ TO_BLOCK: CamelWeb3jToBlock
+ PRIVATE_FOR: CamelWeb3jPrivateFor
+ PRIVATE_FROM: CamelWeb3jPrivateFrom
+ ETH_HASHRATE: CamelWeb3jEthHashrate
\ No newline at end of file
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.yaml
index c57d229..2020733 100644
--- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.yaml
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18.yaml
@@ -37,3 +37,83 @@ recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.eclipse.tahu.host.api.HostApplicationEventHandler
newFullyQualifiedTypeName: org.eclipse.tahu.host.api.MultiHostApplicationEventHandler
+ # Header renames introduced in 4.18
+ - org.apache.camel.upgrade.camel418.upgradeKafkaRecipes
+ - org.apache.camel.upgrade.camel418.upgradeDnsHeaders
+ - org.apache.camel.upgrade.camel418.upgradeSalesforceHeaders
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-kafka---potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418.upgradeKafkaRecipes
+displayName: Migrate camel-kafka headers
+description: Renames Kafka header constants only if camel-kafka dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-kafka
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ kafka.PARTITION_KEY: CamelKafkaPartitionKey
+ kafka.PARTITION: CamelKafkaPartition
+ kafka.KEY: CamelKafkaKey
+ kafka.TOPIC: CamelKafkaTopic
+ kafka.OVERRIDE_TOPIC: CamelKafkaOverrideTopic
+ kafka.OFFSET: CamelKafkaOffset
+ kafka.HEADERS: CamelKafkaHeaders
+ kafka.LAST_RECORD_BEFORE_COMMIT: CamelKafkaLastRecordBeforeCommit
+ kafka.LAST_POLL_RECORD: CamelKafkaLastPollRecord
+ kafka.TIMESTAMP: CamelKafkaTimestamp
+ kafka.OVERRIDE_TIMESTAMP: CamelKafkaOverrideTimestamp
+ kafka.RECORD_META: CamelKafkaRecordMeta
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-dns-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418.upgradeDnsHeaders
+displayName: Migrate camel-dns header constants to new naming convention
+description: Renames DNS header constants from dns.* pattern to CamelDns* pattern only if camel-dns dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-dns
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ dns.class: CamelDnsClass
+ dns.name: CamelDnsName
+ dns.domain: CamelDnsDomain
+ dns.server: CamelDnsServer
+ dns.type: CamelDnsType
+ term: CamelDnsTerm
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc#camel-salesforce-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel418.upgradeSalesforceHeaders
+displayName: Migrate camel-salesforce header constants to new naming convention
+description: Renames Salesforce-specific header constants to CamelSalesforce* pattern when camel-salesforce is present. Only migrates headers with Salesforce-specific terminology (sObject*, apex*, pkChunking*) to minimize false positives. Generic headers like 'limit', 'contentType', 'jobId' are excluded as they could conflict with other components.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-salesforce
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ sObjectName: CamelSalesforceSObjectName
+ sObjectId: CamelSalesforceSObjectId
+ sObjectIds: CamelSalesforceSObjectIds
+ sObjectFields: CamelSalesforceSObjectFields
+ sObjectIdName: CamelSalesforceSObjectIdName
+ sObjectIdValue: CamelSalesforceSObjectIdValue
+ sObjectBlobFieldName: CamelSalesforceSObjectBlobFieldName
+ sObjectClass: CamelSalesforceSObjectClass
+ sObjectQuery: CamelSalesforceSObjectQuery
+ sObjectSearch: CamelSalesforceSObjectSearch
+ apexMethod: CamelSalesforceApexMethod
+ apexUrl: CamelSalesforceApexUrl
+ pkChunking: CamelSalesforcePkChunking
+ pkChunkingChunkSize: CamelSalesforcePkChunkingChunkSize
+ pkChunkingParent: CamelSalesforcePkChunkingParent
+ pkChunkingStartRow: CamelSalesforcePkChunkingStartRow
+ - org.apache.camel.upgrade.camel421.RenameHeaderPrefixes:
+ prefixMappings:
+ apexQueryParam.: CamelSalesforceApexQueryParam.
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18LTS.yaml
similarity index 81%
copy from camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
copy to camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18LTS.yaml
index 5cdc411..ce4c02b 100644
--- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.18LTS.yaml
@@ -16,12 +16,12 @@
#
---
type: specs.openrewrite.org/v1beta/recipe
-name: org.apache.camel.upgrade.CamelMigrationRecipe
-displayName: Migrate to @camel-latest-version@
-description: Migrates Apache Camel application to @camel-latest-version@.
+name: org.apache.camel.upgrade.Camel418LTSMigrationRecipe
+displayName: Migrate to Camel 4.18LTS
+description: Migrates Apache Camel application to 4.18 LTS. This recipe aggregates all migration steps from 4.0 to 4.18.3.
recipeList:
- - org.apache.camel.upgrade.camel420.CamelMigrationRecipe
- - org.apache.camel.upgrade.camel419.CamelMigrationRecipe
+ - org.apache.camel.upgrade.camel418_3.CamelMigrationRecipe
+ - org.apache.camel.upgrade.camel418_1.CamelMigrationRecipe
- org.apache.camel.upgrade.camel418.CamelMigrationRecipe
- org.apache.camel.upgrade.camel417.CamelMigrationRecipe
- org.apache.camel.upgrade.camel416.CamelMigrationRecipe
@@ -43,15 +43,15 @@ recipeList:
- org.openrewrite.maven.UpgradeDependencyVersion:
groupId: 'org.apache.camel'
artifactId: '*'
- newVersion: @camel-latest-version@
+ newVersion: @camel4.18-lts-version@
- org.openrewrite.maven.UpgradePluginVersion:
groupId: 'org.apache.camel'
artifactId: '*'
- newVersion: @camel-latest-version@
+ newVersion: @camel4.18-lts-version@
- org.openrewrite.maven.UpgradeParentVersion:
groupId: 'org.apache.camel'
artifactId: '*'
- newVersion: @camel-latest-version@
+ newVersion: @camel4.18-lts-version@
- org.openrewrite.maven.ChangePropertyValue:
key: camel.version
- newValue: @camel-latest-version@
+ newValue: @camel4.18-lts-version@
\ No newline at end of file
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.19.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.19.yaml
index f59b9fc..3d10cd6 100644
--- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.19.yaml
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.19.yaml
@@ -28,12 +28,11 @@ name: org.apache.camel.upgrade.camel419.CamelMigrationRecipe
displayName: Migrates `camel 4.18` application to `camel 4.19`
description: Migrates `camel 4.18` application to `camel 4.19`.
recipeList:
+ - org.apache.camel.upgrade.camel418_1.saga
+ - org.apache.camel.upgrade.camel418_1.routePolicy
- org.apache.camel.upgrade.camel419.removedComponents
- org.apache.camel.upgrade.camel419.migrateGroovyXml
- - org.apache.camel.upgrade.camel419.XmlDsl419SagaRecipe
- - org.apache.camel.upgrade.camel419.YamlDsl419SagaRecipe
- org.apache.camel.upgrade.camel419.Pom419TestInfraRecipe
- - org.apache.camel.upgrade.camel419.YamlDsl419RoutePolicyRecipe
---
type: specs.openrewrite.org/v1beta/recipe
name: org.apache.camel.upgrade.camel419.removedComponents
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.21.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.21.yaml
new file mode 100644
index 0000000..2606659
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.21.yaml
@@ -0,0 +1,428 @@
+#
+# 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.
+#
+
+#####
+# Rules coming from https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html
+#####
+
+#####
+# Update the Camel project from 4.20 to 4.21
+#####
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.CamelMigrationRecipe
+displayName: Migrates `camel 4.20` application to `camel 4.21`
+description: Migrates `camel 4.20` application to `camel 4.21`.
+recipeList:
+ ## inherited from patch recipe
+ - org.apache.camel.upgrade.camel418_3.upgradeJGroupsHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeJiraHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeJGroupsRaftHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeShiroHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeSolrHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeMongoDbGridFsHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeGitHub2Headers
+ - org.apache.camel.upgrade.camel418_3.upgradeGoogleCloudHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeGoogleSecretManagerHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeLuceneHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeOpenstackHeaders
+ - org.apache.camel.upgrade.camel418_3.upgradeWeb3jHeaders
+ ## defined here
+ - org.apache.camel.upgrade.camel421.upgradeKafkaRecipes
+ - org.apache.camel.upgrade.camel421.upgradeDnsHeaders
+ - org.apache.camel.upgrade.camel421.upgradeCouchdbHeaders
+ - org.apache.camel.upgrade.camel421.upgradeCouchbaseHeaders
+ - org.apache.camel.upgrade.camel421.upgradeGitHub2Headers
+ - org.apache.camel.upgrade.camel421.upgradeGoogleCloudVisionHeaders
+ - org.apache.camel.upgrade.camel421.upgradeGoogleCloudTextToSpeechHeaders
+ - org.apache.camel.upgrade.camel421.upgradeGoogleCloudSpeechToTextHeaders
+ - org.apache.camel.upgrade.camel421.upgradePdfHeaders
+ - org.apache.camel.upgrade.camel421.upgradeArangoDbHeaders
+ - org.apache.camel.upgrade.camel421.upgradeJt400Headers
+ - org.apache.camel.upgrade.camel421.upgradeMailHeaders
+ - org.apache.camel.upgrade.camel421.upgradeMiloHeaders
+ - org.apache.camel.upgrade.camel421.upgradeOpensearchHeaders
+ - org.apache.camel.upgrade.camel421.upgradeIrcHeaders
+ - org.apache.camel.upgrade.camel421.RemoveReifierStrategyImport
+ - org.apache.camel.upgrade.camel421.RemoveZooWordEmbeddingPredictorImport
+ - org.apache.camel.upgrade.camel421.removeCamelStompDependency
+ - org.apache.camel.upgrade.camel421.removeCamelAwsXrayDependency
+ - org.apache.camel.upgrade.camel421.removeCamelGuavaEventbusDependency
+ - org.apache.camel.upgrade.camel421.removeCamelGrapeDependency
+ - org.apache.camel.upgrade.camel421.removeCamelElytronDependency
+ - org.apache.camel.upgrade.camel421.removeCamelGithubDependency
+ - org.apache.camel.upgrade.camel421.migrateAws2S3ListObjectsApi
+ - org.apache.camel.upgrade.camel421.migrateErrorRegistryProperties
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-kafka---potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeKafkaRecipes
+displayName: Migrate camel-kafka headers
+description: Renames Kafka header constants only if camel-kafka dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-kafka
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ kafka.PARTITION_KEY: CamelKafkaPartitionKey
+ kafka.PARTITION: CamelKafkaPartition
+ kafka.KEY: CamelKafkaKey
+ kafka.TOPIC: CamelKafkaTopic
+ kafka.OVERRIDE_TOPIC: CamelKafkaOverrideTopic
+ kafka.OFFSET: CamelKafkaOffset
+ kafka.HEADERS: CamelKafkaHeaders
+ kafka.LAST_RECORD_BEFORE_COMMIT: CamelKafkaLastRecordBeforeCommit
+ kafka.LAST_POLL_RECORD: CamelKafkaLastPollRecord
+ kafka.TIMESTAMP: CamelKafkaTimestamp
+ kafka.OVERRIDE_TIMESTAMP: CamelKafkaOverrideTimestamp
+ kafka.RECORD_META: CamelKafkaRecordMeta
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-dns-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeDnsHeaders
+displayName: Migrate camel-dns header constants to new naming convention
+description: Renames DNS header constants from dns.* pattern to CamelDns* pattern only if camel-dns dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-dns
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ dns.class: CamelDnsClass
+ dns.name: CamelDnsName
+ dns.domain: CamelDnsDomain
+ dns.server: CamelDnsServer
+ dns.type: CamelDnsType
+ term: CamelDnsTerm
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-couchdb
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeCouchdbHeaders
+displayName: Migrate camel-couchdb header constants to new naming convention
+description: Renames CouchDB header constants to CamelCouchDb* pattern only if camel-couchdb dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-couchdb
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ CouchDbDatabase: CamelCouchDbDatabase
+ CouchDbSeq: CamelCouchDbSeq
+ CouchDbId: CamelCouchDbId
+ CouchDbRev: CamelCouchDbRev
+ CouchDbMethod: CamelCouchDbMethod
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-couchbase
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeCouchbaseHeaders
+displayName: Migrate camel-couchbase header constants to new naming convention
+description: Renames Couchbase header constants to CamelCouchbase* pattern only if camel-couchbase dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-couchbase
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ CCB_KEY: CamelCouchbaseKey
+ CCB_ID: CamelCouchbaseId
+ CCB_TTL: CamelCouchbaseTtl
+ CCB_DDN: CamelCouchbaseDesignDocumentName
+ CCB_VN: CamelCouchbaseViewName
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-github2-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeGitHub2Headers
+displayName: Migrate camel-github2 producer header constants to new naming convention
+description: Renames GitHub2 producer header constants to CamelGitHub* pattern only if camel-github dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-github
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ GitHubPullRequest: CamelGitHubPullRequest
+ GitHubInResponseTo: CamelGitHubInResponseTo
+ GitHubPullRequestHeadCommitSHA: CamelGitHubPullRequestHeadCommitSha
+ GitHubIssueTitle: CamelGitHubIssueTitle
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-google-functions-camel-google-secret-manager-camel-google-vision-camel-google-text-to-speech-camel-google-speech-to-text-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeGoogleCloudVisionHeaders
+displayName: Migrate camel-google-vision header constants to new naming convention
+description: Renames Google Vision header constants to CamelGoogleCloud* pattern only if camel-google-functions dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-google-vision
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ GoogleCloudVisionOperation: CamelGoogleCloudVisionOperation
+ GoogleCloudVisionResponseObject: CamelGoogleCloudVisionResponseObject
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-google-functions-camel-google-secret-manager-camel-google-vision-camel-google-text-to-speech-camel-google-speech-to-text-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeGoogleCloudTextToSpeechHeaders
+displayName: Migrate camel-google-test-to-spech header constants to new naming convention
+description: Renames Google Vision header constants to CamelGoogleCloud* pattern only if camel-google-functions dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-google-text-to-speech
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ GoogleCloudTextToSpeechOperation: CamelGoogleCloudTextToSpeechOperation
+ GoogleCloudTextToSpeechResponseObject: CamelGoogleCloudTextToSpeechResponseObject
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-google-functions-camel-google-secret-manager-camel-google-vision-camel-google-text-to-speech-camel-google-speech-to-text-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeGoogleCloudSpeechToTextHeaders
+displayName: Migrate camel-google-speech-to-text header constants to new naming convention
+description: Renames Google Vision header constants to CamelGoogleCloud* pattern only if camel-google-functions dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-google-speech-to-text
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ GoogleCloudSpeechToTextOperation: CamelGoogleCloudSpeechToTextOperation
+ GoogleCloudSpeechToTextResponseObject: CamelGoogleCloudSpeechToTextResponseObject
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-irc-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeIrcHeaders
+displayName: Migrate camel-irc header constants to new naming convention
+description: Renames IRC header constants from irc.* to CamelIrc* pattern only if camel-irc dependency is present.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-irc
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ irc.messageType: CamelIrcMessageType
+ irc.target: CamelIrcTarget
+ irc.sendTo: CamelIrcSendTo
+ irc.user.kicked: CamelIrcUserKicked
+ irc.user.host: CamelIrcUserHost
+ irc.user.nick: CamelIrcUserNick
+ irc.user.servername: CamelIrcUserServername
+ irc.user.username: CamelIrcUserUsername
+ irc.num: CamelIrcNum
+ irc.value: CamelIrcValue
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-pdf-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradePdfHeaders
+displayName: Migrate camel-pdf header constants to new naming convention
+description: Renames PDF header constants to CamelPdf* pattern only if camel-pdf dependency is present. Note - DSL accessor methods (protectionPolicy() → pdfProtectionPolicy(), etc.) are NOT migrated and require manual update.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-pdf
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ protection-policy: CamelPdfProtectionPolicy
+ pdf-document: CamelPdfDocument
+ decryption-material: CamelPdfDecryptionMaterial
+ files-to-merge: CamelPdfFilesToMerge
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-arangodb-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeArangoDbHeaders
+displayName: Migrate camel-arangodb header constants to new naming convention
+description: Renames ArangoDB header constants to CamelArangoDb* pattern only if camel-arangodb dependency is present. Note - DSL accessor methods (key() → arangoDbKey(), resultClassType() → arangoDbResultClassType()) are NOT migrated and require manual update.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-arangodb
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ key: CamelArangoDbKey
+ ResultClassType: CamelArangoDbResultClassType
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-jt400-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeJt400Headers
+displayName: Migrate camel-jt400 header constants to new naming convention
+description: Renames JT400 header constants to CamelJt400* pattern only if camel-jt400 dependency is present. Note - DSL accessor methods (kEY() → jt400Key(), senderInformation() → jt400SenderInformation()) are NOT migrated and require manual update.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-jt400
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ KEY: CamelJt400Key
+ SENDER_INFORMATION: CamelJt400SenderInformation
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-mail-2
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeMailHeaders
+displayName: Migrate camel-mail consumer dispatch header constants to new naming convention
+description: Renames Mail consumer dispatch header constants to CamelMail* pattern only if camel-mail dependency is present. Note - DSL accessor methods (copyTo() → mailCopyTo(), moveTo() → mailMoveTo(), delete() → mailDelete()) are NOT migrated and require manual update.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-mail
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ copyTo: CamelMailCopyTo
+ moveTo: CamelMailMoveTo
+ delete: CamelMailDelete
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-milo-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeMiloHeaders
+displayName: Migrate camel-milo header constants to new naming convention
+description: Renames Milo header constants to CamelMilo* pattern only if camel-milo dependency is present. Note - DSL accessor method (await() → miloAwait()) is NOT migrated and requires manual update.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-milo
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ await: CamelMiloAwait
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-elasticsearch-camel-opensearch-potential-breaking-change
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.upgradeOpensearchHeaders
+displayName: Migrate camel-opensearch header constants to new naming convention
+description: Renames OpenSearch header constants to CamelOpensearch* pattern only if camel-opensearch dependency is present. Note - DSL accessor methods (operation() → opensearchOperation(), indexId() → opensearchIndexId(), etc.) are NOT migrated and require manual update.
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-opensearch
+recipeList:
+ - org.apache.camel.upgrade.camel421.RenameHeaders:
+ headerMappings:
+ operation: CamelOpensearchOperation
+ indexId: CamelOpensearchIndexId
+ indexName: CamelOpensearchIndexName
+ documentClass: CamelOpensearchDocumentClass
+ waitForActiveShards: CamelOpensearchWaitForActiveShards
+ scrollKeepAliveMs: CamelOpensearchScrollKeepAliveMs
+ useScroll: CamelOpensearchUseScroll
+ size: CamelOpensearchSize
+ from: CamelOpensearchFrom
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-stomp-removal
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.removeCamelStompDependency
+displayName: Remove camel-stomp dependency
+description: Removes the camel-stomp dependency which was removed in Camel 4.21 (deprecated since 4.17).
+recipeList:
+ - org.openrewrite.maven.RemoveDependency:
+ groupId: org.apache.camel
+ artifactId: camel-stomp
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-aws-xray-removal
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.removeCamelAwsXrayDependency
+displayName: Remove camel-aws-xray dependency
+description: Removes the camel-aws-xray dependency which was removed in Camel 4.21 (deprecated since 4.17, AWS X-Ray service in maintenance mode).
+recipeList:
+ - org.openrewrite.maven.RemoveDependency:
+ groupId: org.apache.camel
+ artifactId: camel-aws-xray
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-guava-eventbus-removal
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.removeCamelGuavaEventbusDependency
+displayName: Remove camel-guava-eventbus dependency
+description: Removes the camel-guava-eventbus dependency which was removed in Camel 4.21 (deprecated since 4.6).
+recipeList:
+ - org.openrewrite.maven.RemoveDependency:
+ groupId: org.apache.camel
+ artifactId: camel-guava-eventbus
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-grape-removal
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.removeCamelGrapeDependency
+displayName: Remove camel-grape dependency
+description: Removes the camel-grape dependency which was removed in Camel 4.21 (deprecated since 4.1).
+recipeList:
+ - org.openrewrite.maven.RemoveDependency:
+ groupId: org.apache.camel
+ artifactId: camel-grape
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-elytron-removal
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.removeCamelElytronDependency
+displayName: Remove camel-elytron dependency
+description: Removes the camel-elytron dependency which was removed in Camel 4.21 (deprecated since 4.0).
+recipeList:
+ - org.openrewrite.maven.RemoveDependency:
+ groupId: org.apache.camel
+ artifactId: camel-elytron
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-github-removal
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.removeCamelGithubDependency
+displayName: Remove camel-github dependency
+description: Removes the camel-github dependency which was removed in Camel 4.21 (deprecated in 4.18, replaced by camel-github2).
+recipeList:
+ - org.openrewrite.maven.RemoveDependency:
+ groupId: org.apache.camel
+ artifactId: camel-github
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#camel-aws2-s3
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.migrateAws2S3ListObjectsApi
+displayName: Migrate camel-aws2-s3 listObjects to V2 API
+description: Migrates ListObjectsRequest/Response to ListObjectsV2Request/Response for the listObjects operation (pojoRequest=true only).
+preconditions:
+ - org.openrewrite.java.dependencies.search.ModuleHasDependency:
+ groupIdPattern: org.apache.camel
+ artifactIdPattern: camel-aws2-s3
+recipeList:
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: software.amazon.awssdk.services.s3.model.ListObjectsRequest
+ newFullyQualifiedTypeName: software.amazon.awssdk.services.s3.model.ListObjectsV2Request
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: software.amazon.awssdk.services.s3.model.ListObjectsResponse
+ newFullyQualifiedTypeName: software.amazon.awssdk.services.s3.model.ListObjectsV2Response
+---
+## https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc#error-registry
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel421.migrateErrorRegistryProperties
+displayName: Migrate Error Registry configuration properties
+description: Migrates Error Registry configuration from camel.main.errorRegistryXxx to camel.errorRegistry.* pattern in .properties files. Note - errorRegistryStackTraceEnabled is removed (always captures full exception now). YAML files require manual migration.
+recipeList:
+ - org.openrewrite.properties.ChangePropertyKey:
+ oldPropertyKey: camel.main.errorRegistryEnabled
+ newPropertyKey: camel.errorRegistry.enabled
+ - org.openrewrite.properties.ChangePropertyKey:
+ oldPropertyKey: camel.main.errorRegistryMaximumEntries
+ newPropertyKey: camel.errorRegistry.maximumEntries
+ - org.openrewrite.properties.ChangePropertyKey:
+ oldPropertyKey: camel.main.errorRegistryTimeToLiveSeconds
+ newPropertyKey: camel.errorRegistry.timeToLiveSeconds
+ - org.openrewrite.properties.DeleteProperty:
+ propertyKey: camel.main.errorRegistryStackTraceEnabled
diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/examples.yml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/examples.yml
new file mode 100644
index 0000000..d2aeab9
--- /dev/null
+++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/examples.yml
@@ -0,0 +1,254 @@
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderInJavaMethod
+examples:
+- description: ''
+ parameters:
+ - kafka.TOPIC
+ - CamelKafkaTopic
+ sources:
+ - before: |
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("kafka.TOPIC", "my-topic");
+ }
+ }
+ after: |
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("CamelKafkaTopic", "my-topic");
+ }
+ }
+ language: java
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderInSimpleExpression
+examples:
+- description: ''
+ parameters:
+ - kafka.TOPIC
+ - CamelKafkaTopic
+ sources:
+ - before: |
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.kafka.TOPIC}"));
+ }
+ }
+ after: |
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.CamelKafkaTopic}"));
+ }
+ }
+ language: java
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderInXmlDsl
+examples:
+- description: ''
+ parameters:
+ - kafka.TOPIC
+ - CamelKafkaTopic
+ sources:
+ - before: |
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="kafka.TOPIC">
+ <constant>my-topic</constant>
+ </setHeader>
+ </route>
+ after: |
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelKafkaTopic">
+ <constant>my-topic</constant>
+ </setHeader>
+ </route>
+ language: xml
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderInYamlDsl
+examples:
+- description: ''
+ parameters:
+ - kafka.TOPIC
+ - CamelKafkaTopic
+ sources:
+ - before: |
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: kafka.TOPIC
+ constant: my-topic
+ after: |
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelKafkaTopic
+ constant: my-topic
+ language: yaml
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderPrefixInJavaMethod
+examples:
+- description: ''
+ parameters:
+ - SolrField.
+ - CamelSolrField.
+ sources:
+ - before: |
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("SolrField.id", "doc123");
+ exchange.getIn().setHeader("SolrField.name", "Test Document");
+ }
+ }
+ after: |
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("CamelSolrField.id", "doc123");
+ exchange.getIn().setHeader("CamelSolrField.name", "Test Document");
+ }
+ }
+ language: java
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderPrefixInSimpleExpression
+examples:
+- description: ''
+ parameters:
+ - SolrField.
+ - CamelSolrField.
+ sources:
+ - before: |
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.SolrField.id}"));
+ }
+ }
+ after: |
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.CamelSolrField.id}"));
+ }
+ }
+ language: java
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderPrefixInXmlDsl
+examples:
+- description: ''
+ parameters:
+ - SolrField.
+ - CamelSolrField.
+ sources:
+ - before: |
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="SolrField.id">
+ <constant>doc123</constant>
+ </setHeader>
+ </route>
+ after: |
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelSolrField.id">
+ <constant>doc123</constant>
+ </setHeader>
+ </route>
+ language: xml
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaderPrefixInYamlDsl
+examples:
+- description: ''
+ parameters:
+ - SolrField.
+ - CamelSolrField.
+ sources:
+ - before: |
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: SolrField.id
+ constant: doc123
+ after: |
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelSolrField.id
+ constant: doc123
+ language: yaml
+---
+type: specs.openrewrite.org/v1beta/example
+recipeName: org.apache.camel.upgrade.camel421.RenameHeaders
+examples:
+- description: ''
+ parameters:
+ - |-
+ Map.of(
+ "kafka.TOPIC", "CamelKafkaTopic",
+ "kafka.PARTITION", "CamelKafkaPartition",
+ "kafka.KEY", "CamelKafkaKey"
+ )
+ sources:
+ - before: |
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("kafka.TOPIC", "topic1");
+ exchange.getIn().setHeader("kafka.PARTITION", "0");
+ exchange.getIn().setHeader("kafka.KEY", "key1");
+ })
+ .setBody(simple("Topic: ${header.kafka.TOPIC}, Partition: ${header.kafka.PARTITION}"));
+ }
+ }
+ after: |
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelKafkaTopic", "topic1");
+ exchange.getIn().setHeader("CamelKafkaPartition", "0");
+ exchange.getIn().setHeader("CamelKafkaKey", "key1");
+ })
+ .setBody(simple("Topic: ${header.CamelKafkaTopic}, Partition: ${header.CamelKafkaPartition}"));
+ }
+ }
+ language: java
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 5cdc411..921aa54 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
@@ -20,6 +20,7 @@ name: org.apache.camel.upgrade.CamelMigrationRecipe
displayName: Migrate to @camel-latest-version@
description: Migrates Apache Camel application to @camel-latest-version@.
recipeList:
+ - org.apache.camel.upgrade.camel421.CamelMigrationRecipe
- org.apache.camel.upgrade.camel420.CamelMigrationRecipe
- org.apache.camel.upgrade.camel419.CamelMigrationRecipe
- org.apache.camel.upgrade.camel418.CamelMigrationRecipe
diff --git a/camel-upgrade-recipes/src/main/resources/versions.properties b/camel-upgrade-recipes/src/main/resources/versions.properties
index 77c7f77..df2bdb8 100644
--- a/camel-upgrade-recipes/src/main/resources/versions.properties
+++ b/camel-upgrade-recipes/src/main/resources/versions.properties
@@ -1,4 +1,5 @@
camel.latest.version=@camel-latest-version@
camel4.10.lts.version=@camel4.10-lts-version@
+camel4.18.lts.version=@camel4.18-lts-version@
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelTestUtil.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelTestUtil.java
index 25e3360..ba77142 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelTestUtil.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelTestUtil.java
@@ -55,8 +55,11 @@ public class CamelTestUtil {
v4_16(4, 16, 0),
v4_17(4, 17, 0),
v4_18(4, 18, 0),
+ v4_18_1(4, 18, 1, true),
+ v4_18_3(4, 18, 3, true),
v4_19(4, 19, 0),
- v4_20(4, 20, 0);
+ v4_20(4, 20, 0),
+ v4_21(4, 21, 0);
private int major;
private int minor;
@@ -100,11 +103,17 @@ public class CamelTestUtil {
}
public static RecipeSpec recipe(RecipeSpec spec, CamelVersion to, String... activeRecipes) {
+ return recipe(spec, to, false, activeRecipes);
+ }
+ public static RecipeSpec recipe(RecipeSpec spec, CamelVersion to, boolean useAllRecipes, String... activeRecipes) {
String useRecipe = System.getProperty(CamelTestUtil.PROPERTY_USE_RECIPE);
if (useRecipe != null && !useRecipe.isEmpty()) {
return spec.recipeFromResources(useRecipe);
}
if (activeRecipes == null || activeRecipes.length == 0) {
+ if (useAllRecipes) {
+ return spec.recipeFromResources(to.getRecipe());
+ }
return spec.recipeFromResource(to.getYamlFile(), to.getRecipe());
}
return spec.recipeFromResource(to.getYamlFile(), activeRecipes);
@@ -153,6 +162,10 @@ public class CamelTestUtil {
return getString(
"camel4.10.lts.version", "Could not determine 4.10 lts version from properties file.");
}
+ public static String getCamel418LtsVersion() {
+ return getString(
+ "camel4.18.lts.version", "Could not determine 4.18 lts version from properties file.");
+ }
/**
@@ -178,4 +191,32 @@ public class CamelTestUtil {
return "";
}
+ /**
+ * Helper method to create a minimal pom.xml with a Camel component dependency.
+ * This is required for the ModuleHasDependency precondition to work in tests.
+ *
+ * @param artifactId the Camel component artifact ID (e.g., "camel-kafka")
+ * @param version the Camel version to use for the dependency
+ * @return a minimal pom.xml string with the specified dependency
+ */
+ public static String pomXmlWithDependency(String artifactId, CamelVersion version) {
+ return """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties> \s
+ <maven.compiler.release>17</maven.compiler.release> \s
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>%s</artifactId>
+ <version>%s</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """.formatted(artifactId, version.getVersion());
+ }
+
}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418Test.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418Test.java
index 2aaa83e..48fd646 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418Test.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418Test.java
@@ -23,6 +23,8 @@ import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.TypeValidation;
import static org.openrewrite.java.Assertions.java;
+import static org.openrewrite.java.Assertions.mavenProject;
+import static org.openrewrite.maven.Assertions.pomXml;
//class has to stay public, because test is extended in project quarkus-updates
public class CamelUpdate418Test implements RewriteTest {
@@ -31,7 +33,7 @@ public class CamelUpdate418Test implements RewriteTest {
public void defaults(RecipeSpec spec) {
CamelTestUtil.recipe(spec, CamelTestUtil.CamelVersion.v4_18)
.parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_17,
- "camel-core-model", "camel-api", "camel-qdrant", "camel-tahu", "tahu-host"))
+ "camel-core-model", "camel-api", "camel-support", "camel-qdrant", "camel-tahu", "tahu-host"))
.typeValidationOptions(TypeValidation.none());
}
@@ -40,7 +42,7 @@ public class CamelUpdate418Test implements RewriteTest {
*/
@DocumentExample
@Test
- void qdrantHeadersChange() {
+ void testQdrantHeadersChange() {
//language=java
rewriteRun(java(
"""
@@ -69,7 +71,7 @@ public class CamelUpdate418Test implements RewriteTest {
* <a href="https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#_camel_tahu">camel-tahu changes</a>
*/
@Test
- void tahuChange() {
+ void testTahuChange() {
//language=java
rewriteRun(java(
"""
@@ -97,4 +99,140 @@ public class CamelUpdate418Test implements RewriteTest {
}
"""));
}
+
+ @Test
+ void testKafkaHeadersMigration() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-kafka",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-kafka", CamelTestUtil.CamelVersion.v4_17)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("kafka.TOPIC", "topic1");
+ })
+ .setBody(simple("${header.kafka.TOPIC}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelKafkaTopic", "topic1");
+ })
+ .setBody(simple("${header.CamelKafkaTopic}"));
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testDnsHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-dns",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-dns", CamelTestUtil.CamelVersion.v4_17)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("dns.name", "www.example.com");
+ exchange.getIn().setHeader("dns.server", "8.8.8.8");
+ exchange.getIn().setHeader("term", "example");
+ })
+ .setBody(simple("${header.term} ${header.dns.name}"))
+ .to("dns:lookup");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelDnsName", "www.example.com");
+ exchange.getIn().setHeader("CamelDnsServer", "8.8.8.8");
+ exchange.getIn().setHeader("CamelDnsTerm", "example");
+ })
+ .setBody(simple("${header.CamelDnsTerm} ${header.CamelDnsName}"))
+ .to("dns:lookup");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testSalesforceHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-salesforce",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-salesforce", CamelTestUtil.CamelVersion.v4_17)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ // Only Salesforce-specific headers are migrated
+ exchange.getIn().setHeader("sObjectName", "Account");
+ exchange.getIn().setHeader("sObjectQuery", "SELECT Id FROM Account");
+ exchange.getIn().setHeader("sObjectId", "001xx000003DGYM");
+ exchange.getIn().setHeader("apexMethod", "POST");
+ exchange.getIn().setHeader("apexUrl", "/services/apexrest/MyService");
+ exchange.getIn().setHeader("apexQueryParam.foo", "bar");
+ exchange.getIn().setHeader("pkChunking", "true");
+ // Generic headers like jobId, batchId, limit, contentType are NOT migrated
+ exchange.getIn().setHeader("jobId", "job123");
+ exchange.getIn().setHeader("limit", "100");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ // Only Salesforce-specific headers are migrated
+ exchange.getIn().setHeader("CamelSalesforceSObjectName", "Account");
+ exchange.getIn().setHeader("CamelSalesforceSObjectQuery", "SELECT Id FROM Account");
+ exchange.getIn().setHeader("CamelSalesforceSObjectId", "001xx000003DGYM");
+ exchange.getIn().setHeader("CamelSalesforceApexMethod", "POST");
+ exchange.getIn().setHeader("CamelSalesforceApexUrl", "/services/apexrest/MyService");
+ exchange.getIn().setHeader("CamelSalesforceApexQueryParam.foo", "bar");
+ exchange.getIn().setHeader("CamelSalesforcePkChunking", "true");
+ // Generic headers like jobId, batchId, limit, contentType are NOT migrated
+ exchange.getIn().setHeader("jobId", "job123");
+ exchange.getIn().setHeader("limit", "100");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418_1Test.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418_1Test.java
new file mode 100644
index 0000000..55387a4
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418_1Test.java
@@ -0,0 +1,153 @@
+/*
+ * 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.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.xml.Assertions.xml;
+import static org.openrewrite.yaml.Assertions.yaml;
+
+//class has to stay public, because test is extended in project quarkus-updates
+public class CamelUpdate418_1Test implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ CamelTestUtil.recipe(spec, CamelTestUtil.CamelVersion.v4_18_1, true)
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_18,
+ "camel-core-model", "camel-api", "camel-qdrant", "camel-tahu", "tahu-host"))
+ .typeValidationOptions(TypeValidation.none());
+ }
+
+
+ /**
+ * <a href="https://camel.apache.org/manual/camel-4x-upgrade-guide-4_19.html#_saga_eip">Saga EIP</a>
+ */
+ @Test
+ void testSagaEipXml() {
+ //language=xml
+ rewriteRun(xml(
+ """
+ <route>
+ <from uri="direct:start"/>
+ <saga sagaService="mySagaService">
+ <compensation uri="mock:compensation"/>
+ <completion uri="mock:completion"/>
+ <option key="myOptionKey">
+ <constant>myOptionValue</constant>
+ </option>
+ <option key="myOptionKey2">
+ <constant>myOptionValue2</constant>
+ </option>
+ </saga>
+ <choice>
+ <when>
+ <simple>${body} == 'fail'</simple>
+ <throwException exceptionType="java.lang.RuntimeException" message="fail"/>
+ </when>
+ </choice>
+ <to uri="mock:end"/>
+ </route>
+ """,
+ """
+ <route>
+ <from uri="direct:start"/>
+ <saga sagaService="mySagaService" compensation="mock:compensation" completion="mock:completion">
+ <option key="myOptionKey">
+ <constant>myOptionValue</constant>
+ </option>
+ <option key="myOptionKey2">
+ <constant>myOptionValue2</constant>
+ </option>
+ </saga>
+ <choice>
+ <when>
+ <simple>${body} == 'fail'</simple>
+ <throwException exceptionType="java.lang.RuntimeException" message="fail"/>
+ </when>
+ </choice>
+ <to uri="mock:end"/>
+ </route>
+ """));
+ }
+
+ /**
+ * <a href="https://camel.apache.org/manual/camel-4x-upgrade-guide-4_19.html#_saga_eip">Saga EIP</a>
+ */
+ @Test
+ void testSagaEipYaml() {
+ //language=yaml
+ rewriteRun(yaml(
+ """
+ - route:
+ from:
+ uri: direct:start
+ steps:
+ - saga:
+ compensation:
+ uri: direct:compensate
+ completion:
+ uri: direct:complete
+ steps:
+ - to:
+ uri: direct:action
+ """,
+ """
+ - route:
+ from:
+ uri: direct:start
+ steps:
+ - saga:
+ compensation: direct:compensate
+ completion: direct:complete
+ steps:
+ - to:
+ uri: direct:action
+ """));
+ }
+
+ /**
+ * <a href="https://camel.apache.org/manual/camel-4x-upgrade-guide-4_19.html#_camel_yaml_io_camel_xml_io">YAML DSL</a>
+ */
+ @Test
+ void testYamlDslRoutePolicyRename() {
+ //language=yaml
+ rewriteRun(yaml(
+ """
+ - route:
+ id: myRoute
+ routePolicy: myPolicy
+ from:
+ uri: direct:start
+ steps:
+ - to:
+ uri: mock:result
+ """,
+ """
+ - route:
+ id: myRoute
+ routePolicyRef: myPolicy
+ from:
+ uri: direct:start
+ steps:
+ - to:
+ uri: mock:result
+ """));
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418_3Test.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418_3Test.java
new file mode 100644
index 0000000..fbb776f
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate418_3Test.java
@@ -0,0 +1,577 @@
+/*
+ * 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.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.java.Assertions.java;
+import static org.openrewrite.java.Assertions.mavenProject;
+import static org.openrewrite.maven.Assertions.pomXml;
+import static org.openrewrite.xml.Assertions.xml;
+import static org.openrewrite.yaml.Assertions.yaml;
+
+/**
+ * Tests for migrating from Camel 4.18.1 to 4.18.3.
+ * Most changes are header renames that were introduced in 4.18.x and reused from 4.21 recipes.
+ */
+public class CamelUpdate418_3Test implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ CamelTestUtil.recipe(spec, CamelTestUtil.CamelVersion.v4_18_3)
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_18_1, "camel-api",
+ "camel-core-model", "camel-support"))
+ .typeValidationOptions(TypeValidation.none());
+ }
+
+ @Test
+ void testLuceneHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-lucene",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-lucene", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ // QUERY is too generic, not migrated to prevent false positives
+ exchange.getIn().setHeader("QUERY", "lucene query");
+ // Only Lucene-specific headers are migrated
+ exchange.getIn().setHeader("RETURN_LUCENE_DOCS", true);
+ })
+ .to("lucene:insert");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ // QUERY is too generic, not migrated to prevent false positives
+ exchange.getIn().setHeader("QUERY", "lucene query");
+ // Only Lucene-specific headers are migrated
+ exchange.getIn().setHeader("CamelLuceneReturnLuceneDocs", true);
+ })
+ .to("lucene:insert");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testJGroupsHeadersMigration() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-jgroups",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-jgroups", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("JGROUPS_CHANNEL_ADDRESS", "addr1");
+ exchange.getIn().setHeader("JGROUPS_DEST", "destination");
+ })
+ .to("jgroups:clusterName");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelJGroupsChannelAddress", "addr1");
+ exchange.getIn().setHeader("CamelJGroupsDest", "destination");
+ })
+ .to("jgroups:clusterName");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testJiraHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-jira",
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <repositories>
+ <repository>
+ <id>atlassian</id>
+ <url>https://packages.atlassian.com/artifactory/maven-atlassian-all/</url>
+ <name>atlassian external repo</name>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jira</artifactId>
+ <version>4.18.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """
+ ),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("IssueKey", "CAMEL-12345");
+ exchange.getIn().setHeader("IssueSummary", "Bug fix");
+ exchange.getIn().setHeader("ProjectKey", "CAMEL");
+ exchange.getIn().setHeader("linkType", "Relates");
+ exchange.getIn().setHeader("minutesSpent", 30);
+ })
+ .to("jira:addIssue");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelJiraIssueKey", "CAMEL-12345");
+ exchange.getIn().setHeader("CamelJiraIssueSummary", "Bug fix");
+ exchange.getIn().setHeader("CamelJiraIssueProjectKey", "CAMEL");
+ exchange.getIn().setHeader("CamelJiraLinkType", "Relates");
+ exchange.getIn().setHeader("CamelJiraMinutesSpent", 30);
+ })
+ .to("jira:addIssue");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testJGroupsRaftHeadersMigration() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-jgroups-raft",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-jgroups-raft", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("JGROUPSRAFT_SET_OFFSET", 10);
+ exchange.getIn().setHeader("JGROUPSRAFT_SET_TIMEOUT", 5000);
+ })
+ .to("jgroups-raft:cluster");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelJGroupsRaftSetOffset", 10);
+ exchange.getIn().setHeader("CamelJGroupsRaftSetTimeout", 5000);
+ })
+ .to("jgroups-raft:cluster");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testShiroHeadersMigration() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-shiro",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-shiro", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("SHIRO_SECURITY_USERNAME", "admin");
+ exchange.getIn().setHeader("SHIRO_SECURITY_PASSWORD", "secret");
+ })
+ .to("shiro:login");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelShiroSecurityUsername", "admin");
+ exchange.getIn().setHeader("CamelShiroSecurityPassword", "secret");
+ })
+ .to("shiro:login");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testSolrHeadersMigration() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-solr",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-solr", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("SolrField.id", "doc123");
+ exchange.getIn().setHeader("SolrField.name", "Test Document");
+ exchange.getIn().setHeader("SolrParam.commit", true);
+ exchange.getIn().setHeader("SolrParam.commitWithin", 1000);
+ })
+ .to("solr:http://localhost:8983/solr");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelSolrField.id", "doc123");
+ exchange.getIn().setHeader("CamelSolrField.name", "Test Document");
+ exchange.getIn().setHeader("CamelSolrParam.commit", true);
+ exchange.getIn().setHeader("CamelSolrParam.commitWithin", 1000);
+ })
+ .to("solr:http://localhost:8983/solr");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testGitHub2HeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-github",
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-github2</artifactId>
+ <version>4.18.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """
+ ),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("GitHubIssueTitle", "Bug Report");
+ })
+ .to("github2:pullRequests");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelGitHubIssueTitle", "Bug Report");
+ })
+ .to("github2:pullRequests");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testGoogleCloudHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-google-cloud",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-google-functions", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("GoogleCloudFunctionsOperation", "createFunction");
+ })
+ .to("google-functions:project");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelGoogleCloudFunctionsOperation", "createFunction");
+ })
+ .to("google-functions:project");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testMongoDbGridFsHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-mongodb",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-mongodb-gridfs", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("gridfs.operation", "create");
+ })
+ .to("mongodb-gridfs:mydb");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelGridFsOperation", "create");
+ })
+ .to("mongodb-gridfs:mydb");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testOpenstackHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-openstack",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-openstack", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ // Generic *Id headers not migrated to prevent false positives
+ exchange.getIn().setHeader("domainId", "default");
+ exchange.getIn().setHeader("networkId", "net-123");
+ // Only OpenStack-specific headers with clear context are migrated
+ exchange.getIn().setHeader("FlavorId", "m1.small");
+ exchange.getIn().setHeader("RAM", 2048);
+ exchange.getIn().setHeader("adminStateUp", true);
+ })
+ .to("openstack-nova://host");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ // Generic *Id headers not migrated to prevent false positives
+ exchange.getIn().setHeader("domainId", "default");
+ exchange.getIn().setHeader("networkId", "net-123");
+ // Only OpenStack-specific headers with clear context are migrated
+ exchange.getIn().setHeader("CamelOpenstackNovaFlavorId", "m1.small");
+ exchange.getIn().setHeader("CamelOpenstackNovaRam", 2048);
+ exchange.getIn().setHeader("CamelOpenstackNeutronAdminStateUp", true);
+ })
+ .to("openstack-nova://host");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testWeb3jHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-web3j",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-web3j", CamelTestUtil.CamelVersion.v4_18)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("FROM_ADDRESS", "0x123");
+ exchange.getIn().setHeader("TO_ADDRESS", "0x456");
+ exchange.getIn().setHeader("AT_BLOCK", "latest");
+ })
+ .to("web3j://http://localhost:8545");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelWeb3jFromAddress", "0x123");
+ exchange.getIn().setHeader("CamelWeb3jToAddress", "0x456");
+ exchange.getIn().setHeader("CamelWeb3jAtBlock", "latest");
+ })
+ .to("web3j://http://localhost:8545");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate419Test.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate419Test.java
index b2aae16..a0014ae 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate419Test.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate419Test.java
@@ -25,15 +25,13 @@ import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.TypeValidation;
import static org.openrewrite.maven.Assertions.pomXml;
-import static org.openrewrite.xml.Assertions.xml;
-import static org.openrewrite.yaml.Assertions.yaml;
//class has to stay public, because test is extended in project quarkus-updates
public class CamelUpdate419Test implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
- CamelTestUtil.recipe(spec, CamelTestUtil.CamelVersion.v4_19)
+ CamelTestUtil.recipe(spec, CamelTestUtil.CamelVersion.v4_19, true)
.parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_18,
"camel-core-model", "camel-api", "camel-qdrant", "camel-tahu", "tahu-host"))
.typeValidationOptions(TypeValidation.none());
@@ -110,50 +108,7 @@ public class CamelUpdate419Test implements RewriteTest {
*/
@Test
void sagaEipXml() {
- //language=xml
- rewriteRun(xml(
- """
- <route>
- <from uri="direct:start"/>
- <saga sagaService="mySagaService">
- <compensation uri="mock:compensation"/>
- <completion uri="mock:completion"/>
- <option key="myOptionKey">
- <constant>myOptionValue</constant>
- </option>
- <option key="myOptionKey2">
- <constant>myOptionValue2</constant>
- </option>
- </saga>
- <choice>
- <when>
- <simple>${body} == 'fail'</simple>
- <throwException exceptionType="java.lang.RuntimeException" message="fail"/>
- </when>
- </choice>
- <to uri="mock:end"/>
- </route>
- """,
- """
- <route>
- <from uri="direct:start"/>
- <saga sagaService="mySagaService" compensation="mock:compensation" completion="mock:completion">
- <option key="myOptionKey">
- <constant>myOptionValue</constant>
- </option>
- <option key="myOptionKey2">
- <constant>myOptionValue2</constant>
- </option>
- </saga>
- <choice>
- <when>
- <simple>${body} == 'fail'</simple>
- <throwException exceptionType="java.lang.RuntimeException" message="fail"/>
- </when>
- </choice>
- <to uri="mock:end"/>
- </route>
- """));
+ new CamelUpdate418_1Test().testSagaEipXml();
}
/**
@@ -161,34 +116,7 @@ public class CamelUpdate419Test implements RewriteTest {
*/
@Test
void sagaEipYaml() {
- //language=yaml
- rewriteRun(yaml(
- """
- - route:
- from:
- uri: direct:start
- steps:
- - saga:
- compensation:
- uri: direct:compensate
- completion:
- uri: direct:complete
- steps:
- - to:
- uri: direct:action
- """,
- """
- - route:
- from:
- uri: direct:start
- steps:
- - saga:
- compensation: direct:compensate
- completion: direct:complete
- steps:
- - to:
- uri: direct:action
- """));
+ new CamelUpdate418_1Test().testSagaEipYaml();
}
@@ -263,28 +191,7 @@ public class CamelUpdate419Test implements RewriteTest {
*/
@Test
void yamlDslRoutePolicyRename() {
- //language=yaml
- rewriteRun(yaml(
- """
- - route:
- id: myRoute
- routePolicy: myPolicy
- from:
- uri: direct:start
- steps:
- - to:
- uri: mock:result
- """,
- """
- - route:
- id: myRoute
- routePolicyRef: myPolicy
- from:
- uri: direct:start
- steps:
- - to:
- uri: mock:result
- """));
+ new CamelUpdate418_1Test().testYamlDslRoutePolicyRename();
}
/**
* <a href="https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#_camel_bom">camel-bom</a>
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate421Test.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate421Test.java
new file mode 100644
index 0000000..df5bdf0
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate421Test.java
@@ -0,0 +1,586 @@
+/*
+ * 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.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.java.Assertions.java;
+import static org.openrewrite.java.Assertions.mavenProject;
+import static org.openrewrite.maven.Assertions.pomXml;
+import static org.openrewrite.properties.Assertions.properties;
+
+//class has to stay public, because test is extended in project quarkus-updates
+public class CamelUpdate421Test implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ // Note: We load the full 4.21 recipe here, but each component recipe has
+ // ModuleHasDependency preconditions that ensure only relevant recipes run
+ // based on which dependencies are present in the test's pom.xml
+ CamelTestUtil.recipe(spec, CamelTestUtil.CamelVersion.v4_21, true)
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_20,
+ "camel-core-model", "camel-api", "s3"))
+ .typeValidationOptions(TypeValidation.none())
+ // Explicitly set expected cycles to 1 to prevent other recipes from running
+ .expectedCyclesThatMakeChanges(1);
+ }
+
+ @Test
+ void testJGroupsHeadersMigration() {
+ new CamelUpdate418_3Test().testJGroupsHeadersMigration();
+ }
+
+ @Test
+ void testDnsHeadersMigrationJava() {
+ new CamelUpdate418Test().testDnsHeadersMigrationJava();
+ }
+
+ @Test
+ void testJiraHeadersMigrationJava() {
+ new CamelUpdate418_3Test().testJiraHeadersMigrationJava();
+ }
+
+ @Test
+ void testOpenstackHeadersMigrationJava() {
+ new CamelUpdate418_3Test().testOpenstackHeadersMigrationJava();
+ }
+
+ @Test
+ void testWeb3jHeadersMigrationJava() {
+ new CamelUpdate418_3Test().testWeb3jHeadersMigrationJava();
+ }
+
+ @Test
+ void testCouchdbHeadersMigration() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-couchdb",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-couchdb", CamelTestUtil.CamelVersion.v4_20)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CouchDbDatabase", "mydb");
+ exchange.getIn().setHeader("CouchDbId", "doc1");
+ })
+ .to("couchdb:http://localhost:5984");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelCouchDbDatabase", "mydb");
+ exchange.getIn().setHeader("CamelCouchDbId", "doc1");
+ })
+ .to("couchdb:http://localhost:5984");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testCouchbaseHeadersMigration() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-couchbase",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-couchbase", CamelTestUtil.CamelVersion.v4_20)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CCB_KEY", "key1");
+ exchange.getIn().setHeader("CCB_TTL", 3600);
+ })
+ .to("couchbase:http://localhost");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelCouchbaseKey", "key1");
+ exchange.getIn().setHeader("CamelCouchbaseTtl", 3600);
+ })
+ .to("couchbase:http://localhost");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testJGroupsRaftHeadersMigration() {
+ new CamelUpdate418_3Test().testJGroupsRaftHeadersMigration();
+ }
+
+ @Test
+ void testShiroHeadersMigration() {
+ new CamelUpdate418_3Test().testShiroHeadersMigration();
+ }
+
+ @Test
+ void testSolrHeadersMigration() {
+ new CamelUpdate418_3Test().testSolrHeadersMigration();
+ }
+
+ @Test
+ void testGitHub2HeadersMigrationJava() {
+ new CamelUpdate418_3Test().testGitHub2HeadersMigrationJava();
+ }
+
+ @Test
+ void testGoogleCloudHeadersMigrationJava() {
+ new CamelUpdate418_3Test().testGoogleCloudHeadersMigrationJava();
+ }
+
+ //todo more google - vision, text-to=speech, speech-to-text
+
+ @Test
+ void testMongoDbGridFsHeadersMigrationJava() {
+ new CamelUpdate418_3Test().testMongoDbGridFsHeadersMigrationJava();
+ }
+
+ @Test
+ void testIrcHeadersMigrationJava() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-irc",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-irc", CamelTestUtil.CamelVersion.v4_20)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("irc.sendTo", "#channel");
+ })
+ .to("irc:bot@irc.server.org");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelIrcSendTo", "#channel");
+ })
+ .to("irc:bot@irc.server.org");
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testPreconditionBlocksWithoutDependency() {
+ // Test that the Kafka recipe does NOT run when camel-kafka dependency is absent
+ // This verifies the ModuleHasDependency precondition works correctly
+ // Using camel-core instead of camel-kafka means the precondition will block the recipe
+ //language=java
+ rewriteRun(
+ spec -> spec.expectedCyclesThatMakeChanges(0),
+ mavenProject("test-negative",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-core", CamelTestUtil.CamelVersion.v4_20)),
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("kafka.TOPIC", "topic1");
+ });
+ }
+ }
+ """
+ )
+ ));
+ }
+
+ @Test
+ void testRemoveReifierStrategyImport() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+ import org.apache.camel.spi.ReifierStrategy;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start").to("log:test");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start").to("log:test");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void testRemoveZooWordEmbeddingPredictorImport() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+ import org.apache.camel.component.djl.model.nlp.ZooWordEmbeddingPredictor;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start").to("log:test");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start").to("log:test");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void testLuceneHeadersMigrationJava() {
+ new CamelUpdate418_3Test().testLuceneHeadersMigrationJava();
+ }
+
+ @Test
+ void testRemoveCamelStompDependency() {
+ //language=xml
+ rewriteRun(
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-stomp</artifactId>
+ <version>4.20.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """,
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ </project>
+ """
+ )
+ );
+ }
+
+ @Test
+ void testRemoveCamelAwsXrayDependency() {
+ //language=xml
+ rewriteRun(
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-aws-xray</artifactId>
+ <version>4.20.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """,
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ </project>
+ """
+ )
+ );
+ }
+
+ @Test
+ void testRemoveCamelGuavaEventbusDependency() {
+ //language=xml
+ rewriteRun(
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-guava-eventbus</artifactId>
+ <version>4.20.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """,
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ </project>
+ """
+ )
+ );
+ }
+
+ @Test
+ void testRemoveCamelGrapeDependency() {
+ //language=xml
+ rewriteRun(
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-grape</artifactId>
+ <version>4.20.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """,
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ </project>
+ """
+ )
+ );
+ }
+
+ @Test
+ void testRemoveCamelElytronDependency() {
+ //language=xml
+ rewriteRun(
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-elytron</artifactId>
+ <version>4.20.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """,
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ </project>
+ """
+ )
+ );
+ }
+
+ @Test
+ void testMigrateAws2S3ListObjectsApi() {
+ //language=java
+ rewriteRun(
+ mavenProject("test-aws2-s3",
+ pomXml(CamelTestUtil.pomXmlWithDependency("camel-aws2-s3", CamelTestUtil.CamelVersion.v4_20)),
+ java(
+ """
+ import software.amazon.awssdk.services.s3.model.ListObjectsRequest;
+ import software.amazon.awssdk.services.s3.model.ListObjectsResponse;
+
+ public class S3Example {
+ public void example() {
+ ListObjectsRequest request = ListObjectsRequest.builder().build();
+ ListObjectsResponse response = null;
+ }
+ }
+ """,
+ """
+ import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
+ import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
+
+ public class S3Example {
+ public void example() {
+ ListObjectsV2Request request = ListObjectsV2Request.builder().build();
+ ListObjectsV2Response response = null;
+ }
+ }
+ """
+ )
+ )
+ );
+ }
+
+ @Test
+ void testRemoveCamelGithubDependency() {
+ //language=xml
+ rewriteRun(
+ pomXml(
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-github</artifactId>
+ <version>4.20.0</version>
+ </dependency>
+ </dependencies>
+ </project>
+ """,
+ """
+ <project>
+ <groupId>com.example</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <properties>
+ <maven.compiler.release>17</maven.compiler.release>
+ </properties>
+ </project>
+ """
+ )
+ );
+ }
+
+ @Test
+ void testErrorRegistryPropertiesFile() {
+ //language=properties
+ rewriteRun(
+ properties(
+ """
+ camel.main.errorRegistryEnabled=true
+ camel.main.errorRegistryMaximumEntries=100
+ camel.main.errorRegistryTimeToLiveSeconds=300
+ camel.main.errorRegistryStackTraceEnabled=false
+ """,
+ """
+ camel.errorRegistry.enabled=true
+ camel.errorRegistry.maximumEntries=100
+ camel.errorRegistry.timeToLiveSeconds=300
+ """,
+ spec -> spec.path("application.properties")
+ )
+ );
+ }
+
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInJavaMethodTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInJavaMethodTest.java
new file mode 100644
index 0000000..b92a04c
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInJavaMethodTest.java
@@ -0,0 +1,254 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.CamelTestUtil;
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.java.Assertions.java;
+
+public class RenameHeaderInJavaMethodTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderInJavaMethod("kafka.TOPIC", "CamelKafkaTopic"))
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_20,
+ "camel-core-model", "camel-api"))
+ .typeValidationOptions(TypeValidation.none());
+ }
+
+ @DocumentExample
+ @Test
+ void setHeaderMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("kafka.TOPIC", "my-topic");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("CamelKafkaTopic", "my-topic");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void getHeaderWithClassMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String topic = exchange.getIn().getHeader("kafka.TOPIC", String.class);
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String topic = exchange.getIn().getHeader("CamelKafkaTopic", String.class);
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void getHeaderNoClassMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ Object topic = exchange.getIn().getHeader("kafka.TOPIC");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ Object topic = exchange.getIn().getHeader("CamelKafkaTopic");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void getHeaderWithDefaultMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String topic = exchange.getIn().getHeader("kafka.TOPIC", "default", String.class);
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String topic = exchange.getIn().getHeader("CamelKafkaTopic", "default", String.class);
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleHeadersMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("kafka.TOPIC", "my-topic");
+ String topic = exchange.getIn().getHeader("kafka.TOPIC");
+ exchange.getIn().setHeader("other.header", "value");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("CamelKafkaTopic", "my-topic");
+ String topic = exchange.getIn().getHeader("CamelKafkaTopic");
+ exchange.getIn().setHeader("other.header", "value");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateArbitraryStrings() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void someMethod(Exchange exchange) {
+ String headerName = "kafka.TOPIC"; // Should NOT be changed
+ System.out.println("Setting header: kafka.TOPIC"); // Should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDynamicAccess() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void someMethod(Exchange exchange, String headerName) {
+ exchange.getIn().getHeader(headerName); // Should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateMapGet() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void someMethod(Exchange exchange) {
+ Object topic = exchange.getIn().getHeaders().get("kafka.TOPIC"); // Should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentHeaderName() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("kafka.PARTITION", "0"); // Different header, should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInSimpleExpressionTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInSimpleExpressionTest.java
new file mode 100644
index 0000000..4635472
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInSimpleExpressionTest.java
@@ -0,0 +1,245 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.CamelTestUtil;
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.java.Assertions.java;
+
+public class RenameHeaderInSimpleExpressionTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderInSimpleExpression("kafka.TOPIC", "CamelKafkaTopic"))
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_20,
+ "camel-core-model", "camel-api"))
+ .typeValidationOptions(TypeValidation.none());
+ }
+
+ @DocumentExample
+ @Test
+ void simpleExpressionHeaderMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.kafka.TOPIC}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.CamelKafkaTopic}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void simpleExpressionHeadersVariantMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${headers.kafka.TOPIC}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${headers.CamelKafkaTopic}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void simpleExpressionInSetHeader() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setHeader("myHeader", simple("${header.kafka.TOPIC}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setHeader("myHeader", simple("${header.CamelKafkaTopic}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void simpleExpressionWithOtherText() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("Topic: ${header.kafka.TOPIC}, Partition: ${header.kafka.PARTITION}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("Topic: ${header.CamelKafkaTopic}, Partition: ${header.kafka.PARTITION}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleSimpleExpressions() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.kafka.TOPIC}"))
+ .setHeader("copy", simple("${headers.kafka.TOPIC}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.CamelKafkaTopic}"))
+ .setHeader("copy", simple("${headers.CamelKafkaTopic}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateNonSimpleStrings() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ String expression = "${header.kafka.TOPIC}"; // Not inside simple() call
+ System.out.println("Expression: ${header.kafka.TOPIC}");
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentHeader() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.kafka.PARTITION}")); // Different header
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigratePartialMatch() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.kafka.TOPIC.name}")); // Has extra suffix
+ }
+ }
+ """
+ // No change expected - doesn't match exact pattern
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInXmlDslTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInXmlDslTest.java
new file mode 100644
index 0000000..322592e
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInXmlDslTest.java
@@ -0,0 +1,204 @@
+/*
+ * 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.camel421;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.xml.Assertions.xml;
+
+public class RenameHeaderInXmlDslTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderInXmlDsl("kafka.TOPIC", "CamelKafkaTopic"));
+ }
+
+ @DocumentExample
+ @Test
+ void setHeaderMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="kafka.TOPIC">
+ <constant>my-topic</constant>
+ </setHeader>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelKafkaTopic">
+ <constant>my-topic</constant>
+ </setHeader>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void headerElementMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <choice>
+ <when>
+ <header name="kafka.TOPIC"/>
+ <to uri="mock:found"/>
+ </when>
+ </choice>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <choice>
+ <when>
+ <header name="CamelKafkaTopic"/>
+ <to uri="mock:found"/>
+ </when>
+ </choice>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void removeHeaderMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <removeHeader name="kafka.TOPIC"/>
+ <to uri="mock:result"/>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <removeHeader name="CamelKafkaTopic"/>
+ <to uri="mock:result"/>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleHeadersMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="kafka.TOPIC">
+ <constant>topic1</constant>
+ </setHeader>
+ <setHeader name="other.header">
+ <constant>value</constant>
+ </setHeader>
+ <removeHeader name="kafka.TOPIC"/>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelKafkaTopic">
+ <constant>topic1</constant>
+ </setHeader>
+ <setHeader name="other.header">
+ <constant>value</constant>
+ </setHeader>
+ <removeHeader name="CamelKafkaTopic"/>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void setHeaderWithSimpleExpression() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="kafka.TOPIC">
+ <simple>${header.myHeader}</simple>
+ </setHeader>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelKafkaTopic">
+ <simple>${header.myHeader}</simple>
+ </setHeader>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentHeader() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="kafka.PARTITION">
+ <constant>0</constant>
+ </setHeader>
+ </route>
+ """
+ // No change expected - different header name
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateOtherAttributes() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <to uri="kafka:kafka.TOPIC"/>
+ </route>
+ """
+ // No change expected - "kafka.TOPIC" is not a header name attribute
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInYamlDslTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInYamlDslTest.java
new file mode 100644
index 0000000..a9fd6db
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderInYamlDslTest.java
@@ -0,0 +1,235 @@
+/*
+ * 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.camel421;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.yaml.Assertions.yaml;
+
+public class RenameHeaderInYamlDslTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderInYamlDsl("kafka.TOPIC", "CamelKafkaTopic"));
+ }
+
+ @DocumentExample
+ @Test
+ void setHeaderMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: kafka.TOPIC
+ constant: my-topic
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelKafkaTopic
+ constant: my-topic
+ """
+ )
+ );
+ }
+
+ @Test
+ void headerPredicateMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - choice:
+ when:
+ - header:
+ name: kafka.TOPIC
+ steps:
+ - to: "mock:found"
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - choice:
+ when:
+ - header:
+ name: CamelKafkaTopic
+ steps:
+ - to: "mock:found"
+ """
+ )
+ );
+ }
+
+ @Test
+ void removeHeaderMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - removeHeader:
+ name: kafka.TOPIC
+ - to: "mock:result"
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - removeHeader:
+ name: CamelKafkaTopic
+ - to: "mock:result"
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleHeadersMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: kafka.TOPIC
+ constant: topic1
+ - setHeader:
+ name: other.header
+ constant: value
+ - removeHeader:
+ name: kafka.TOPIC
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelKafkaTopic
+ constant: topic1
+ - setHeader:
+ name: other.header
+ constant: value
+ - removeHeader:
+ name: CamelKafkaTopic
+ """
+ )
+ );
+ }
+
+ @Test
+ void setHeaderWithSimpleExpression() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: kafka.TOPIC
+ simple: "${header.myHeader}"
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelKafkaTopic
+ simple: "${header.myHeader}"
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentHeader() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: kafka.PARTITION
+ constant: 0
+ """
+ // No change expected - different header name
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateNonHeaderName() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "kafka:kafka.TOPIC"
+ steps:
+ - to: "mock:result"
+ """
+ // No change expected - "kafka.TOPIC" is URI, not a header name
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateNonCamelYaml() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ app:
+ headers:
+ kafka.TOPIC: my-topic
+ """
+ // No change expected - not Camel YAML DSL
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInJavaMethodTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInJavaMethodTest.java
new file mode 100644
index 0000000..14befa2
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInJavaMethodTest.java
@@ -0,0 +1,291 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.CamelTestUtil;
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.java.Assertions.java;
+
+public class RenameHeaderPrefixInJavaMethodTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderPrefixInJavaMethod("SolrField.", "CamelSolrField."))
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_20,
+ "camel-core-model", "camel-api"))
+ .typeValidationOptions(TypeValidation.none());
+ }
+
+ @DocumentExample
+ @Test
+ void setHeaderPrefixMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("SolrField.id", "doc123");
+ exchange.getIn().setHeader("SolrField.name", "Test Document");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("CamelSolrField.id", "doc123");
+ exchange.getIn().setHeader("CamelSolrField.name", "Test Document");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void getHeaderWithClassPrefixMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String id = exchange.getIn().getHeader("SolrField.id", String.class);
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String id = exchange.getIn().getHeader("CamelSolrField.id", String.class);
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void getHeaderNoClassPrefixMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ Object id = exchange.getIn().getHeader("SolrField.id");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ Object id = exchange.getIn().getHeader("CamelSolrField.id");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void getHeaderWithDefaultPrefixMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String id = exchange.getIn().getHeader("SolrField.id", "default", String.class);
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ String id = exchange.getIn().getHeader("CamelSolrField.id", "default", String.class);
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleHeadersPrefixMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("SolrField.id", "doc123");
+ String id = exchange.getIn().getHeader("SolrField.id");
+ exchange.getIn().setHeader("SolrField.title", "My Document");
+ exchange.getIn().setHeader("other.header", "value");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("CamelSolrField.id", "doc123");
+ String id = exchange.getIn().getHeader("CamelSolrField.id");
+ exchange.getIn().setHeader("CamelSolrField.title", "My Document");
+ exchange.getIn().setHeader("other.header", "value");
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentPrefix() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("SolrParam.commit", true); // Different prefix, should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateArbitraryStrings() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void someMethod(Exchange exchange) {
+ String headerName = "SolrField.id"; // Should NOT be changed
+ System.out.println("Setting header: SolrField.id"); // Should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDynamicAccess() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void someMethod(Exchange exchange, String headerName) {
+ exchange.getIn().getHeader(headerName); // Should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateMapGet() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void someMethod(Exchange exchange) {
+ Object id = exchange.getIn().getHeaders().get("SolrField.id"); // Should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void migratesVariousFieldNames() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("SolrField.id", "123");
+ exchange.getIn().setHeader("SolrField.name", "Test");
+ exchange.getIn().setHeader("SolrField.description", "Desc");
+ exchange.getIn().setHeader("SolrField.custom_field_123", "Custom");
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+
+ class Test {
+ void configure(Exchange exchange) {
+ exchange.getIn().setHeader("CamelSolrField.id", "123");
+ exchange.getIn().setHeader("CamelSolrField.name", "Test");
+ exchange.getIn().setHeader("CamelSolrField.description", "Desc");
+ exchange.getIn().setHeader("CamelSolrField.custom_field_123", "Custom");
+ }
+ }
+ """
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInSimpleExpressionTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInSimpleExpressionTest.java
new file mode 100644
index 0000000..a4cb3f6
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInSimpleExpressionTest.java
@@ -0,0 +1,249 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.CamelTestUtil;
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.java.Assertions.java;
+
+public class RenameHeaderPrefixInSimpleExpressionTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderPrefixInSimpleExpression("SolrField.", "CamelSolrField."))
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_20,
+ "camel-core-model", "camel-api"))
+ .typeValidationOptions(TypeValidation.none());
+ }
+
+ @DocumentExample
+ @Test
+ void simpleExpressionHeaderPrefixMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.SolrField.id}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.CamelSolrField.id}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void simpleExpressionHeadersVariantPrefixMigration() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${headers.SolrField.id}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${headers.CamelSolrField.id}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void simpleExpressionInSetHeader() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setHeader("result", simple("Value: ${header.SolrField.name}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setHeader("result", simple("Value: ${header.CamelSolrField.name}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleHeaderReferencesInOneExpression() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("ID: ${header.SolrField.id}, Name: ${header.SolrField.name}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("ID: ${header.CamelSolrField.id}, Name: ${header.CamelSolrField.name}"));
+ }
+ }
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentPrefix() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody(simple("${header.SolrParam.commit}")); // Different prefix, should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateArbitraryStrings() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .log("Header: SolrField.id"); // Should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateOutsideSimpleMethod() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setBody("${header.SolrField.id}"); // Not inside simple() call, should NOT be changed
+ }
+ }
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void migratesVariousFieldNames() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setHeader("h1", simple("${header.SolrField.id}"))
+ .setHeader("h2", simple("${header.SolrField.name}"))
+ .setHeader("h3", simple("${header.SolrField.description}"))
+ .setHeader("h4", simple("${header.SolrField.custom_field_123}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .setHeader("h1", simple("${header.CamelSolrField.id}"))
+ .setHeader("h2", simple("${header.CamelSolrField.name}"))
+ .setHeader("h3", simple("${header.CamelSolrField.description}"))
+ .setHeader("h4", simple("${header.CamelSolrField.custom_field_123}"));
+ }
+ }
+ """
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInXmlDslTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInXmlDslTest.java
new file mode 100644
index 0000000..95910e7
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInXmlDslTest.java
@@ -0,0 +1,206 @@
+/*
+ * 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.camel421;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.xml.Assertions.xml;
+
+public class RenameHeaderPrefixInXmlDslTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderPrefixInXmlDsl("SolrField.", "CamelSolrField."));
+ }
+
+ @DocumentExample
+ @Test
+ void setHeaderPrefixMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="SolrField.id">
+ <constant>doc123</constant>
+ </setHeader>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelSolrField.id">
+ <constant>doc123</constant>
+ </setHeader>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void headerElementPrefixMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <choice>
+ <when>
+ <header name="SolrField.id"/>
+ <to uri="mock:found"/>
+ </when>
+ </choice>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <choice>
+ <when>
+ <header name="CamelSolrField.id"/>
+ <to uri="mock:found"/>
+ </when>
+ </choice>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void removeHeaderPrefixMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <removeHeader name="SolrField.id"/>
+ <to uri="mock:result"/>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <removeHeader name="CamelSolrField.id"/>
+ <to uri="mock:result"/>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleHeadersPrefixMigration() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="SolrField.id">
+ <constant>123</constant>
+ </setHeader>
+ <setHeader name="SolrField.name">
+ <constant>Test</constant>
+ </setHeader>
+ <to uri="mock:result"/>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelSolrField.id">
+ <constant>123</constant>
+ </setHeader>
+ <setHeader name="CamelSolrField.name">
+ <constant>Test</constant>
+ </setHeader>
+ <to uri="mock:result"/>
+ </route>
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentPrefix() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="SolrParam.commit">
+ <constant>true</constant>
+ </setHeader>
+ </route>
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateArbitraryAttributes() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <to uri="solr://localhost?field=SolrField.id"/>
+ </route>
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void migratesVariousFieldNames() {
+ //language=xml
+ rewriteRun(
+ xml(
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="SolrField.id"><constant>1</constant></setHeader>
+ <setHeader name="SolrField.name"><constant>Test</constant></setHeader>
+ <setHeader name="SolrField.description"><constant>Desc</constant></setHeader>
+ <setHeader name="SolrField.custom_field_123"><constant>Custom</constant></setHeader>
+ </route>
+ """,
+ """
+ <route xmlns="http://camel.apache.org/schema/spring">
+ <from uri="direct:start"/>
+ <setHeader name="CamelSolrField.id"><constant>1</constant></setHeader>
+ <setHeader name="CamelSolrField.name"><constant>Test</constant></setHeader>
+ <setHeader name="CamelSolrField.description"><constant>Desc</constant></setHeader>
+ <setHeader name="CamelSolrField.custom_field_123"><constant>Custom</constant></setHeader>
+ </route>
+ """
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInYamlDslTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInYamlDslTest.java
new file mode 100644
index 0000000..454ef01
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeaderPrefixInYamlDslTest.java
@@ -0,0 +1,233 @@
+/*
+ * 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.camel421;
+
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.yaml.Assertions.yaml;
+
+public class RenameHeaderPrefixInYamlDslTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaderPrefixInYamlDsl("SolrField.", "CamelSolrField."));
+ }
+
+ @DocumentExample
+ @Test
+ void setHeaderPrefixMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: SolrField.id
+ constant: doc123
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelSolrField.id
+ constant: doc123
+ """
+ )
+ );
+ }
+
+ @Test
+ void headerPredicatePrefixMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - choice:
+ when:
+ - header:
+ name: SolrField.id
+ steps:
+ - to: "mock:found"
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - choice:
+ when:
+ - header:
+ name: CamelSolrField.id
+ steps:
+ - to: "mock:found"
+ """
+ )
+ );
+ }
+
+ @Test
+ void removeHeaderPrefixMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - removeHeader:
+ name: SolrField.id
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - removeHeader:
+ name: CamelSolrField.id
+ """
+ )
+ );
+ }
+
+ @Test
+ void multipleHeadersPrefixMigration() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: SolrField.id
+ constant: "123"
+ - setHeader:
+ name: SolrField.name
+ constant: "Test"
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelSolrField.id
+ constant: "123"
+ - setHeader:
+ name: CamelSolrField.name
+ constant: "Test"
+ """
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateDifferentPrefix() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: SolrParam.commit
+ constant: true
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void doesNotMigrateArbitraryYaml() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - log:
+ message: "Header: SolrField.id"
+ """
+ // No change expected
+ )
+ );
+ }
+
+ @Test
+ void migratesVariousFieldNames() {
+ //language=yaml
+ rewriteRun(
+ yaml(
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: SolrField.id
+ constant: "1"
+ - setHeader:
+ name: SolrField.name
+ constant: "Test"
+ - setHeader:
+ name: SolrField.description
+ constant: "Desc"
+ - setHeader:
+ name: SolrField.custom_field_123
+ constant: "Custom"
+ """,
+ """
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - setHeader:
+ name: CamelSolrField.id
+ constant: "1"
+ - setHeader:
+ name: CamelSolrField.name
+ constant: "Test"
+ - setHeader:
+ name: CamelSolrField.description
+ constant: "Desc"
+ - setHeader:
+ name: CamelSolrField.custom_field_123
+ constant: "Custom"
+ """
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeadersTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeadersTest.java
new file mode 100644
index 0000000..65e7851
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel421/RenameHeadersTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.camel421;
+
+import org.apache.camel.upgrade.CamelTestUtil;
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import java.util.Map;
+
+import static org.openrewrite.java.Assertions.java;
+
+/**
+ * Tests for the bulk RenameHeaders recipe that renames multiple headers at once using a map.
+ */
+public class RenameHeadersTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec.recipe(new RenameHeaders(Map.of(
+ "kafka.TOPIC", "CamelKafkaTopic",
+ "kafka.PARTITION", "CamelKafkaPartition",
+ "kafka.KEY", "CamelKafkaKey"
+ )))
+ .parser(CamelTestUtil.parserFromClasspath(CamelTestUtil.CamelVersion.v4_20,
+ "camel-core-model", "camel-api"))
+ .typeValidationOptions(TypeValidation.none());
+ }
+
+ @DocumentExample
+ @Test
+ void bulkHeaderRename() {
+ // Demonstrates that a single RenameHeaders recipe with a map can rename multiple headers
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("kafka.TOPIC", "topic1");
+ exchange.getIn().setHeader("kafka.PARTITION", "0");
+ exchange.getIn().setHeader("kafka.KEY", "key1");
+ })
+ .setBody(simple("Topic: ${header.kafka.TOPIC}, Partition: ${header.kafka.PARTITION}"));
+ }
+ }
+ """,
+ """
+ import org.apache.camel.Exchange;
+ import org.apache.camel.builder.RouteBuilder;
+
+ class Test extends RouteBuilder {
+ public void configure() {
+ from("direct:start")
+ .process(exchange -> {
+ exchange.getIn().setHeader("CamelKafkaTopic", "topic1");
+ exchange.getIn().setHeader("CamelKafkaPartition", "0");
+ exchange.getIn().setHeader("CamelKafkaKey", "key1");
+ })
+ .setBody(simple("Topic: ${header.CamelKafkaTopic}, Partition: ${header.CamelKafkaPartition}"));
+ }
+ }
+ """
+ )
+ );
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/suites/CamelUpdate410LtsTestSuite.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/suites/CamelUpdate410LtsTestSuite.java
index aa2bbc8..bce1d83 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/suites/CamelUpdate410LtsTestSuite.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/suites/CamelUpdate410LtsTestSuite.java
@@ -5,7 +5,11 @@ import org.junit.platform.suite.api.*;
@SelectClasses({CamelUpdate45Test.class, CamelUpdate46Test.class, CamelUpdate47Test.class, CamelUpdate49Test.class, CamelUpdate410Test.class})
@SelectMethod("org.apache.camel.upgrade.CamelUpdate412Test#javaDslChoice") //test for 4.10.3 to 4.10.4 java dsl - https://camel.apache.org/manual/camel-4x-upgrade-guide-4_10.html#_java_dsl
-@SelectPackages({"org.apache.camel.upgrade.camel40", "org.apache.camel.upgrade.camel44", "org.apache.camel.upgrade.camel410lts"})
+@SelectPackages({
+ "org.apache.camel.upgrade.versions",
+ "org.apache.camel.upgrade.camel40",
+ "org.apache.camel.upgrade.camel44"
+})
@Suite
@SuiteDisplayName("4.10LTS")
public class CamelUpdate410LtsTestSuite {
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/suites/CamelUpdate418LtsTestSuite.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/suites/CamelUpdate418LtsTestSuite.java
new file mode 100644
index 0000000..12a1e8b
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/suites/CamelUpdate418LtsTestSuite.java
@@ -0,0 +1,59 @@
+/*
+ * 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.suites;
+
+import org.apache.camel.upgrade.*;
+import org.junit.platform.suite.api.*;
+
+/**
+ * Test suite for Camel 4.18.3 LTS migration.
+ * Includes all tests from 4.0 to 4.18.3, covering the complete upgrade path.
+ */
+@SelectClasses({
+ CamelUpdate45Test.class,
+ CamelUpdate46Test.class,
+ CamelUpdate47Test.class,
+ CamelUpdate49Test.class,
+ CamelUpdate410Test.class,
+ CamelUpdate411Test.class,
+ CamelUpdate412Test.class,
+ CamelUpdate413Test.class,
+ CamelUpdate414Test.class,
+ CamelUpdate415Test.class,
+ CamelUpdate417Test.class,
+ CamelUpdate418Test.class,
+ CamelUpdate418_1Test.class,
+ CamelUpdate418_3Test.class
+})
+@SelectPackages({"org.apache.camel.upgrade.versions",
+ "org.apache.camel.upgrade.camel40",
+ "org.apache.camel.upgrade.camel44"
+})
+@Suite
+@SuiteDisplayName("4.18LTS")
+public class CamelUpdate418LtsTestSuite {
+
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.setProperty(CamelTestUtil.PROPERTY_USE_RECIPE, "org.apache.camel.upgrade.Camel418LTSMigrationRecipe");
+ }
+
+ @AfterSuite
+ public static void afterSuite() {
+ System.clearProperty(CamelTestUtil.PROPERTY_USE_RECIPE);
+ }
+}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel410lts/CamelUpdate410LtsVersionTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdate410LtsVersionTest.java
similarity index 96%
rename from camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel410lts/CamelUpdate410LtsVersionTest.java
rename to camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdate410LtsVersionTest.java
index 17e3995..1e996b6 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel410lts/CamelUpdate410LtsVersionTest.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdate410LtsVersionTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.upgrade.camel410lts;
+package org.apache.camel.upgrade.versions;
import org.apache.camel.upgrade.AbstractCamelUpdateVersionTest;
import org.apache.camel.upgrade.CamelTestUtil;
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/latest/CamelUpdateLatestVersionTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdate418LtsVersionTest.java
similarity index 81%
copy from camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/latest/CamelUpdateLatestVersionTest.java
copy to camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdate418LtsVersionTest.java
index f81a30e..0e06c3c 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/latest/CamelUpdateLatestVersionTest.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdate418LtsVersionTest.java
@@ -14,21 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.upgrade.latest;
+package org.apache.camel.upgrade.versions;
import org.apache.camel.upgrade.AbstractCamelUpdateVersionTest;
import org.apache.camel.upgrade.CamelTestUtil;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-@Disabled //todo investigate properly why is failing on CI
-@EnabledIfSystemProperty(named = CamelTestUtil.PROPERTY_USE_RECIPE, matches = "org.apache.camel.upgrade.CamelMigrationRecipe")
//class has to stay public, because test is extended in project quarkus-updates
-public class CamelUpdateLatestVersionTest extends AbstractCamelUpdateVersionTest {
+@Disabled //until 4.18.3 is released
+@EnabledIfSystemProperty(named = CamelTestUtil.PROPERTY_USE_RECIPE, matches = "org.apache.camel.upgrade.Camel418LTSMigrationRecipe")
+public class CamelUpdate418LtsVersionTest extends AbstractCamelUpdateVersionTest {
+
@Override
protected String targetVersion() {
- return CamelTestUtil.getCamelLatestVersion();
+ return CamelTestUtil.getCamel418LtsVersion();
}
-
}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/latest/CamelUpdateLatestVersionTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdateLatestVersionTest.java
similarity index 97%
rename from camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/latest/CamelUpdateLatestVersionTest.java
rename to camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdateLatestVersionTest.java
index f81a30e..2009a2b 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/latest/CamelUpdateLatestVersionTest.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/versions/CamelUpdateLatestVersionTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.upgrade.latest;
+package org.apache.camel.upgrade.versions;
import org.apache.camel.upgrade.AbstractCamelUpdateVersionTest;
import org.apache.camel.upgrade.CamelTestUtil;
diff --git a/pom.xml b/pom.xml
index ec24d44..53a4699 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,9 +106,10 @@
<camel4.18-version>4.18.0</camel4.18-version>
<camel4.10-lts-version>4.10.6</camel4.10-lts-version>
+ <camel4.18-lts-version>4.18.3</camel4.18-lts-version>
<!-- versions for latest recipes, has to be kept aligned to the latest camel release -->
- <camel-latest-version>4.20.0</camel-latest-version>
+ <camel-latest-version>4.21.0</camel-latest-version>
<camel-version>${project.version}</camel-version>
<camel-spring-boot-version>${project.version}</camel-spring-boot-version>
diff --git a/release_notes.adoc b/release_notes.adoc
index 115eca4..5148b1c 100644
--- a/release_notes.adoc
+++ b/release_notes.adoc
@@ -1,5 +1,94 @@
= Camel Upgrade Recipes - Release notes
+== 4.21.0
+
+=== Summary
+
+This is a release supporting Camel, Camel Quarkus and Camel Spring Boot 4.21.0 with the required upgrade recipes (described by the https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html[migration guide]).
+
+=== Safety Features
+
+All header rename recipes now include dependency-based preconditions using `ModuleHasDependency`. This ensures headers are only renamed when the corresponding Camel component is actually present in the project, preventing false positives and accidental renaming of unrelated headers.
+
+=== Migration coverage
+
+The following table lists migration topics and indicates the level of coverage (full, partial, or not covered), along with additional comments.
+
+[%autowidth,stripes=hover]
+|===
+| Migration | Coverage | Comment
+
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-grok-potential-breaking-change[camel-grok Library Migration] | ❌ None | If `io.krakens:java-grok` is used outside the component, the code could not be migrated. If is used only via component, migration is not needed.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-core[camel-api Null Safety Annotations] | ❌ None | Optional dependency, no migration required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-core[DefaultHeaderFilterStrategy Lowercase Default] | ❌ None | Configuration default change, manual review required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#error-registry[Error Registry SPI Changes] | ⚠️ Partial | Property key migration automated for `.properties` files (`camel.main.errorRegistryXxx` → `camel.errorRegistry.*`). Type changes (`ErrorRegistryEntry` → `BacklogErrorEventMessage`) require manual migration. YAML files require manual migration.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#virtual-threads[Virtual Threads maxQueueSize Honored] | ❌ None | Runtime behavior change
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#new-block-rejected-policy[New Block Rejected Policy] | ❌ None | New feature
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#java-serialization[Java Serialization Type Converters Removed] | ❌ None | Removal without replacement
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#reifierstrategy[ReifierStrategy SPI Removed] | ✅ Full | Import removal automated for `org.apache.camel.spi.ReifierStrategy`
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#namednode-getchildren-method[NamedNode.getChildren() Method] | ❌ None | New method (additive)
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#namednode-level[NamedNode Level Calculation Changed] | ❌ None | Runtime behavior change
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-jbang[camel-jbang] | ❌ None | CLI runtime behavior
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-yaml-dsl[camel-yaml-dsl Canonical JSON Schema] | ❌ None | New schema variant, no migration needed
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-kafka-spring-boot[camel-kafka Spring Boot Property Bridging] | ❌ None | Spring Boot enhancement
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#default-deserialization-filter-tightened[Default Deserialization Filter Tightened] | ❌ None | Runtime security enhancement
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-jms[camel-jms ObjectMessage Disabled by Default] | ❌ None | Security change, manual configuration required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-sjms-camel-sjms2[camel-sjms/sjms2 ObjectMessage Disabled] | ❌ None | Security change, manual configuration required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-hazelcast[camel-hazelcast Default Serialization Filter] | ❌ None | Runtime security enhancement
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-stomp-removal[camel-stomp Removed] | ✅ Full | Automated removal of `org.apache.camel:camel-stomp` dependency
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-aws-xray-removal[camel-aws-xray Removed] | ✅ Full | Automated removal of `org.apache.camel:camel-aws-xray` dependency
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-guava-eventbus-removal[camel-guava-eventbus Removed] | ✅ Full | Automated removal of `org.apache.camel:camel-guava-eventbus` dependency
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-grape-removal[camel-grape Removed] | ✅ Full | Automated removal of `org.apache.camel:camel-grape` dependency
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-elytron-removal[camel-elytron Removed] | ✅ Full | Automated removal of `org.apache.camel:camel-elytron` dependency
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-github-removal[camel-github Removed] | ✅ Full | Automated removal of `org.apache.camel:camel-github` dependency. Migration to `camel-github2` was automated in 4.18.3 (see 4.18.3 section below).
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-telemetry[camel-telemetry Processor Span Changes] | ❌ None | Interface signature changed
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-opentelemetry2[camel-opentelemetry2 Scope Management] | ❌ None | Internal implementation change
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-djl[camel-djl Word Embedding Removed] | ✅ Full | Import removal automated for `ZooWordEmbeddingPredictor`
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-aws-bedrock[camel-aws-bedrock Guardrail Header] | ❌ None | New optional feature
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-jgroups-potential-breaking-change[camel-jgroups Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-elasticsearch-rest-client[camel-elasticsearch-rest-client Headers] | ❌ None | Header values are too common, automatic upgrade is complicated.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-dns-potential-breaking-change[camel-dns Headers] | ⚠️ Partial | Only basic header usage is migrated, including `term` → `CamelDnsTerm`. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-solr[camel-solr Header Prefixes] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-aws2-s3[camel-aws2-s3 ListObjects API] | ✅ Full | Automated type migration: `ListObjectsRequest` → `ListObjectsV2Request`, `ListObjectsResponse` → `ListObjectsV2Response` (applies only when using `pojoRequest=true`)
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-nats[camel-nats Pull Subscription Fixed] | ❌ None | Behavior fix with new options
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-xmpp[camel-xmpp HeaderFilterStrategy] | ❌ None | New filtering behavior
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-couchdb[camel-couchdb Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-couchbase[camel-couchbase Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-jgroups-raft[camel-jgroups-raft Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-jira-potential-breaking-change[camel-jira Headers] | ⚠️ Partial | Only basic header usage is migrated, including `linkType` → `CamelJiraLinkType` and `minutesSpent` → `CamelJiraMinutesSpent`. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-vertx-websocket[camel-vertx-websocket HeaderFilterStrategy] | ❌ None | New filtering behavior
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-atmosphere-websocket[camel-atmosphere-websocket Header Filtering] | ❌ None | Filtering behavior change
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-iggy[camel-iggy HeaderFilterStrategy] | ❌ None | New filtering behavior
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-shiro-potential-breaking-change[camel-shiro Security Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-github2-potential-breaking-change[camel-github2 Producer Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-google-functions-camel-google-secret-manager-camel-google-vision-camel-google-text-to-speech-camel-google-speech-to-text-potential-breaking-change[camel-google-cloud Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-kafka-potential-breaking-change[camel-kafka Headers (HIGH IMPACT)] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review. Includes precondition to only migrate when camel-kafka is present.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#jackson-dataformat-documentation-pages-renamed[Jackson Dataformat Documentation] | ❌ None | Documentation change only
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-platform-http-main[camel-platform-http-main JWT Validation] | ❌ None | New optional feature
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-test[camel-test Port Extension] | ❌ None | Behavior change
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-mongodb-gridfs[camel-mongodb-gridfs Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-lucene[camel-lucene Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods (`qUERY()` → `luceneQuery()`) require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-pdf-potential-breaking-change[camel-pdf Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-arangodb-potential-breaking-change[camel-arangodb Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods (`key()` → `arangoDbKey()`) require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-jt400-potential-breaking-change[camel-jt400 Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods (`kEY()` → `jt400Key()`) require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-mail-2[camel-mail Consumer Dispatch Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-milo-potential-breaking-change[camel-milo Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods (`await()` → `miloAwait()`) require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-elasticsearch-camel-opensearch-potential-breaking-change[camel-elasticsearch/opensearch Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods (`operation()` → `elasticsearchOperation()`) require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-openstack-potential-breaking-change[camel-openstack Headers] | ⚠️ Partial | Only OpenStack-specific header names automated (e.g., `FlavorId`, `KeypairName`, `volumeType`). Generic headers (`operation`, `ID`, `name`, `description`, `properties`, etc.) excluded to prevent false positives - require manual migration with code review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-web3j-potential-breaking-change[camel-web3j Headers] | ⚠️ Partial | Only Web3j-specific header names automated (e.g., `AT_BLOCK`, `TRANSACTION_HASH`, `GAS_PRICE`). Generic headers (`ID`, `OPERATION`, `INDEX`, `VALUE`, `DATA`, `status`, `operation`) excluded to prevent false positives - require manual migration with code review. DSL accessor changes still require manual migration.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-cxf-potential-breaking-change[camel-cxf/cxfrs Headers] | ⚠️ Partial | Basic header string literal renames are now automated for `.setHeader()` and Simple expressions, including SimpleConsumer-style `${header.operationName}` migration. Cross-transport propagation and broader semantic review still require manual migration.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-jooq-dbcp[camel-jooq DBCP Dependency] | ❌ None | Dependency was test-only, removed from camel-jooq. Users should add commons-dbcp2 if needed. Not automated as version mapping is complex.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#deprecation-of-camel-ironmq[camel-ironmq Deprecated] | ❌ None | Deprecation notice
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#deprecation-of-camel-digitalocean[camel-digitalocean Deprecated] | ❌ None | Deprecation notice
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-irc-potential-breaking-change[camel-irc Headers (deprecated)] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review. Component is deprecated.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#deprecation-of-camel-iec-60870[camel-iec-60870 Deprecated] | ❌ None | Deprecation notice
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#deprecation-of-camel-jasypt-cli-entrypoint[camel-jasypt CLI Deprecated] | ❌ None | Deprecation notice
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-langchain4j-tools-camel-langchain4j-agent-camel-spring-ai-tools[camel-langchain4j/spring-ai Parameter Filtering] | ❌ None | Runtime behavior change
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#deprecation-of-camel-paho[camel-paho Deprecated] | ❌ None | Deprecation notice
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#tightened-default-objectinputfilter-across-deserialization-sites-potential-breaking-change[Tightened ObjectInputFilter Defaults] | ❌ None | Runtime security limits
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_21.html#camel-azure-storage-blob[camel-azure-storage-blob List Versions] | ❌ None | New feature
+|===
+
== 4.20.0
=== Summary
@@ -57,6 +146,61 @@ The following table lists migration topics and indicates the level of coverage (
| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_19.html#_removed_components[Removed Components] | ✅ Full | Component removal: Automatically migrated.
|===
+== 4.18.3
+
+=== Summary
+
+This is a release supporting Camel, Camel Quarkus and Camel Spring Boot 4.18.3 LTS with the required upgrade recipes (described by the https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc[migration guide]).
+
+Most recipes in 4.18.3 are header renames that were introduced in the 4.18.x maintenance releases and later adopted in 4.21.0. These recipes are shared between 4.18.3 and 4.21.0.
+
+=== Safety Features
+
+All header rename recipes include dependency-based preconditions using `ModuleHasDependency`. This ensures headers are only renamed when the corresponding Camel component is actually present in the project, preventing false positives and accidental renaming of unrelated headers.
+
+=== Migration coverage
+
+The following table lists migration topics and indicates the level of coverage (full, partial, or not covered), along with additional comments.
+
+[%autowidth,stripes=hover]
+|===
+| Migration | Coverage | Comment
+
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-core[DefaultHeaderFilterStrategy Lowercase Default] | ❌ None | Configuration default change from 4.18.3, manual review required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-jms[camel-jms ObjectMessage Disabled] | ❌ None | Security change, manual configuration required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-sjms-camel-sjms2[camel-sjms/sjms2 ObjectMessage Disabled] | ❌ None | Security change, manual configuration required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-aws-bedrock[camel-aws-bedrock Guardrail Header] | ❌ None | Header name change, manual migration required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-hazelcast[camel-hazelcast Serialization Filter] | ❌ None | Runtime security enhancement
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-bom[camel-bom camel-test Removed] | ❌ None | camel-test module removed from camel-bom. Replace with camel-test-junit5 or camel-test-junit6 depending on your JUnit version.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-dapr-potential-breaking-change[camel-dapr HeaderFilterStrategy & Consumer Headers] | ❌ None | Runtime behavior change - dapr-pubsub consumer no longer sets CamelDaprPubSubName/CamelDaprTopic headers. Routes reading these headers must be manually updated to read from endpoint configuration instead.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-yaml-io-camel-xml-io[YAML DSL routePolicy renamed to routePolicyRef] | ✅ Full | Automatically renames `routePolicy` to `routePolicyRef` in YAML DSL route definitions.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#saga-eip[Saga EIP Structure Changes] | ✅ Full | XML DSL: `<compensation>`/`<completion>` child elements automatically converted to attributes. YAML DSL: nested uri objects automatically flattened to simple values. Java DSL not affected.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-simple[camel-simple Init Blocks Syntax] | ❌ None | Simple language init blocks now require semicolons after each variable assignment. Manual migration required - add `;` after each `$var := value` line inside `$init{...}init$` blocks.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-jgroups-potential-breaking-change[camel-jgroups Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-lucene[camel-lucene Headers] | ⚠️ Partial | Only Lucene-specific header `RETURN_LUCENE_DOCS` migrated. Generic header `QUERY` excluded to prevent false positives. DSL accessor methods require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-jgroups-raft[camel-jgroups-raft Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-elasticsearch-rest-client[camel-elasticsearch-rest-client Headers] | ❌ None | Not covered. Header names are too common, therefore the automation might be dangerous.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-neo4j[camel-neo4j Property Validation] | ❌ None | New validation behavior, no migration needed
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-mail[camel-mail SMTP Security] | ❌ None | Security change requiring opt-in, manual configuration required
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-mail[camel-mail IdempotentRepository Auto-Start] | ❌ None | Runtime behavior change - custom IdempotentRepository beans are now auto-started (aligned with camel-file). If your code manually starts the repository, review for potential duplicate startup.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-mail-2[camel-mail Consumer Dispatch Headers] | ❌ None | Generic header names (`copyTo`, `moveTo`, `delete`) excluded to prevent false positives. Manual migration required.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-jira-potential-breaking-change[camel-jira Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods (`issueKey()` → `jiraIssueKey()`) require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-pdf-potential-breaking-change[camel-pdf Headers] | ❌ None | All header names too generic to safely automate. Manual migration required.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-arangodb-potential-breaking-change[camel-arangodb Headers] | ❌ None | Generic header names (`key`, `ResultClassType`) excluded to prevent false positives. Manual migration required.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-jt400-potential-breaking-change[camel-jt400 Headers] | ❌ None | Generic header names (`KEY`, `SENDER_INFORMATION`) excluded to prevent false positives. Manual migration required.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-github2-potential-breaking-change[camel-github2 Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-elasticsearch-camel-opensearch-potential-breaking-change[camel-elasticsearch/opensearch Headers] | ⚠️ Partial | Only Elasticsearch-unique header `enableDocumentOnlyMode` migrated. Generic headers (`operation`, `indexId`, `indexName`, `documentClass`, `size`, `from`, etc.) and all OpenSearch headers excluded to prevent false positives and conflicts between the two components.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-google-functions-camel-google-secret-manager-camel-google-vision-camel-google-text-to-speech-camel-google-speech-to-text-potential-breaking-change[camel-google-cloud Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-openstack-potential-breaking-change[camel-openstack Headers] | ⚠️ Partial | Only OpenStack-specific headers with clear cloud terminology migrated (e.g., `FlavorId`, `RAM`, `VCPU`, `KeypairName`, `adminStateUp`). Generic headers (*Id, *Name, `containerName`, `objectName`, `ipVersion`) excluded to prevent false positives.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-shiro-potential-breaking-change[camel-shiro Security Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Security-critical - headers now filtered by default.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-web3j-potential-breaking-change[camel-web3j Headers] | ⚠️ Partial | Only blockchain-specific headers migrated (e.g., `FROM_ADDRESS`, `BLOCK_HASH`, `GAS_PRICE`, `NONCE`). Generic headers (`ADDRESS`, `POSITION`, `SOURCE_CODE`, `DATABASE_NAME`, `CLIENT_ID`, `PRIORITY`, `TTL`, `ERROR_*`, etc.) excluded to prevent false positives.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-milo-potential-breaking-change[camel-milo Headers] | ❌ None | Generic header name (`await`) excluded to prevent false positives. Manual migration required.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-mongodb-gridfs[camel-mongodb-gridfs Headers] | ⚠️ Partial | Header string literals migrated. DSL accessor methods require manual update.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-solr[camel-solr Header Prefixes] | ⚠️ Partial | Header prefix migration automated: `SolrField.` → `CamelSolrField.`, `SolrParam.` → `CamelSolrParam.` for `.setHeader()` and Simple expressions. Routes using symbolic constants (e.g., `SolrConstants.HEADER_FIELD_PREFIX + "id"`) continue to work unchanged. Dynamic headers and Map operations require manual review. WARNING: Renamed headers are stripped by HeaderFilterStra [...]
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-json-patch[camel-json-patch Deprecated] | ❌ None | Component deprecated - underlying library unmaintained and incompatible with Jackson 3. Consider alternative solutions for JSON patching.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.adoc#camel-openapi-java[camel-openapi-java base.path Priority] | ❌ None | Configuration behavior change - base.path now takes precedence over contextPath for OpenAPI server URL generation. If you configured base.path and want to keep using contextPath in the API spec, remove the base.path configuration.
+|===
+
== 4.18.0
=== Summary
@@ -77,6 +221,18 @@ The following table lists migration topics and indicates the level of coverage (
| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#_camel_tahu[camel-tahu] | ⚠️ Partial | Tool renames handlers to MultiHostApplicationEventHandler. Other API changes are not covered.
| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#_camel_platform_http_vertx_and_rest_dsl_contract_first[camel-platform-http-vertx and Rest DSL contract-first] | ❌ None | Not supported by the migration tool.
| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#_component_deprecation[Component deprecation] | ❌ None | Not supported by the migration tool.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-nats[camel-nats HeaderFilterStrategy] | ❌ None | New default NatsHeaderFilterStrategy filters Camel* headers. Routes relying on passing Camel-prefixed headers through NATS must use a custom headerFilterStrategy.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-xmpp[camel-xmpp HeaderFilterStrategy] | ❌ None | New filtering behavior for Camel* headers.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-vertx-websocket[camel-vertx-websocket HeaderFilterStrategy] | ❌ None | New filtering behavior for Camel* headers.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-atmosphere-websocket[camel-atmosphere-websocket HeaderFilterStrategy] | ❌ None | New filtering behavior for Camel* headers.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-iggy[camel-iggy HeaderFilterStrategy] | ❌ None | New filtering behavior for Camel* headers.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-aws2-sqs[camel-aws2-sqs HeaderFilterStrategy] | ❌ None | New filtering behavior for Camel* headers.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-aws2-sns[camel-aws2-sns HeaderFilterStrategy] | ❌ None | New filtering behavior for Camel* headers.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-dns-potential-breaking-change[camel-dns Headers] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-kafka-potential-breaking-change[camel-kafka Headers (HIGH IMPACT)] | ⚠️ Partial | Only basic header usage is migrated. Automated for `.setHeader()` and Simple expressions. Dynamic headers and Map operations require manual review. Includes precondition to only migrate when camel-kafka is present.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-cxf-potential-breaking-change[camel-cxf/cxfrs Headers] | ❌ None | Generic header names (`operationName`, `operationNamespace`) excluded to prevent false positives. Manual migration required.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-salesforce-potential-breaking-change[camel-salesforce Headers] | ⚠️ Partial | Header literal renames automated for Salesforce-specific headers only (16 headers: `sObject*`, `apex*`, `pkChunking*` + `apexQueryParam.` prefix). Generic headers (`limit`, `contentType`, `jobId`, `batchId`, `resultId`, etc.) excluded to prevent false positives. Routes using symbolic constants continue to work unchanged.
+| https://camel.apache.org/manual/camel-4x-upgrade-guide-4_18.html#camel-pqc[camel-pqc Key Metadata Format] | ❌ None | Runtime automatic migration from Java serialization to JSON. No code changes required.
|===
== 4.17.0