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

ppkarwasz pushed a commit to branch feat/use-commons-xml
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git

commit 18ec795e47fd66e0d01a18122108ff906e0ca59b
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Sun Aug 30 22:25:52 2026 +0200

    Resolve schema locally in TestMultiFileConfigurationBuilder
    
    The 2001 test configuration references its schema through an absolute
    https URI (xsi:noNamespaceSchemaLocation). The hardened parser does not
    fetch external resources, so testSchemaValidationError no longer reached
    the intended schema validation error; the entity resolver refused the
    remote fetch first.
    
    Register the local testMultiConfiguration.xsd for that system URI via an
    XML catalog (CatalogResolver pointing at the existing catalog.xml, which
    already rewrites https://commons.apache.org/ to the local test
    resources) and set it as the builder's entity resolver. The schema now
    loads locally, so the expected SAXParseException validation error is
    raised again.
    
    Assisted-By: Claude Opus 4.8 (1M context) <[email protected]>
---
 .../builder/combined/TestMultiFileConfigurationBuilder.java      | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/src/test/java/org/apache/commons/configuration2/builder/combined/TestMultiFileConfigurationBuilder.java
 
b/src/test/java/org/apache/commons/configuration2/builder/combined/TestMultiFileConfigurationBuilder.java
index d1e51f0f8..e43d6a964 100644
--- 
a/src/test/java/org/apache/commons/configuration2/builder/combined/TestMultiFileConfigurationBuilder.java
+++ 
b/src/test/java/org/apache/commons/configuration2/builder/combined/TestMultiFileConfigurationBuilder.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.apache.commons.configuration2.ConfigurationAssert;
 import org.apache.commons.configuration2.ConfigurationLookup;
 import org.apache.commons.configuration2.DynamicCombinedConfiguration;
 import org.apache.commons.configuration2.HierarchicalConfiguration;
@@ -49,6 +50,7 @@ import 
org.apache.commons.configuration2.event.EventListenerTestImpl;
 import org.apache.commons.configuration2.ex.ConfigurationException;
 import org.apache.commons.configuration2.interpol.ConfigurationInterpolator;
 import org.apache.commons.configuration2.interpol.DefaultLookups;
+import org.apache.commons.configuration2.resolver.CatalogResolver;
 import org.apache.commons.configuration2.tree.ExpressionEngine;
 import org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine;
 import org.junit.jupiter.api.Test;
@@ -334,8 +336,13 @@ public class TestMultiFileConfigurationBuilder extends 
AbstractMultiFileConfigur
      */
     @Test
     void testSchemaValidationError() {
+        // The testMultiConfiguration_2001.xml configuration references its 
schema through an absolute https URI.
+        // The hardened parser does not fetch external resources,
+        // so register the local testMultiConfiguration.xsd for that system 
URI via an XML catalog.
+        final CatalogResolver resolver = new CatalogResolver();
+        
resolver.setCatalogFiles(ConfigurationAssert.getTestFile("catalog.xml").getAbsolutePath());
         final MultiFileConfigurationBuilder<XMLConfiguration> builder = 
createTestBuilder(
-            new 
XMLBuilderParametersImpl().setValidating(true).setSchemaValidation(true));
+            new 
XMLBuilderParametersImpl().setValidating(true).setSchemaValidation(true).setEntityResolver(resolver));
         switchToConfig("2001");
         final ConfigurationException ex = 
assertThrows(ConfigurationException.class, builder::getConfiguration);
         Throwable cause = ex.getCause();

Reply via email to