You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2026/09/25 15:10:06 UTC

(ws-xmlschema) 01/01: Fix test on JDK8

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

coheigea pushed a commit to branch coheigea/fix-test
in repository https://gitbox.apache.org/repos/asf/ws-xmlschema.git

commit ccece5b8080177fdb131acee6ae2cfcd66df8f8e
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri Sep 25 16:09:42 2026 +0100

    Fix test on JDK8
---
 .../test/java/tests/DefaultURIResolverTest.java    | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java b/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java
index e3a2cd7b..f1339e3d 100644
--- a/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java
+++ b/xmlschema-core/src/test/java/tests/DefaultURIResolverTest.java
@@ -144,11 +144,31 @@ public class DefaultURIResolverTest extends Assert {
         }
     }
 
+    /**
+     * Refused, without requiring a particular reason. Which layer refuses a location depends on the
+     * running JDK: composing a base URI with a scheme the JDK has no handler for fails in
+     * {@link java.net.URL} before this resolver's own checks see it. Both outcomes are a refusal,
+     * which is what matters here.
+     */
+    private static void assertRefused(String schemaLocation, String baseUri) {
+        DefaultURIResolver resolver = new DefaultURIResolver();
+        try {
+            resolver.resolveEntity("urn:x", schemaLocation, baseUri);
+            fail("The location \"" + schemaLocation + "\" must be refused.");
+        } catch (XmlSchemaException expected) {
+            // expected, whichever layer refused it
+        }
+    }
+
     @Test
     public void testDisallowedSchemesAreRefusedFromALocalBase() {
         assertSchemeRefused("mailto:someone@example.com", localBase());
-        assertSchemeRefused("jrt:/java.base/java/lang/Object.class", localBase());
         assertSchemeRefused("ftp://attacker.example/x.xsd", localBase());
+        // jrt: has no URL handler before Java 9, where composing it with the base fails in
+        // java.net.URL rather than reaching the scheme check, so only require the refusal.
+        assertRefused("jrt:/java.base/java/lang/Object.class", localBase());
+        // A scheme no JDK has a handler for, to cover that path on every JDK.
+        assertRefused("nosuchscheme:/x.xsd", localBase());
     }
 
     @Test