Skip to content

Commit

Permalink
8320918: Fix errors in the built-in Catalog implementation
Browse files Browse the repository at this point in the history
Reviewed-by: lancea, naoto, iris
  • Loading branch information
JoeWang-Java committed Nov 29, 2023
1 parent 5e1b771 commit 9a6ca23
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 22 additions & 4 deletions src/java.xml/share/conf/jaxp.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Object[][] getConfigs(Processor processor) {

// 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 = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 10 additions & 7 deletions test/jaxp/javax/xml/jaxp/unittest/common/util/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -334,15 +335,17 @@ protected void validate(String filename, SchemaFactory sf, boolean expectError,

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 {
Assert.assertTrue((str != null) && str.contains(error));
// 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));
}
}
}

Expand Down

1 comment on commit 9a6ca23

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.