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

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

commit 3445db7c486d454fa5204f92507dcc82bad5d141
Author: Luigi De Masi <[email protected]>
AuthorDate: Tue Sep 29 15:35:00 2026 +0200

    CAMEL-25138: Validate semantic schemas across build phases
    
    Read the generated schema's target namespace in the declaration-order test.
    A clean test build produces the Spring namespace, while an incremental
    build after packaging can retain the XML IO namespace. The hard-coded
    Spring namespace therefore failed in CI's Java 17 test phase.
    
    Accept only the two expected namespaces and keep schema validation for
    semantic declarations before routes under both routes and camel roots.
    
    Validation: reproduced the two CI failures on Java 17 before the fix.
    The XML IO suite passes on Java 17 with clean and packaged schemas and on
    Java 25 (425 tests per run, including two existing skips). The full
    695-module clean install passes with tests skipped. All 11 CI-selected 
modules also pass on Java 17: 2928
    tests, no failures or errors, and two existing skips.
    
    Co-authored-by: Codex <[email protected]>
    Signed-off-by: Luigi De Masi <[email protected]>
---
 .../java/org/apache/camel/xml/out/ModelWriterTest.java     | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/core/camel-xml-io/src/test/java/org/apache/camel/xml/out/ModelWriterTest.java 
b/core/camel-xml-io/src/test/java/org/apache/camel/xml/out/ModelWriterTest.java
index 8760bdd91848..7cc364e282de 100644
--- 
a/core/camel-xml-io/src/test/java/org/apache/camel/xml/out/ModelWriterTest.java
+++ 
b/core/camel-xml-io/src/test/java/org/apache/camel/xml/out/ModelWriterTest.java
@@ -26,6 +26,7 @@ import java.io.StringWriter;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Collection;
@@ -38,6 +39,7 @@ import java.util.stream.Stream;
 import jakarta.xml.bind.annotation.XmlTransient;
 
 import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.SchemaFactory;
 
@@ -76,17 +78,21 @@ public class ModelWriterTest {
     @ParameterizedTest
     @ValueSource(strings = { "routes", "camel" })
     void semanticDeclarationsBeforeRoutesConformToTheSchema(String root) 
throws Exception {
+        URL schema = getClass().getResource("/camel-xml-io.xsd");
+        // Clean test builds use the Spring namespace; incremental builds can 
reuse the packaged xml-io schema.
+        String namespace = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(schema.toExternalForm())
+                .getDocumentElement().getAttribute("targetNamespace");
+        assertThat(namespace).isIn("http://camel.apache.org/schema/spring";, 
NAMESPACE);
         String xml = """
-                <%s xmlns="http://camel.apache.org/schema/spring";>
+                <%s xmlns="%s">
                   <semantic>
                     <question name="valid" 
type="boolean"><instructions>Valid?</instructions></question>
                   </semantic>
                   <route><from uri="direct:input"/><to 
uri="mock:output"/></route>
                 </%s>
-                """.formatted(root, root);
-        // The build changes the generated schema's namespace to xml-io after 
the test phase.
+                """.formatted(root, namespace, root);
         SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
-                .newSchema(getClass().getResource("/camel-xml-io.xsd"))
+                .newSchema(schema)
                 .newValidator().validate(new StreamSource(new 
StringReader(xml)));
     }
 

Reply via email to