8320918: Fix errors in the built-in Catalog implementation

Reviewed-by: lancea, naoto, iris
This commit is contained in:
Joe Wang 2023-11-29 04:33:28 +00:00
parent 5e1b771a19
commit 9a6ca233c7
6 changed files with 52 additions and 18 deletions

View File

@ -304,7 +304,7 @@ public final class JdkConstants {
* System Property for the JDKCatalog' RESOLVE property
* @since 22
*/
public static final String JDKCATALOG_RESOLVE = "jdk.xml.jdkCatalog.resolve";
public static final String JDKCATALOG_RESOLVE = "jdk.xml.jdkcatalog.resolve";
// Catalog Resolve Integer mappings for String values
public static final int CONTINUE = 0;

View File

@ -47,11 +47,11 @@
# the default property values. The format is:
# system-property-name=value
#
# For example, the FILES property in CatalogFeatures has an associated system
# property called javax.xml.catalog.files. An entry for the FILES property in the
# configuration file would therefore use javax.xml.catalog.files as the key, that
# For example, the RESOLVE property in CatalogFeatures has an associated system
# property called javax.xml.catalog.resolve. An entry for the RESOLVE property in the
# configuration file would therefore use javax.xml.catalog.resolve as the key, that
# is:
# javax.xml.catalog.files=strict
# javax.xml.catalog.resolve=strict
#
#
# Extension Functions:
@ -128,6 +128,24 @@ jdk.xml.overrideDefaultParser=false
#
# javax.xml.useCatalog=true
#
# Implementation Specific Properties - jdkcatalog.resolve
#
# This property instructs the JDK default CatalogResolver to act in accordance with
# the setting when unable to resolve an external reference with the built-in Catalog.
# The options are:
# continue -- indicates that the processing should continue
# ignore -- indicates that the reference is skipped
# strict -- indicates that the resolver should throw a CatalogException
#
# The following setting would cause the resolve to throw a CatalogException when
# unable to resolve an external reference:
# jdk.xml.jdkcatalog.resolve=strict
#
# Implementation Specific Properties - DTD
#
# This property instructs the parsers to: deny, ignore or allow DTD processing.
# The following setting would cause the parser to reject DTD by throwing an exception.
# jdk.xml.dtd.support=deny
#
# Implementation Specific Properties - Limits
#

View File

@ -57,7 +57,7 @@ public class CatalogTestBase extends TestBase {
// error (not from catalog) is expect when CATALOG=continue
boolean isErrExpected = true;
String expected1 = "invalid.site.com";
String expected1 = UNKNOWN_HOST;
// expected when reference is resolved by Catalog
String expected3 = "", expected4 = "";

View File

@ -13,7 +13,7 @@
# ---- Config File: for testing the CATALOG property ----
#
# strict: report error if not resolved by the JDK Catalog
jdk.xml.jdkCatalog.resolve=strict
jdk.xml.jdkcatalog.resolve=strict
# Enable Extension Functions
jdk.xml.enableExtensionFunctions=true
# Disallow overriding the default parser

View File

@ -47,11 +47,11 @@
# the default property values. The format is:
# system-property-name=value
#
# For example, the FILES property in CatalogFeatures has an associated system
# property called javax.xml.catalog.files. An entry for the FILES property in the
# configuration file would therefore use javax.xml.catalog.files as the key, that
# For example, the RESOLVE property in CatalogFeatures has an associated system
# property called javax.xml.catalog.resolve. An entry for the RESOLVE property in the
# configuration file would therefore use javax.xml.catalog.resolve as the key, that
# is:
# javax.xml.catalog.files=strict
# javax.xml.catalog.resolve=strict
#
#
# Extension Functions:
@ -128,6 +128,19 @@ jdk.xml.overrideDefaultParser=false
#
# javax.xml.useCatalog=true
#
# Implementation Specific Properties - jdkcatalog.resolve
#
# This property instructs the JDK default CatalogResolver to act in accordance with
# the setting when unable to resolve an external reference with the built-in Catalog.
# The options are:
# continue -- indicates that the processing should continue
# ignore -- indicates that the reference is skipped
# strict -- indicates that the resolver should throw a CatalogException
#
# The following setting would cause the resolve to throw a CatalogException when
# unable to resolve an external reference:
# jdk.xml.jdkcatalog.resolve=strict
#
# Implementation Specific Properties - DTD
#
# This property instructs the parsers to: deny, ignore or allow DTD processing.

View File

@ -102,7 +102,7 @@ public class TestBase {
// Impl Specific Properties
public static final String SP_DTD = "jdk.xml.dtd.support";
public static final String SP_CATALOG = "jdk.xml.jdkCatalog.resolve";
public static final String SP_CATALOG = "jdk.xml.jdkcatalog.resolve";
public static final String OVERRIDE_PARSER = "jdk.xml.overrideDefaultParser";
// DTD/CATALOG constants
@ -121,6 +121,7 @@ public class TestBase {
// CATALOG=strict
public static final String CONFIG_CATALOG_STRICT = "catalog2.properties";
public static final String UNKNOWN_HOST = "invalid.site.com";
String xmlExternalEntity, xmlExternalEntityId;
String xmlGE_Expansion, xmlGE_ExpansionId;
@ -334,17 +335,19 @@ public class TestBase {
protected void processError(boolean expectError, String error, Exception e)
throws Exception {
//e.printStackTrace();
String str = e.getMessage();
// System.out.println("Exp Msg: " + str);
//e.printStackTrace();
if (!expectError) {
Assert.assertTrue(false, "Expected pass, but Exception is thrown " +
str);
Assert.assertTrue(false, "Expected pass, but Exception is thrown " + str);
} else {
// This check is necessary since errors other than UnknownHostException
// can contain the host name in the System ID
if (UNKNOWN_HOST.equals(error)) {
Assert.assertTrue((str != null) && str.equals(error));
} else {
Assert.assertTrue((str != null) && str.contains(error));
}
}
}
/**
* Returns a DocumentBuilderFactory with settings as specified.