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/08/25 11:52:12 UTC
(camel-upgrade-recipes) branch gate-xml-recipes-126 created (now 83c0f93)
This is an automated email from the ASF dual-hosted git repository.
Croway pushed a change to branch gate-xml-recipes-126
in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
at 83c0f93 Gate the remaining XML DSL recipes on a Camel document
This branch includes the following new commits:
new 83c0f93 Gate the remaining XML DSL recipes on a Camel document
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(camel-upgrade-recipes) 01/01: Gate the remaining XML DSL recipes on a Camel document
Posted by fm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
Croway pushed a commit to branch gate-xml-recipes-126
in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
commit 83c0f93f27c390517f8514bbaf88943e08a93bb5
Author: croway <fe...@gmail.com>
AuthorDate: Tue Aug 25 13:52:03 2026 +0200
Gate the remaining XML DSL recipes on a Camel document
Fixes #126.
The Java recipes are gated by UsesType and the YAML recipes by
camelYamlDslPrecondition, and #125 added camelXmlDslPrecondition and
applied it to two XML recipes. The other ten visited every XML document
in a project, so a matcher that happens to fit an unrelated file rewrote
it. XmlDsl418_1SagaRecipe did not merely rename in such a file, it
removed a child element and folded it into an attribute.
Wraps every remaining XML visitor in the precondition, so the whole set
is now uniform and a new XML recipe inherits the same guard.
CameXmlDslRecipeTest.circuitBreakerFull used a synthetic <differentContext>
root, which is not a Camel document. Its sibling circuitBreaker test
already covers the <route> context, so the root becomes <camelContext>,
which is where a top level resilience4jConfiguration actually lives, and
the option coverage the test exists for is unchanged.
Adds CamelXmlDslPreconditionTest, one negative test per gated recipe,
each feeding a document carrying exactly the shape that recipe matches
under a plainly non-Camel root. Kept in one class rather than spread over
the existing test classes because the property is uniform across the
recipes, so a new XML recipe is one line away from being covered.
Verified the tests are not vacuous: with the gating reverted, 8 of the 10
fail, the other 2 being the recipes already gated by #125.
camel40.xml.XmlDslRecipe has no negative test on purpose, its matchers
are anchored at /routes/route so the document root has to be routes,
which is a Camel root.
Co-Authored-By: Claude Opus 5 (1M context) <no...@anthropic.com>
---
.../camel40/xml/CircuitBreakerXmlDslRecipe.java | 6 +-
.../camel/upgrade/camel40/xml/XmlDslRecipe.java | 6 +-
.../apache/camel/upgrade/camel41/XmlDslRecipe.java | 6 +-
.../camel/upgrade/camel410/XmlDsl410Recipe.java | 6 +-
.../upgrade/camel418_1/XmlDsl418_1SagaRecipe.java | 6 +-
.../camel418_3/RenameHeaderPrefixInXmlDsl.java | 5 +-
.../camel/upgrade/camel47/XmlDsl47Recipe.java | 6 +-
.../ReplacePropertyInComponentXml.java | 5 +-
.../ReplacePropertyInDataFormatXml.java | 6 +-
.../internal/ChangeXmlComponentUriRecipe.java | 5 +-
.../upgrade/camel40/CameXmlDslRecipeTest.java | 8 +-
.../upgrade/xml/CamelXmlDslPreconditionTest.java | 225 +++++++++++++++++++++
12 files changed, 267 insertions(+), 23 deletions(-)
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/CircuitBreakerXmlDslRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/CircuitBreakerXmlDslRecipe.java
index 2fdabbf..67a71f4 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/CircuitBreakerXmlDslRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/CircuitBreakerXmlDslRecipe.java
@@ -16,8 +16,10 @@
*/
package org.apache.camel.upgrade.camel40.xml;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
import org.jspecify.annotations.Nullable;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.Tree;
@@ -101,7 +103,7 @@ public class CircuitBreakerXmlDslRecipe extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.@Nullable Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -142,6 +144,6 @@ public class CircuitBreakerXmlDslRecipe extends Recipe {
return t;
}
- };
+ });
}
}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/XmlDslRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/XmlDslRecipe.java
index 5d47bae..80e5a1e 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/XmlDslRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel40/xml/XmlDslRecipe.java
@@ -16,8 +16,10 @@
*/
package org.apache.camel.upgrade.camel40.xml;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
import org.jspecify.annotations.Nullable;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.Tree;
@@ -69,7 +71,7 @@ public class XmlDslRecipe extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.@Nullable Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -100,6 +102,6 @@ public class XmlDslRecipe extends Recipe {
return t;
}
- };
+ });
}
}
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 0bfa9c1..1b32245 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
@@ -16,7 +16,9 @@
*/
package org.apache.camel.upgrade.camel41;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.Tree;
@@ -70,7 +72,7 @@ public class XmlDslRecipe extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -106,6 +108,6 @@ public class XmlDslRecipe extends Recipe {
return t;
}
- };
+ });
}
}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel410/XmlDsl410Recipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel410/XmlDsl410Recipe.java
index 49f13ca..8c2f3f2 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel410/XmlDsl410Recipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel410/XmlDsl410Recipe.java
@@ -16,7 +16,9 @@
*/
package org.apache.camel.upgrade.camel410;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
@@ -50,7 +52,7 @@ public class XmlDsl410Recipe extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -64,6 +66,6 @@ public class XmlDsl410Recipe extends Recipe {
.findAny()
.orElse(t);
}
- };
+ });
}
}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_1/XmlDsl418_1SagaRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_1/XmlDsl418_1SagaRecipe.java
index 34ed9d8..070b11a 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_1/XmlDsl418_1SagaRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_1/XmlDsl418_1SagaRecipe.java
@@ -16,7 +16,9 @@
*/
package org.apache.camel.upgrade.camel418_1;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
@@ -49,7 +51,7 @@ public class XmlDsl418_1SagaRecipe extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -111,6 +113,6 @@ public class XmlDsl418_1SagaRecipe extends Recipe {
)
)));
}
- };
+ });
}
}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_3/RenameHeaderPrefixInXmlDsl.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_3/RenameHeaderPrefixInXmlDsl.java
index ee54903..f5ce0e8 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_3/RenameHeaderPrefixInXmlDsl.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_3/RenameHeaderPrefixInXmlDsl.java
@@ -16,7 +16,9 @@
*/
package org.apache.camel.upgrade.camel418_3;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Option;
import org.openrewrite.Recipe;
@@ -69,7 +71,8 @@ public class RenameHeaderPrefixInXmlDsl extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new XmlHeaderPrefixVisitor(oldPrefix, newPrefix);
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(),
+ new XmlHeaderPrefixVisitor(oldPrefix, newPrefix));
}
private static class XmlHeaderPrefixVisitor extends AbstractCamelXmlVisitor {
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/XmlDsl47Recipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/XmlDsl47Recipe.java
index 37eca9b..82c0c8e 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/XmlDsl47Recipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel47/XmlDsl47Recipe.java
@@ -16,7 +16,9 @@
*/
package org.apache.camel.upgrade.camel47;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
@@ -54,7 +56,7 @@ public class XmlDsl47Recipe extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -68,6 +70,6 @@ public class XmlDsl47Recipe extends Recipe {
.findAny()
.orElse(t);
}
- };
+ });
}
}
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInComponentXml.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInComponentXml.java
index ebf85fd..e820154 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInComponentXml.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/ReplacePropertyInComponentXml.java
@@ -18,6 +18,7 @@ package org.apache.camel.upgrade.customRecipes;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Option;
import org.openrewrite.Recipe;
@@ -89,7 +90,7 @@ public class ReplacePropertyInComponentXml extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -104,7 +105,7 @@ public class ReplacePropertyInComponentXml extends Recipe {
return t;
}
- };
+ });
}
private Xml.Tag replacePropertyIfPossible(final Xml.Tag tag) {
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 94237f3..5d51591 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
@@ -16,7 +16,9 @@
*/
package org.apache.camel.upgrade.customRecipes;
+import org.apache.camel.upgrade.RecipesUtil;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Option;
import org.openrewrite.Recipe;
@@ -73,7 +75,7 @@ public class ReplacePropertyInDataFormatXml extends Recipe {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
@@ -84,7 +86,7 @@ public class ReplacePropertyInDataFormatXml extends Recipe {
}
return t;
}
- };
+ });
}
private Xml.Tag replacePropertyIfPossible(final Xml.Tag tag) {
diff --git a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/internal/ChangeXmlComponentUriRecipe.java b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/internal/ChangeXmlComponentUriRecipe.java
index 88b0ac4..2c97a5b 100644
--- a/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/internal/ChangeXmlComponentUriRecipe.java
+++ b/camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/customRecipes/internal/ChangeXmlComponentUriRecipe.java
@@ -18,6 +18,7 @@ package org.apache.camel.upgrade.customRecipes.internal;
import org.apache.camel.upgrade.AbstractCamelXmlVisitor;
import org.apache.camel.upgrade.RecipesUtil;
+import org.openrewrite.Preconditions;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Option;
import org.openrewrite.Recipe;
@@ -97,7 +98,7 @@ public class ChangeXmlComponentUriRecipe extends Recipe {
public TreeVisitor<?, ExecutionContext> getVisitor() {
Pattern pattern = Pattern.compile(uriPattern);
- return new AbstractCamelXmlVisitor() {
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(), new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(Xml.Tag tag, ExecutionContext ctx) {
Xml.Tag t = super.doVisitTag(tag, ctx);
@@ -109,7 +110,7 @@ public class ChangeXmlComponentUriRecipe extends Recipe {
return t;
}
- };
+ });
}
private static Xml.Tag transformXmlUri(Xml.Tag tag, Pattern pattern, String replacement) {
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel40/CameXmlDslRecipeTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel40/CameXmlDslRecipeTest.java
index 7615142..7e3e39c 100644
--- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel40/CameXmlDslRecipeTest.java
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/camel40/CameXmlDslRecipeTest.java
@@ -86,7 +86,7 @@ public class CameXmlDslRecipeTest implements RewriteTest {
//language=xml
rewriteRun(xml(
"""
- <differentContext>
+ <camelContext>
<circuitBreaker>
<resilience4jConfiguration>
<bulkheadEnabled>5643</bulkheadEnabled>
@@ -98,15 +98,15 @@ public class CameXmlDslRecipeTest implements RewriteTest {
<timeoutCancelRunningFuture></timeoutCancelRunningFuture>
</resilience4jConfiguration>
</circuitBreaker>
- </differentContext>
+ </camelContext>
""",
"""
- <differentContext>
+ <camelContext>
<circuitBreaker>
<resilience4jConfiguration bulkheadEnabled="5643" bulkheadMaxConcurrentCalls="aaaa" bulkheadMaxWaitDuration="1" timeoutEnabled="true" timeoutExecutorService="1" timeoutDuration="1">
</resilience4jConfiguration>
</circuitBreaker>
- </differentContext>
+ </camelContext>
"""));
}
diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/xml/CamelXmlDslPreconditionTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/xml/CamelXmlDslPreconditionTest.java
new file mode 100644
index 0000000..31827e9
--- /dev/null
+++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/xml/CamelXmlDslPreconditionTest.java
@@ -0,0 +1,225 @@
+/*
+ * 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.xml;
+
+import org.apache.camel.upgrade.CamelTestUtil;
+import org.apache.camel.upgrade.camel410.XmlDsl410Recipe;
+import org.apache.camel.upgrade.camel418_1.XmlDsl418_1SagaRecipe;
+import org.apache.camel.upgrade.camel418_3.RenameHeaderInXmlDsl;
+import org.apache.camel.upgrade.camel418_3.RenameHeaderPrefixInXmlDsl;
+import org.apache.camel.upgrade.camel46.XmlDsl46Recipe;
+import org.apache.camel.upgrade.camel47.XmlDsl47Recipe;
+import org.apache.camel.upgrade.customRecipes.ReplacePropertyInComponentXml;
+import org.apache.camel.upgrade.customRecipes.ReplacePropertyInDataFormatXml;
+import org.apache.camel.upgrade.customRecipes.internal.ChangeXmlComponentUriRecipe;
+import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.test.RewriteTest;
+import org.openrewrite.test.TypeValidation;
+
+import static org.openrewrite.xml.Assertions.xml;
+
+/**
+ * Every XML DSL recipe is gated on {@code RecipesUtil.camelXmlDslPrecondition()}, so none of them may
+ * touch a document that is not Camel XML. Each test feeds a document carrying exactly the shape the
+ * recipe matches, wrapped in a root element that is plainly not Camel, and expects no change.
+ * <p>
+ * {@code camel40.xml.XmlDslRecipe} has no test here on purpose: its matchers are anchored at
+ * {@code /routes/route}, so the document root has to be {@code routes}, which is a Camel root.
+ */
+class CamelXmlDslPreconditionTest implements RewriteTest {
+
+ @DocumentExample
+ @Test
+ void springBeanDefinitionIsNotADataFormatOrHeaderCarrier() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new XmlDsl46Recipe()),
+ xml(
+ """
+ <beans xmlns="http://www.springframework.org/schema/beans">
+ <bean id="example" class="com.example.Example">
+ <property name="topic" value="orders"/>
+ </bean>
+ </beans>
+ """
+ )
+ );
+ }
+
+ @Test
+ void headerRenameLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new RenameHeaderInXmlDsl("kafka.TOPIC", "CamelKafkaTopic")),
+ xml(
+ """
+ <configuration xmlns="http://example.com/schema/http">
+ <endpoint url="https://example.com/publish">
+ <header name="kafka.TOPIC" value="orders"/>
+ <template>${header.kafka.TOPIC}</template>
+ </endpoint>
+ </configuration>
+ """
+ )
+ );
+ }
+
+ @Test
+ void headerPrefixRenameLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new RenameHeaderPrefixInXmlDsl("SolrField.", "CamelSolrField.")),
+ xml(
+ """
+ <configuration xmlns="http://example.com/schema/http">
+ <endpoint url="https://example.com/search">
+ <header name="SolrField.id" value="doc123"/>
+ </endpoint>
+ </configuration>
+ """
+ )
+ );
+ }
+
+ @Test
+ void sagaLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new XmlDsl418_1SagaRecipe()),
+ xml(
+ """
+ <workflow xmlns="http://example.com/schema/workflow">
+ <saga>
+ <compensation uri="http://example.com/undo"/>
+ <completion uri="http://example.com/done"/>
+ </saga>
+ </workflow>
+ """
+ )
+ );
+ }
+
+ @Test
+ void circuitBreakerLeavesNonCamelXmlAlone() {
+ // driven through the whole 4.0 migration, the way CameXmlDslRecipeTest drives it
+ //language=xml
+ rewriteRun(
+ spec -> CamelTestUtil.recipe(spec, CamelTestUtil.CamelVersion.v4_0)
+ .typeValidationOptions(TypeValidation.none()),
+ xml(
+ """
+ <application>
+ <circuitBreaker>
+ <resilience4jConfiguration>
+ <timeoutEnabled>true</timeoutEnabled>
+ <timeoutDuration>1</timeoutDuration>
+ </resilience4jConfiguration>
+ </circuitBreaker>
+ </application>
+ """
+ )
+ );
+ }
+
+ @Test
+ void interceptLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new XmlDsl410Recipe()),
+ xml(
+ """
+ <pipeline xmlns="http://example.com/schema/pipeline">
+ <intercept>
+ <when>
+ <simple>true</simple>
+ </when>
+ </intercept>
+ </pipeline>
+ """
+ )
+ );
+ }
+
+ @Test
+ void loadBalanceLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new XmlDsl47Recipe()),
+ xml(
+ """
+ <cluster xmlns="http://example.com/schema/cluster">
+ <loadBalance>
+ <roundRobin/>
+ </loadBalance>
+ </cluster>
+ """
+ )
+ );
+ }
+
+ @Test
+ void componentPropertyLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new ReplacePropertyInComponentXml("netty-http", "keyStoreFile", "keyStoreResource", "file:")),
+ xml(
+ """
+ <deployment xmlns="http://example.com/schema/deployment">
+ <route>
+ <from uri="netty-http:https://0.0.0.0:8443/service?keyStoreFile=/opt/keystore.jks"/>
+ </route>
+ </deployment>
+ """
+ )
+ );
+ }
+
+ @Test
+ void dataFormatPropertyLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new ReplacePropertyInDataFormatXml("csv", "formatRef", "format")),
+ xml(
+ """
+ <deployment xmlns="http://example.com/schema/deployment">
+ <marshal>
+ <csv formatRef="myCsvFormat"/>
+ </marshal>
+ </deployment>
+ """
+ )
+ );
+ }
+
+ @Test
+ void componentUriLeavesNonCamelXmlAlone() {
+ //language=xml
+ rewriteRun(
+ spec -> spec.recipe(new ChangeXmlComponentUriRecipe("^langchain4j-tools:(.*)$", "ai-tool:${1}", true)),
+ xml(
+ """
+ <deployment xmlns="http://example.com/schema/deployment">
+ <route>
+ <from uri="langchain4j-tools:weather?tags=weather"/>
+ </route>
+ </deployment>
+ """
+ )
+ );
+ }
+}