8303530: Redefine JAXP Configuration File
Reviewed-by: naoto, lancea, alanb, smarks
This commit is contained in:
parent
1bb037bdc6
commit
aff9cea054
37
make/modules/java.xml/Copy.gmk
Normal file
37
make/modules/java.xml/Copy.gmk
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
include CopyCommon.gmk
|
||||
|
||||
################################################################################
|
||||
|
||||
XML_LIB_SRC := $(TOPDIR)/src/java.xml/share/conf
|
||||
|
||||
$(CONF_DST_DIR)/jaxp.properties: $(XML_LIB_SRC)/jaxp.properties
|
||||
$(call install-file)
|
||||
|
||||
TARGETS := $(CONF_DST_DIR)/jaxp.properties
|
||||
|
||||
################################################################################
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,7 +31,7 @@ import jdk.xml.internal.SecuritySupport;
|
||||
/**
|
||||
* This is the base class for features and properties
|
||||
*
|
||||
* @LastModified: May 2021
|
||||
* @LastModified: Mar 2023
|
||||
*/
|
||||
public abstract class FeaturePropertyBase {
|
||||
|
||||
@ -205,7 +205,7 @@ public abstract class FeaturePropertyBase {
|
||||
return;
|
||||
}
|
||||
|
||||
value = SecuritySupport.readJAXPProperty(systemProperty);
|
||||
value = SecuritySupport.readConfig(systemProperty);
|
||||
if (value != null) {
|
||||
values[property.ordinal()] = value;
|
||||
states[property.ordinal()] = State.JAXPDOTPROPERTIES;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -39,7 +39,7 @@ import org.xml.sax.SAXNotSupportedException;
|
||||
/**
|
||||
* @author Rajiv Mordani
|
||||
* @author Edwin Goei
|
||||
* @LastModified: May 2021
|
||||
* @LastModified: Mar 2023
|
||||
*/
|
||||
public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
|
||||
/** These are DocumentBuilderFactory attributes not DOM attributes */
|
||||
@ -148,7 +148,7 @@ public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
|
||||
//check if the property is managed by security manager
|
||||
String pName;
|
||||
if ((pName = fSecurityManager.find(name)) != null) {
|
||||
return attributes.get(pName);
|
||||
return fSecurityManager.getLimitAsString(pName);
|
||||
} else if ((pName = fSecurityPropertyMgr.find(name)) != null) {
|
||||
return attributes.get(pName);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -512,22 +512,17 @@ public final class XMLSecurityManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from system properties, or those in jaxp.properties
|
||||
* Read system properties, or the configuration file
|
||||
*/
|
||||
private void readSystemProperties() {
|
||||
|
||||
for (Limit limit : Limit.values()) {
|
||||
if (!getSystemProperty(limit, limit.systemProperty())) {
|
||||
//if system property is not found, try the older form if any
|
||||
for (NameMap nameMap : NameMap.values()) {
|
||||
String oldName = nameMap.getOldName(limit.systemProperty());
|
||||
if (oldName != null) {
|
||||
getSystemProperty(limit, oldName);
|
||||
}
|
||||
}
|
||||
// attempts to read both the current and old system propery
|
||||
if (!getSystemProperty(limit, limit.systemProperty())
|
||||
&& (!getOldSystemProperty(limit))) {
|
||||
//if system property is not found, try the config file
|
||||
getPropertyConfig(limit, limit.systemProperty());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Array list to store printed warnings for each SAX parser used
|
||||
@ -548,9 +543,9 @@ public final class XMLSecurityManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from system properties, or those in jaxp.properties
|
||||
* Reads a system property, sets value and state if found.
|
||||
*
|
||||
* @param property the type of the property
|
||||
* @param limit the limit property
|
||||
* @param sysPropertyName the name of system property
|
||||
*/
|
||||
private boolean getSystemProperty(Limit limit, String sysPropertyName) {
|
||||
@ -561,8 +556,42 @@ public final class XMLSecurityManager {
|
||||
states[limit.ordinal()] = State.SYSTEMPROPERTY;
|
||||
return true;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
//invalid setting
|
||||
throw new NumberFormatException("Invalid setting for system property: " + limit.systemProperty());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
value = SecuritySupport.readJAXPProperty(sysPropertyName);
|
||||
/**
|
||||
* Reads the legacy system property.
|
||||
* @param limit a limit object
|
||||
* @return true if found, false otherwise
|
||||
*/
|
||||
private boolean getOldSystemProperty(Limit limit) {
|
||||
boolean found = false;
|
||||
for (NameMap nameMap : NameMap.values()) {
|
||||
String oldName = nameMap.getOldName(limit.systemProperty());
|
||||
if (oldName != null) {
|
||||
if (getSystemProperty(limit, oldName)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a property from a configuration file, if any.
|
||||
*
|
||||
* @param limit the limit property
|
||||
* @param sysPropertyName the name of system property
|
||||
* @return
|
||||
*/
|
||||
private boolean getPropertyConfig(Limit limit, String sysPropertyName) {
|
||||
try {
|
||||
String value = SecuritySupport.readConfig(sysPropertyName);
|
||||
if (value != null && !value.equals("")) {
|
||||
values[limit.ordinal()] = Integer.parseInt(value);
|
||||
states[limit.ordinal()] = State.JAXPDOTPROPERTIES;
|
||||
@ -575,7 +604,6 @@ public final class XMLSecurityManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a value set through setProperty to XMLSecurityManager.
|
||||
* If the value is an instance of XMLSecurityManager, use it to override the default;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -231,7 +231,7 @@ public final class XMLSecurityPropertyManager {
|
||||
return;
|
||||
}
|
||||
|
||||
value = SecuritySupport.readJAXPProperty(systemProperty);
|
||||
value = SecuritySupport.readConfig(systemProperty);
|
||||
if (value != null) {
|
||||
values[property.ordinal()] = value;
|
||||
states[property.ordinal()] = State.JAXPDOTPROPERTIES;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,55 @@
|
||||
package javax.xml;
|
||||
|
||||
/**
|
||||
* <p>Utility class to contain basic XML values as constants.
|
||||
* Defines constants for XML Processing APIs.
|
||||
*
|
||||
* <h2 id="EAP">External Access Properties</h2>
|
||||
* The value of the external access properties, including {@link #ACCESS_EXTERNAL_DTD},
|
||||
* {@link #ACCESS_EXTERNAL_SCHEMA}, and {@link #ACCESS_EXTERNAL_STYLESHEET},
|
||||
* is defined as follows.
|
||||
*
|
||||
* <h3 id="EAPValue">Value:</h3>
|
||||
* A list of protocols separated by comma. A protocol is the scheme portion of a
|
||||
* {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme
|
||||
* portion separated by colon. A scheme is defined as:
|
||||
*
|
||||
* <blockquote>
|
||||
* scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
|
||||
* where alpha = a-z and A-Z.<br><br>
|
||||
*
|
||||
* And the JAR protocol:<br>
|
||||
*
|
||||
* jar[:scheme]<br><br>
|
||||
*
|
||||
* Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
|
||||
* {@link java.lang.Character#isSpaceChar } in the value will be ignored.
|
||||
* Examples of protocols are file, http, jar:file.
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* <h3>Default value:</h3>
|
||||
* The default value is implementation specific and therefore not specified.
|
||||
* The following options are provided for consideration:
|
||||
* <blockquote>
|
||||
* <UL>
|
||||
* <LI>an empty string to deny all access to external references;</LI>
|
||||
* <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
|
||||
* <LI>the keyword "all" to grant permission to all protocols.</LI>
|
||||
* </UL><br>
|
||||
* When FEATURE_SECURE_PROCESSING is enabled, it is recommended that implementations
|
||||
* restrict external connections by default, though this may cause problems for applications
|
||||
* that process XML/XSD/XSL with external references.
|
||||
* </blockquote>
|
||||
*
|
||||
* <h3>Granting all access:</h3>
|
||||
* The keyword "all" grants permission to all protocols.
|
||||
*
|
||||
* <h2 id="PropPrec">Property Precedence</h2>
|
||||
* Properties, including the <a href="#EAP">External Access Properties</a> and
|
||||
* {@link #USE_CATALOG}, can be specified through multiple configuration sources.
|
||||
* They follow the configuration process as defined in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#Conf">Configuration</a> section
|
||||
* of the module summary.
|
||||
*
|
||||
* @author Jeff Suttor
|
||||
* @see <a href="http://www.w3.org/TR/xml11/">Extensible Markup Language (XML) 1.1</a>
|
||||
@ -184,6 +232,10 @@ public final class XMLConstants {
|
||||
* ignoring security issues such as limits on XML constructs to avoid conditions such as denial of service attacks.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @implNote
|
||||
* when the Java Security Manager is present, the JDK sets the value of
|
||||
* this feature to true and does not allow it to be turned off.
|
||||
*/
|
||||
public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing";
|
||||
|
||||
@ -198,54 +250,15 @@ public final class XMLConstants {
|
||||
* for example, {@link org.xml.sax.SAXException} is thrown.
|
||||
*
|
||||
* <p>
|
||||
* <b>Value: </b> a list of protocols separated by comma. A protocol is the scheme portion of a
|
||||
* {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
|
||||
* separated by colon.
|
||||
* A scheme is defined as:
|
||||
*
|
||||
* <blockquote>
|
||||
* scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
|
||||
* where alpha = a-z and A-Z.<br><br>
|
||||
*
|
||||
* And the JAR protocol:<br>
|
||||
*
|
||||
* jar[:scheme]<br><br>
|
||||
*
|
||||
* Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
|
||||
* {@link java.lang.Character#isSpaceChar } in the value will be ignored.
|
||||
* Examples of protocols are file, http, jar:file.
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
*<p>
|
||||
* <b>Default value:</b> The default value is implementation specific and therefore not specified.
|
||||
* The following options are provided for consideration:
|
||||
* <blockquote>
|
||||
* <UL>
|
||||
* <LI>an empty string to deny all access to external references;</LI>
|
||||
* <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
|
||||
* <LI>the keyword "all" to grant permission to all protocols.</LI>
|
||||
* </UL><br>
|
||||
* When FEATURE_SECURE_PROCESSING is enabled, it is recommended that implementations
|
||||
* restrict external connections by default, though this may cause problems for applications
|
||||
* that process XML/XSD/XSL with external references.
|
||||
* </blockquote>
|
||||
* <b>Value: </b> as defined in <a href="#EAP">the class description</a>.
|
||||
*
|
||||
* <p>
|
||||
* <b>Granting all access:</b> the keyword "all" grants permission to all protocols.
|
||||
* <b>System Property:</b> {@code javax.xml.accessExternalDTD}.
|
||||
*
|
||||
* <p>
|
||||
* <b>System Property:</b> The value of this property can be set or overridden by
|
||||
* system property {@code javax.xml.accessExternalDTD}.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <b>jaxp.properties:</b> This configuration file is in standard
|
||||
* {@link java.util.Properties} format and typically located in the {@code conf}
|
||||
* directory of the Java installation. If the file exists and the system
|
||||
* property is specified, its value will be used to override the default
|
||||
* of the property.
|
||||
*
|
||||
* <b>Configuration File:</b>
|
||||
* Yes. The property can be set in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#ConfigurationFile">configuration file</a>.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
@ -262,53 +275,16 @@ public final class XMLConstants {
|
||||
* for example, org.xml.sax.SAXException is thrown.
|
||||
*
|
||||
* <p>
|
||||
* <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
|
||||
* {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
|
||||
* separated by colon.
|
||||
* A scheme is defined as:
|
||||
*
|
||||
* <blockquote>
|
||||
* scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
|
||||
* where alpha = a-z and A-Z.<br><br>
|
||||
*
|
||||
* And the JAR protocol:<br>
|
||||
*
|
||||
* jar[:scheme]<br><br>
|
||||
*
|
||||
* Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
|
||||
* {@link java.lang.Character#isSpaceChar } in the value will be ignored.
|
||||
* Examples of protocols are file, http, jar:file.
|
||||
*
|
||||
* </blockquote>
|
||||
* <b>Value: </b> as defined in <a href="#EAP">the class description</a>.
|
||||
*
|
||||
* <p>
|
||||
* <b>Default value:</b> The default value is implementation specific and therefore not specified.
|
||||
* The following options are provided for consideration:
|
||||
* <blockquote>
|
||||
* <UL>
|
||||
* <LI>an empty string to deny all access to external references;</LI>
|
||||
* <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
|
||||
* <LI>the keyword "all" to grant permission to all protocols.</LI>
|
||||
* </UL><br>
|
||||
* When FEATURE_SECURE_PROCESSING is enabled, it is recommended that implementations
|
||||
* restrict external connections by default, though this may cause problems for applications
|
||||
* that process XML/XSD/XSL with external references.
|
||||
* </blockquote>
|
||||
* <b>System Property:</b> {@code javax.xml.accessExternalSchema}
|
||||
*
|
||||
* <p>
|
||||
* <b>Granting all access:</b> the keyword "all" grants permission to all protocols.
|
||||
*
|
||||
* <p>
|
||||
* <b>System Property:</b> The value of this property can be set or overridden by
|
||||
* system property {@code javax.xml.accessExternalSchema}
|
||||
*
|
||||
* <p>
|
||||
* <b>jaxp.properties:</b> This configuration file is in standard
|
||||
* {@link java.util.Properties} format and typically located in the {@code conf}
|
||||
* directory of the Java installation. If the file exists and the system
|
||||
* property is specified, its value will be used to override the default
|
||||
* of the property.
|
||||
*
|
||||
* <b>Configuration File:</b>
|
||||
* Yes. The property can be set in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#ConfigurationFile">configuration file</a>.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final String ACCESS_EXTERNAL_SCHEMA = "http://javax.xml.XMLConstants/property/accessExternalSchema";
|
||||
@ -326,52 +302,15 @@ public final class XMLConstants {
|
||||
* will be thrown by the {@link javax.xml.transform.TransformerFactory}.
|
||||
*
|
||||
* <p>
|
||||
* <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
|
||||
* {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
|
||||
* separated by colon.
|
||||
* A scheme is defined as:
|
||||
*
|
||||
* <blockquote>
|
||||
* scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
|
||||
* where alpha = a-z and A-Z.<br><br>
|
||||
*
|
||||
* And the JAR protocol:<br>
|
||||
*
|
||||
* jar[:scheme]<br><br>
|
||||
*
|
||||
* Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
|
||||
* {@link java.lang.Character#isSpaceChar } in the value will be ignored.
|
||||
* Examples of protocols are file, http, jar:file.
|
||||
*
|
||||
* </blockquote>
|
||||
* <b>Value: </b> as defined in <a href="#EAP">the class description</a>.
|
||||
*
|
||||
* <p>
|
||||
* <b>Default value:</b> The default value is implementation specific and therefore not specified.
|
||||
* The following options are provided for consideration:
|
||||
* <blockquote>
|
||||
* <UL>
|
||||
* <LI>an empty string to deny all access to external references;</LI>
|
||||
* <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
|
||||
* <LI>the keyword "all" to grant permission to all protocols.</LI>
|
||||
* </UL><br>
|
||||
* When FEATURE_SECURE_PROCESSING is enabled, it is recommended that implementations
|
||||
* restrict external connections by default, though this may cause problems for applications
|
||||
* that process XML/XSD/XSL with external references.
|
||||
* </blockquote>
|
||||
* <b>System Property:</b> {@code javax.xml.accessExternalStylesheet}
|
||||
*
|
||||
* <p>
|
||||
* <b>Granting all access:</b> the keyword "all" grants permission to all protocols.
|
||||
*
|
||||
* <p>
|
||||
* <b>System Property:</b> The value of this property can be set or overridden by
|
||||
* system property {@code javax.xml.accessExternalStylesheet}
|
||||
*
|
||||
* <p>
|
||||
* <b>jaxp.properties:</b> This configuration file is in standard
|
||||
* {@link java.util.Properties} format and typically located in the {@code conf}
|
||||
* directory of the Java installation. If the file exists and the system
|
||||
* property is specified, its value will be used to override the default
|
||||
* of the property.
|
||||
* <b>Configuration File:</b>
|
||||
* Yes. The property can be set in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#ConfigurationFile">configuration file</a>.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
@ -384,15 +323,15 @@ public final class XMLConstants {
|
||||
* <p>
|
||||
* Instructs XML processors to use XML Catalogs to resolve entity references.
|
||||
* Catalogs may be set through JAXP factories, system properties, or
|
||||
* jaxp.properties by using the {@code javax.xml.catalog.files} property
|
||||
* configuration file by using the {@code javax.xml.catalog.files} property
|
||||
* defined in {@link javax.xml.catalog.CatalogFeatures}.
|
||||
* The following code enables Catalog on SAX parser:
|
||||
* <pre>{@code
|
||||
* {@snippet :
|
||||
* SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
* spf.setFeature(XMLConstants.USE_CATALOG, true);
|
||||
* SAXParser parser = spf.newSAXParser();
|
||||
* parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "catalog.xml");
|
||||
* }</pre>
|
||||
* }
|
||||
*
|
||||
* <p>
|
||||
* <b>Value:</b> a boolean. If the value is true, and a catalog is set,
|
||||
@ -401,15 +340,12 @@ public final class XMLConstants {
|
||||
* XML Catalog is ignored even if one is set. The default value is true.
|
||||
*
|
||||
* <p>
|
||||
* <b>System Property:</b> The value of this property can be set or overridden by
|
||||
* system property {@code javax.xml.useCatalog}
|
||||
* <b>System Property:</b> {@code javax.xml.useCatalog}
|
||||
*
|
||||
* <p>
|
||||
* <b>jaxp.properties:</b> This configuration file is in standard
|
||||
* {@link java.util.Properties} format and typically located in the {@code conf}
|
||||
* directory of the Java installation. If the file exists and the system
|
||||
* property is specified, its value will be used to override the default
|
||||
* value of the property.
|
||||
* <b>Configuration File:</b>
|
||||
* Yes. The property can be set in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#ConfigurationFile">configuration file</a>.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,8 +24,6 @@
|
||||
*/
|
||||
package javax.xml.catalog;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import jdk.xml.internal.SecuritySupport;
|
||||
@ -42,7 +40,6 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* <th scope="col" rowspan="2">Description</th>
|
||||
* <th scope="col" rowspan="2">Property Name</th>
|
||||
* <th scope="col" rowspan="2">System Property [1]</th>
|
||||
* <th scope="col" rowspan="2">jaxp.properties [1]</th>
|
||||
* <th scope="col" colspan="2" style="text-align:center">Value [2]</th>
|
||||
* <th scope="col" rowspan="2">Action</th>
|
||||
* </tr>
|
||||
@ -61,7 +58,6 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* </td>
|
||||
* <td>javax.xml.catalog.files</td>
|
||||
* <td>javax.xml.catalog.files</td>
|
||||
* <td>javax.xml.catalog.files</td>
|
||||
* <td>String</td>
|
||||
* <th id="URIs" scope="row" style="font-weight:normal">URIs</th>
|
||||
* <td>
|
||||
@ -76,7 +72,6 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* identifiers. The default value is public [3].</td>
|
||||
* <td rowspan="2">javax.xml.catalog.prefer</td>
|
||||
* <td rowspan="2">N/A</td>
|
||||
* <td rowspan="2">N/A</td>
|
||||
* <td rowspan="2">String</td>
|
||||
* <th scope="row" id="system" style="font-weight:normal">{@code system}</th>
|
||||
* <td>
|
||||
@ -97,7 +92,6 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* needed. The default value is true.</td>
|
||||
* <td rowspan="2">javax.xml.catalog.defer [4]</td>
|
||||
* <td rowspan="2">javax.xml.catalog.defer</td>
|
||||
* <td rowspan="2">javax.xml.catalog.defer</td>
|
||||
* <td rowspan="2">String</td>
|
||||
* <th scope="row" id="true" style="font-weight:normal">{@code true}</th>
|
||||
* <td>
|
||||
@ -116,7 +110,6 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* all of the specified catalogs are exhausted. The default is strict.</td>
|
||||
* <td rowspan="3">javax.xml.catalog.resolve [4]</td>
|
||||
* <td rowspan="3">javax.xml.catalog.resolve</td>
|
||||
* <td rowspan="3">javax.xml.catalog.resolve</td>
|
||||
* <td rowspan="3">String</td>
|
||||
* <th scope="row" id="strict" style="font-weight:normal">{@code strict}</th>
|
||||
* <td>
|
||||
@ -140,7 +133,6 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* </table>
|
||||
* <p>
|
||||
* <b>[1]</b> There is no System property for the features that marked as "N/A".
|
||||
*
|
||||
* <p>
|
||||
* <b>[2]</b> The value shall be exactly as listed in this table, case-sensitive.
|
||||
* Any unspecified value will result in {@link IllegalArgumentException}.
|
||||
@ -164,33 +156,22 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* set the property {@code javax.xml.catalog.defer} to false to allow the entire
|
||||
* catalog to be pre-loaded.
|
||||
*
|
||||
* <h2>Scope and Order</h2>
|
||||
* Features and properties can be set through the catalog file, the Catalog API,
|
||||
* system properties, and {@code jaxp.properties}, with a preference in the same order.
|
||||
* <p>
|
||||
* Properties that are specified as attributes in the catalog file for the
|
||||
* catalog and group entries shall take preference over any of the other settings.
|
||||
* <h2>Property Precedence</h2>
|
||||
* The Catalog Features follow the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#PP">Property Precedence</a>
|
||||
* as described in the module summary with regards to the priority with which
|
||||
* their values are retrieved from the various configuration sources such as the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#Conf_CF">JAXP configuration file</a>,
|
||||
* system and API properties. In addition to the general configuration sources,
|
||||
* the Catalog Features are further supported in the catalog file itself where
|
||||
* they can be specified as attributes of the catalog and group entries. When the
|
||||
* attributes are specified, they shall take preference over any of the other
|
||||
* configuration sources.
|
||||
* For example, if a {@code prefer} attribute is set in the catalog file as in
|
||||
* {@code <catalog prefer="public">}, any other input for the "prefer" property
|
||||
* is not necessary or will be ignored.
|
||||
* <p>
|
||||
* Properties set through the Catalog API override those that may have been set
|
||||
* by system properties and/or in {@code jaxp.properties}. In case of multiple
|
||||
* interfaces, the latest in a procedure shall take preference. For
|
||||
* {@link Feature#FILES}, this means that the URI(s) specified through the methods
|
||||
* of the {@link CatalogManager} will override any that may have been entered
|
||||
* through the {@link Builder}.
|
||||
*
|
||||
* <p>
|
||||
* System properties when set shall override those in {@code jaxp.properties}.
|
||||
* <p>
|
||||
* The {@code jaxp.properties} file is typically in the conf directory of the Java
|
||||
* installation. The file is read only once by the JAXP implementation and
|
||||
* its values are then cached for future use. If the file does not exist
|
||||
* when the first attempt is made to read from it, no further attempts are
|
||||
* made to check for its existence. It is not possible to change the value
|
||||
* of any properties in {@code jaxp.properties} after it has been read.
|
||||
* <p>
|
||||
* A CatalogFeatures instance can be created through its builder as illustrated
|
||||
* in the following sample code:
|
||||
* <pre>{@code
|
||||
@ -489,7 +470,7 @@ public class CatalogFeatures {
|
||||
|
||||
/**
|
||||
* States of the settings of a property, in the order: default value,
|
||||
* jaxp.properties file, jaxp system properties, and jaxp api properties
|
||||
* configuration file, jaxp system properties, and jaxp api properties
|
||||
*/
|
||||
static enum State {
|
||||
/** represents the default state of a feature. */
|
||||
@ -622,7 +603,7 @@ public class CatalogFeatures {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = SecuritySupport.readJAXPProperty(sysPropertyName);
|
||||
value = SecuritySupport.readConfig(sysPropertyName);
|
||||
if (value != null && !value.isEmpty()) {
|
||||
setProperty(cf, State.JAXPDOTPROPERTIES, value);
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,7 +33,7 @@
|
||||
* The Catalog API defines a standard solution for resolving external resources
|
||||
* referenced by XML documents. It is fully supported by the XML Processors
|
||||
* allowing application developers to configure a catalog through an XML processor
|
||||
* or system property or the jaxp.properties file to take advantage of the feature.
|
||||
* or system property or the configuration file to take advantage of the feature.
|
||||
* <p>
|
||||
* The XML Catalog API defines the following interfaces:
|
||||
* <ul>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,11 +25,9 @@
|
||||
|
||||
package javax.xml.datatype;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
@ -51,17 +49,6 @@ class FactoryFinder {
|
||||
*/
|
||||
private static boolean debug = false;
|
||||
|
||||
/**
|
||||
* Cache for properties in java.home/conf/jaxp.properties
|
||||
*/
|
||||
private final static Properties cacheProps = new Properties();
|
||||
|
||||
/**
|
||||
* Flag indicating if properties from java.home/conf/jaxp.properties
|
||||
* have been cached.
|
||||
*/
|
||||
private static volatile boolean firstTime = true;
|
||||
|
||||
// Define system property "jaxp.debug" to get output
|
||||
static {
|
||||
// Use try/catch block to support applets, which throws
|
||||
@ -233,31 +220,10 @@ class FactoryFinder {
|
||||
if (debug) se.printStackTrace();
|
||||
}
|
||||
|
||||
// try to read from $java.home/conf/jaxp.properties
|
||||
try {
|
||||
if (firstTime) {
|
||||
synchronized (cacheProps) {
|
||||
if (firstTime) {
|
||||
String configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
|
||||
"conf" + File.separator + "jaxp.properties";
|
||||
File f = new File(configFile);
|
||||
firstTime = false;
|
||||
if (SecuritySupport.doesFileExist(f)) {
|
||||
dPrint(()->"Read properties file "+f);
|
||||
cacheProps.load(SecuritySupport.getFileInputStream(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String factoryClassName = cacheProps.getProperty(factoryId);
|
||||
|
||||
if (factoryClassName != null) {
|
||||
dPrint(()->"found in ${java.home}/conf/jaxp.properties, value=" + factoryClassName);
|
||||
return newInstance(type, factoryClassName, null, true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (debug) ex.printStackTrace();
|
||||
// try to read from the configuration file
|
||||
String factoryClassName = SecuritySupport.readConfig(factoryId);
|
||||
if (factoryClassName != null) {
|
||||
return newInstance(type, factoryClassName, null, true);
|
||||
}
|
||||
|
||||
// Try Jar Service Provider Mechanism
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,11 +25,9 @@
|
||||
|
||||
package javax.xml.parsers;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
@ -50,17 +48,6 @@ class FactoryFinder {
|
||||
*/
|
||||
private static boolean debug = false;
|
||||
|
||||
/**
|
||||
* Cache for properties in java.home/conf/jaxp.properties
|
||||
*/
|
||||
private static final Properties cacheProps = new Properties();
|
||||
|
||||
/**
|
||||
* Flag indicating if properties from java.home/conf/jaxp.properties
|
||||
* have been cached.
|
||||
*/
|
||||
static volatile boolean firstTime = true;
|
||||
|
||||
// Define system property "jaxp.debug" to get output
|
||||
static {
|
||||
// Use try/catch block to support applets, which throws
|
||||
@ -231,31 +218,10 @@ class FactoryFinder {
|
||||
if (debug) se.printStackTrace();
|
||||
}
|
||||
|
||||
// try to read from $java.home/conf/jaxp.properties
|
||||
try {
|
||||
if (firstTime) {
|
||||
synchronized (cacheProps) {
|
||||
if (firstTime) {
|
||||
String configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
|
||||
"conf" + File.separator + "jaxp.properties";
|
||||
File f = new File(configFile);
|
||||
firstTime = false;
|
||||
if (SecuritySupport.doesFileExist(f)) {
|
||||
dPrint(()->"Read properties file "+f);
|
||||
cacheProps.load(SecuritySupport.getFileInputStream(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String factoryClassName = cacheProps.getProperty(factoryId);
|
||||
|
||||
if (factoryClassName != null) {
|
||||
dPrint(()->"found in ${java.home}/conf/jaxp.properties, value=" + factoryClassName);
|
||||
return newInstance(type, factoryClassName, null, true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (debug) ex.printStackTrace();
|
||||
// try to read from the configuration file
|
||||
String factoryClassName = SecuritySupport.readConfig(factoryId);
|
||||
if (factoryClassName != null) {
|
||||
return newInstance(type, factoryClassName, null, true);
|
||||
}
|
||||
|
||||
// Try Jar Service Provider Mechanism
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,11 +25,9 @@
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
@ -52,17 +50,6 @@ class FactoryFinder {
|
||||
*/
|
||||
private static boolean debug = false;
|
||||
|
||||
/**
|
||||
* Cache for properties in java.home/conf/jaxp.properties
|
||||
*/
|
||||
final private static Properties cacheProps = new Properties();
|
||||
|
||||
/**
|
||||
* Flag indicating if properties from java.home/conf/jaxp.properties
|
||||
* have been cached.
|
||||
*/
|
||||
private static volatile boolean firstTime = true;
|
||||
|
||||
// Define system property "jaxp.debug" to get output
|
||||
static {
|
||||
// Use try/catch block to support applets, which throws
|
||||
@ -266,43 +253,10 @@ class FactoryFinder {
|
||||
"Failed to read factoryId '" + factoryId + "'", se);
|
||||
}
|
||||
|
||||
// Try read $java.home/conf/stax.properties followed by
|
||||
// $java.home/conf/jaxp.properties if former not present
|
||||
String configFile = null;
|
||||
try {
|
||||
if (firstTime) {
|
||||
synchronized (cacheProps) {
|
||||
if (firstTime) {
|
||||
configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
|
||||
"conf" + File.separator + "stax.properties";
|
||||
final File fStax = new File(configFile);
|
||||
firstTime = false;
|
||||
if (SecuritySupport.doesFileExist(fStax)) {
|
||||
dPrint(()->"Read properties file "+fStax);
|
||||
cacheProps.load(SecuritySupport.getFileInputStream(fStax));
|
||||
}
|
||||
else {
|
||||
configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
|
||||
"conf" + File.separator + "jaxp.properties";
|
||||
final File fJaxp = new File(configFile);
|
||||
if (SecuritySupport.doesFileExist(fJaxp)) {
|
||||
dPrint(()->"Read properties file "+fJaxp);
|
||||
cacheProps.load(SecuritySupport.getFileInputStream(fJaxp));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String factoryClassName = cacheProps.getProperty(factoryId);
|
||||
|
||||
if (factoryClassName != null) {
|
||||
final String foundIn = configFile;
|
||||
dPrint(()->"found in " + foundIn + " value=" + factoryClassName);
|
||||
return newInstance(type, factoryClassName, cl, true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (debug) ex.printStackTrace();
|
||||
// try to read from the configuration file
|
||||
String factoryClassName = SecuritySupport.readConfig(factoryId, true);
|
||||
if (factoryClassName != null) {
|
||||
return newInstance(type, factoryClassName, cl, true);
|
||||
}
|
||||
|
||||
if (type.getName().equals(factoryId)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -82,7 +82,7 @@ public abstract class XMLEventFactory {
|
||||
|
||||
/**
|
||||
* Creates a new instance of the factory. This method uses the
|
||||
* <a href="../../../module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>
|
||||
* to determine the {@code XMLEventFactory} implementation class to load.
|
||||
* <p>
|
||||
* Once an application has obtained a reference to a {@code XMLEventFactory}, it
|
||||
@ -134,23 +134,10 @@ public abstract class XMLEventFactory {
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
* Use the configuration file "stax.properties". The file is in standard
|
||||
* {@link java.util.Properties} format and typically located in the
|
||||
* conf directory of the Java installation. It contains the fully qualified
|
||||
* name of the implementation class with the key being the system property
|
||||
* defined above.
|
||||
*
|
||||
* <p>
|
||||
* The stax.properties file is read only once by the implementation
|
||||
* and its values are then cached for future use. If the file does not exist
|
||||
* when the first attempt is made to read from it, no further attempts are
|
||||
* made to check for its existence. It is not possible to change the value
|
||||
* of any property in stax.properties after it has been read for the first time.
|
||||
*
|
||||
* <p>
|
||||
* Use the jaxp configuration file "jaxp.properties". The file is in the same
|
||||
* format as stax.properties and will only be read if stax.properties does
|
||||
* not exist.
|
||||
* Use the value of the property {@code factoryId} set in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#ConfigurationFile">configuration file</a>,
|
||||
* jaxp.properties by default. If the file exists and the property {@code factoryId}
|
||||
* is specified in the file, its value will be used as the implementation class.
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
|
@ -168,7 +168,7 @@ public abstract class XMLInputFactory {
|
||||
|
||||
/**
|
||||
* Creates a new instance of the factory. This method uses the
|
||||
* <a href="../../../module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>
|
||||
* to determine the {@code XMLInputFactory} implementation class to load.
|
||||
* <p>
|
||||
* Once an application has obtained a reference to a {@code XMLInputFactory}, it
|
||||
@ -221,23 +221,10 @@ public abstract class XMLInputFactory {
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
* Use the configuration file "stax.properties". The file is in standard
|
||||
* {@link java.util.Properties} format and typically located in the
|
||||
* {@code conf} directory of the Java installation. It contains the fully qualified
|
||||
* name of the implementation class with the key being the system property
|
||||
* defined above.
|
||||
*
|
||||
* <p>
|
||||
* The stax.properties file is read only once by the implementation
|
||||
* and its values are then cached for future use. If the file does not exist
|
||||
* when the first attempt is made to read from it, no further attempts are
|
||||
* made to check for its existence. It is not possible to change the value
|
||||
* of any property in stax.properties after it has been read for the first time.
|
||||
*
|
||||
* <p>
|
||||
* Use the jaxp configuration file "jaxp.properties". The file is in the same
|
||||
* format as stax.properties and will only be read if stax.properties does
|
||||
* not exist.
|
||||
* Use the value of the property {@code factoryId} set in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#ConfigurationFile">configuration file</a>,
|
||||
* jaxp.properties by default. If the file exists and the property {@code factoryId}
|
||||
* is specified in the file, its value will be used as the implementation class.
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
|
@ -145,7 +145,7 @@ public abstract class XMLOutputFactory {
|
||||
|
||||
/**
|
||||
* Creates a new instance of the factory. This method uses the
|
||||
* <a href="../../../module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>
|
||||
* to determine the {@code XMLOutputFactory} implementation class to load.
|
||||
* <p>
|
||||
* Once an application has obtained a reference to a {@code XMLOutputFactory}, it
|
||||
@ -196,23 +196,10 @@ public abstract class XMLOutputFactory {
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
* Use the configuration file "stax.properties". The file is in standard
|
||||
* {@link java.util.Properties} format and typically located in the
|
||||
* {@code conf} directory of the Java installation. It contains the fully qualified
|
||||
* name of the implementation class with the key being the system property
|
||||
* defined above.
|
||||
*
|
||||
* <p>
|
||||
* The stax.properties file is read only once by the implementation
|
||||
* and its values are then cached for future use. If the file does not exist
|
||||
* when the first attempt is made to read from it, no further attempts are
|
||||
* made to check for its existence. It is not possible to change the value
|
||||
* of any property in stax.properties after it has been read for the first time.
|
||||
*
|
||||
* <p>
|
||||
* Use the jaxp configuration file "jaxp.properties". The file is in the same
|
||||
* format as stax.properties and will only be read if stax.properties does
|
||||
* not exist.
|
||||
* Use the value of the property {@code factoryId} set in the
|
||||
* <a href="{@docRoot}/java.xml/module-summary.html#ConfigurationFile">configuration file</a>,
|
||||
* jaxp.properties by default. If the file exists and the property {@code factoryId}
|
||||
* is specified in the file, its value will be used as the implementation class.
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,13 +25,9 @@
|
||||
|
||||
package javax.xml.transform;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
@ -53,17 +49,6 @@ class FactoryFinder {
|
||||
*/
|
||||
private static boolean debug = false;
|
||||
|
||||
/**
|
||||
* Cache for properties in java.home/conf/jaxp.properties
|
||||
*/
|
||||
private final static Properties cacheProps = new Properties();
|
||||
|
||||
/**
|
||||
* Flag indicating if properties from java.home/conf/jaxp.properties
|
||||
* have been cached.
|
||||
*/
|
||||
static volatile boolean firstTime = true;
|
||||
|
||||
// Define system property "jaxp.debug" to get output
|
||||
static {
|
||||
// Use try/catch block to support applets, which throws
|
||||
@ -217,31 +202,10 @@ class FactoryFinder {
|
||||
if (debug) se.printStackTrace();
|
||||
}
|
||||
|
||||
// try to read from $java.home/conf/jaxp.properties
|
||||
try {
|
||||
if (firstTime) {
|
||||
synchronized (cacheProps) {
|
||||
if (firstTime) {
|
||||
String configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
|
||||
"conf" + File.separator + "jaxp.properties";
|
||||
File f = new File(configFile);
|
||||
firstTime = false;
|
||||
if (SecuritySupport.doesFileExist(f)) {
|
||||
dPrint(()->"Read properties file "+f);
|
||||
cacheProps.load(SecuritySupport.getFileInputStream(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String factoryClassName = cacheProps.getProperty(factoryId);
|
||||
|
||||
if (factoryClassName != null) {
|
||||
dPrint(()->"found in ${java.home}/conf/jaxp.properties, value=" + factoryClassName);
|
||||
return newInstance(type, factoryClassName, null, true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (debug) ex.printStackTrace();
|
||||
// try to read from the configuration file
|
||||
String factoryClassName = SecuritySupport.readConfig(factoryId);
|
||||
if (factoryClassName != null) {
|
||||
return newInstance(type, factoryClassName, null, true);
|
||||
}
|
||||
|
||||
// Try Jar Service Provider Mechanism
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,14 +26,10 @@
|
||||
package javax.xml.validation;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
@ -51,15 +47,6 @@ class SchemaFactoryFinder {
|
||||
private static boolean debug = false;
|
||||
|
||||
private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
|
||||
/**
|
||||
* <p>Cache properties for performance.</p>
|
||||
*/
|
||||
private static final Properties cacheProps = new Properties();
|
||||
|
||||
/**
|
||||
* <p>First time requires initialization overhead.</p>
|
||||
*/
|
||||
private static volatile boolean firstTime = true;
|
||||
|
||||
static {
|
||||
// Use try/catch block to support applets
|
||||
@ -179,37 +166,12 @@ class SchemaFactoryFinder {
|
||||
}
|
||||
}
|
||||
|
||||
String javah = SecuritySupport.getSystemProperty( "java.home" );
|
||||
String configFile = javah + File.separator +
|
||||
"conf" + File.separator + "jaxp.properties";
|
||||
|
||||
|
||||
// try to read from $java.home/conf/jaxp.properties
|
||||
try {
|
||||
if(firstTime){
|
||||
synchronized(cacheProps){
|
||||
if(firstTime){
|
||||
File f=new File( configFile );
|
||||
firstTime = false;
|
||||
if(SecuritySupport.doesFileExist(f)){
|
||||
debugPrintln(()->"Read properties file " + f);
|
||||
cacheProps.load(SecuritySupport.getFileInputStream(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String factoryClassName = cacheProps.getProperty(propertyName);
|
||||
debugPrintln(()->"found " + factoryClassName + " in $java.home/conf/jaxp.properties");
|
||||
|
||||
if (factoryClassName != null) {
|
||||
sf = createInstance(factoryClassName);
|
||||
if(sf != null){
|
||||
return sf;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (debug) {
|
||||
ex.printStackTrace();
|
||||
// try to read from the configuration file
|
||||
String factoryClassName = SecuritySupport.readConfig(propertyName);
|
||||
if (factoryClassName != null) {
|
||||
sf = createInstance(factoryClassName);
|
||||
if(sf != null){
|
||||
return sf;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package javax.xml.xpath;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
@ -174,36 +173,11 @@ class XPathFactoryFinder {
|
||||
}
|
||||
}
|
||||
|
||||
String javah = SecuritySupport.getSystemProperty( "java.home" );
|
||||
String configFile = javah + File.separator +
|
||||
"conf" + File.separator + "jaxp.properties";
|
||||
|
||||
// try to read from $java.home/conf/jaxp.properties
|
||||
try {
|
||||
if(firstTime){
|
||||
synchronized(cacheProps){
|
||||
if(firstTime){
|
||||
File f=new File( configFile );
|
||||
firstTime = false;
|
||||
if(SecuritySupport.doesFileExist(f)){
|
||||
debugPrintln(()->"Read properties file " + f);
|
||||
cacheProps.load(SecuritySupport.getFileInputStream(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String factoryClassName = cacheProps.getProperty(propertyName);
|
||||
debugPrintln(()->"found " + factoryClassName + " in $java.home/conf/jaxp.properties");
|
||||
|
||||
if (factoryClassName != null) {
|
||||
xpathFactory = createInstance(factoryClassName);
|
||||
if(xpathFactory != null){
|
||||
return xpathFactory;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (debug) {
|
||||
ex.printStackTrace();
|
||||
String factoryClassName = SecuritySupport.readConfig(propertyName);
|
||||
if (factoryClassName != null) {
|
||||
xpathFactory = createInstance(factoryClassName);
|
||||
if(xpathFactory != null){
|
||||
return xpathFactory;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -283,6 +283,12 @@ public final class JdkConstants {
|
||||
public static final String XML_SECURITY_PROPERTY_MANAGER =
|
||||
"jdk.xml.xmlSecurityPropertyManager";
|
||||
|
||||
/**
|
||||
* System Property for the Configuration File
|
||||
* @since 21
|
||||
*/
|
||||
public static final String CONFIG_FILE = "java.xml.config.file";
|
||||
|
||||
/**
|
||||
* Values for a feature
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -407,7 +407,7 @@ public class JdkXmlFeatures {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = SecuritySupport.readJAXPProperty(sysPropertyName);
|
||||
value = SecuritySupport.readConfig(sysPropertyName);
|
||||
if (value != null && !value.isEmpty()) {
|
||||
setFeature(feature, State.JAXPDOTPROPERTIES, Boolean.parseBoolean(value));
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,6 +30,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.AccessController;
|
||||
import java.security.CodeSource;
|
||||
import java.security.PrivilegedAction;
|
||||
@ -159,47 +160,87 @@ public class SecuritySupport {
|
||||
public static String getJAXPSystemProperty(String propName) {
|
||||
String value = getSystemProperty(propName);
|
||||
if (value == null) {
|
||||
value = readJAXPProperty(propName);
|
||||
value = readConfig(propName);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the specified property from $java.home/conf/jaxp.properties
|
||||
* Returns the value of the specified property from the Configuration file.
|
||||
* The method reads the System Property "java.xml.config.file" for a custom
|
||||
* configuration file, if doesn't exist, falls back to the JDK default that
|
||||
* is typically located at $java.home/conf/jaxp.properties.
|
||||
*
|
||||
* @param propName the name of the property
|
||||
* @return the value of the property
|
||||
* @param propName the specified property
|
||||
* @return the value of the specified property, null if the property is not
|
||||
* found
|
||||
*/
|
||||
public static String readJAXPProperty(String propName) {
|
||||
String value = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
if (firstTime) {
|
||||
synchronized (cacheProps) {
|
||||
if (firstTime) {
|
||||
String configFile = getSystemProperty("java.home") + File.separator
|
||||
+ "conf" + File.separator + "jaxp.properties";
|
||||
File f = new File(configFile);
|
||||
if (isFileExists(f)) {
|
||||
is = getFileInputStream(f);
|
||||
cacheProps.load(is);
|
||||
}
|
||||
firstTime = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
value = cacheProps.getProperty(propName);
|
||||
public static String readConfig(String propName) {
|
||||
return readConfig(propName, false);
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException ex) {}
|
||||
/**
|
||||
* Returns the value of the specified property from the Configuration file.
|
||||
* The method reads the JDK default configuration that is typically located
|
||||
* at $java.home/conf/jaxp.properties. On top of the default, if the System
|
||||
* Property "java.xml.config.file" exists, the configuration file it points
|
||||
* to will also be read. Any settings in it will then override those in the
|
||||
* default.
|
||||
*
|
||||
* @param propName the specified property
|
||||
* @param stax a flag indicating whether to read stax.properties
|
||||
* @return the value of the specified property, null if the property is not
|
||||
* found
|
||||
*/
|
||||
public static String readConfig(String propName, boolean stax) {
|
||||
// always load the default configuration file
|
||||
if (firstTime) {
|
||||
synchronized (cacheProps) {
|
||||
if (firstTime) {
|
||||
boolean found = loadProperties(
|
||||
Paths.get(SecuritySupport.getSystemProperty("java.home"),
|
||||
"conf", "jaxp.properties")
|
||||
.toAbsolutePath().normalize().toString());
|
||||
|
||||
// attempts to find stax.properties only if jaxp.properties is not available
|
||||
if (stax && !found) {
|
||||
found = loadProperties(
|
||||
Paths.get(SecuritySupport.getSystemProperty("java.home"),
|
||||
"conf", "stax.properties")
|
||||
.toAbsolutePath().normalize().toString()
|
||||
);
|
||||
}
|
||||
|
||||
// load the custom configure on top of the default if any
|
||||
String configFile = SecuritySupport.getSystemProperty(JdkConstants.CONFIG_FILE);
|
||||
if (configFile != null) {
|
||||
loadProperties(configFile);
|
||||
}
|
||||
|
||||
firstTime = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
return cacheProps.getProperty(propName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the properties from the specified file into the cache.
|
||||
* @param file the specified file
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
private static boolean loadProperties(String file) {
|
||||
File f = new File(file);
|
||||
if (SecuritySupport.doesFileExist(f)) {
|
||||
try (final InputStream in = SecuritySupport.getFileInputStream(f)) {
|
||||
cacheProps.load(in);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
// shouldn't happen, but required by method getFileInputStream
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -535,22 +535,17 @@ public final class XMLSecurityManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from system properties, or those in jaxp.properties
|
||||
* Read system properties, or the configuration file
|
||||
*/
|
||||
private void readSystemProperties() {
|
||||
|
||||
for (Limit limit : Limit.values()) {
|
||||
if (!getSystemProperty(limit, limit.systemProperty())) {
|
||||
//if system property is not found, try the older form if any
|
||||
for (NameMap nameMap : NameMap.values()) {
|
||||
String oldName = nameMap.getOldName(limit.systemProperty());
|
||||
if (oldName != null) {
|
||||
getSystemProperty(limit, oldName);
|
||||
}
|
||||
}
|
||||
// attempts to read both the current and old system propery
|
||||
if (!getSystemProperty(limit, limit.systemProperty())
|
||||
&& (!getOldSystemProperty(limit))) {
|
||||
//if system property is not found, try the config file
|
||||
getPropertyConfig(limit, limit.systemProperty());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Array list to store printed warnings for each SAX parser used
|
||||
@ -571,9 +566,9 @@ public final class XMLSecurityManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from system properties, or those in jaxp.properties
|
||||
* Reads a system property, sets value and state if found.
|
||||
*
|
||||
* @param property the type of the property
|
||||
* @param limit the limit property
|
||||
* @param sysPropertyName the name of system property
|
||||
*/
|
||||
private boolean getSystemProperty(Limit limit, String sysPropertyName) {
|
||||
@ -584,8 +579,42 @@ public final class XMLSecurityManager {
|
||||
states[limit.ordinal()] = State.SYSTEMPROPERTY;
|
||||
return true;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
//invalid setting
|
||||
throw new NumberFormatException("Invalid setting for system property: " + limit.systemProperty());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
value = SecuritySupport.readJAXPProperty(sysPropertyName);
|
||||
/**
|
||||
* Reads the legacy system property.
|
||||
* @param limit a limit object
|
||||
* @return true if found, false otherwise
|
||||
*/
|
||||
private boolean getOldSystemProperty(Limit limit) {
|
||||
boolean found = false;
|
||||
for (NameMap nameMap : NameMap.values()) {
|
||||
String oldName = nameMap.getOldName(limit.systemProperty());
|
||||
if (oldName != null) {
|
||||
if (getSystemProperty(limit, oldName)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a property from a configuration file, if any.
|
||||
*
|
||||
* @param limit the limit property
|
||||
* @param sysPropertyName the name of system property
|
||||
* @return
|
||||
*/
|
||||
private boolean getPropertyConfig(Limit limit, String sysPropertyName) {
|
||||
try {
|
||||
String value = SecuritySupport.readConfig(sysPropertyName);
|
||||
if (value != null && !value.equals("")) {
|
||||
values[limit.ordinal()] = Integer.parseInt(value);
|
||||
states[limit.ordinal()] = State.JAXPDOTPROPERTIES;
|
||||
@ -598,7 +627,6 @@ public final class XMLSecurityManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a value set through setProperty to XMLSecurityManager.
|
||||
* If the value is an instance of XMLSecurityManager, use it to override the default;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,14 +24,222 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines the Java API for XML Processing (JAXP), the Streaming API for XML (StAX),
|
||||
* the Simple API for XML (SAX), and the W3C Document Object Model (DOM) API.
|
||||
* Defines the Java APIs for XML Processing (JAXP).
|
||||
*
|
||||
* <ul>
|
||||
* <li><a href="#JAXP">The JAXP APIs</a></li>
|
||||
* <li><a href="#FacPro">Factories and Processors</a></li>
|
||||
* <li><a href="#Conf">Configuration</a>
|
||||
* <ul>
|
||||
* <li><a href="#Conf_Properties">JAXP Properties</a></li>
|
||||
* <li><a href="#Conf_SystemProperties">System Properties</a></li>
|
||||
* <li><a href="#Conf_CF">Configuration File</a>
|
||||
* <ul>
|
||||
* <li><a href="#Conf_CF_Default">{@code jaxp.properties} File</a></li>
|
||||
* <li><a href="#Conf_CF_SP">User-defined Configuration File</a></li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li><a href="#PP">Property Precedence</a></li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li><a href="#LookupMechanism">JAXP Lookup Mechanism</a>
|
||||
* <ul>
|
||||
* <li><a href="#LookupProcedure">Lookup Procedure</a></li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li><a href="#implNote">Implementation Note</a></li>
|
||||
* </ul>
|
||||
*
|
||||
* <h2 id="JAXP">The JAXP APIs</h2>
|
||||
* JAXP comprises a set of APIs built upon a number of XML technologies and
|
||||
* standards that are essential for XML processing. These include APIs for:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Parsing: the {@link javax.xml.parsers JAXP Parsing API} based on
|
||||
* {@link org.w3c.dom Document Object Model (DOM)} and
|
||||
* {@link org.xml.sax Simple API for XML Parsing (SAX)}, and
|
||||
* {@link javax.xml.stream Streaming API for XML (StAX)};
|
||||
* </li>
|
||||
* <li>Serializing: StAX and
|
||||
* {@link javax.xml.transform Extensible Stylesheet Language Transformations (XSLT)};
|
||||
* </li>
|
||||
* <li>Validation: the {@link javax.xml.validation JAXP Validation API}
|
||||
* based on the XML Schema Definition Language;</li>
|
||||
* <li>Transformation: the {@link javax.xml.transform JAXP Transformation API}
|
||||
* or XSLT (Extensible Stylesheet Language Transformations);</li>
|
||||
* <li>Querying and traversing XML documents: the
|
||||
* {@link javax.xml.xpath XML XPath Language API (XPath)};</li>
|
||||
* <li>Resolving external resources: the {@link javax.xml.catalog XML Catalog API};</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h2 id="FacPro">Factories and Processors</h2>
|
||||
* Factories are the entry points of each API, providing methods to allow applications
|
||||
* to set <a href="#Conf_Properties">JAXP Properties</a> programmatically, before
|
||||
* creating processors. The <a href="#Conf">Configuration</a> section provides more
|
||||
* details on this. Factories also support the
|
||||
* <a href="#LookupMechanism">JAXP Lookup Mechanism</a>, in which applications can be
|
||||
* deployed with third party implementations to use instead of JDK implementations
|
||||
* <p>
|
||||
*
|
||||
* Processors are aggregates of parsers (or readers), serializers (or writers),
|
||||
* validators, and transformers that control and perform the processing in their
|
||||
* respective areas. They are defined in their relevant packages.
|
||||
* In the {@link javax.xml.parsers parsers} package for example,
|
||||
* are the {@link javax.xml.parsers.DocumentBuilder DocumentBuilder} and
|
||||
* {@link javax.xml.parsers.SAXParser SAXParser}, that represent the DOM and
|
||||
* SAX processors.
|
||||
* <p>
|
||||
* The processors are configured and instantiated with their corresponding factories.
|
||||
* The DocumentBuilder and SAXParser for example are constructed with the
|
||||
* {@link javax.xml.parsers.DocumentBuilderFactory DocumentBuilderFactory}
|
||||
* and {@link javax.xml.parsers.SAXParserFactory SAXParserFactory} respectively.
|
||||
*
|
||||
* <h2 id="Conf">Configuration</h2>
|
||||
* When a JAXP factory is invoked for the first time, it performs a configuration
|
||||
* process to determine the implementation to be used and its subsequent behaviors.
|
||||
* During configuration, the factory examines configuration sources such as the
|
||||
* <a href="#Conf_Properties">JAXP Properties</a>,
|
||||
* <a href="#Conf_SystemProperties">System Properties</a>,
|
||||
* and the <a href="#Conf_CF">JAXP Configuration File</a>, and sets the values
|
||||
* following the <a href="#PP">Property Precedence</a>. The terminologies and
|
||||
* process are defined below.
|
||||
*
|
||||
* <h3 id="Conf_Properties">JAXP Properties</h3>
|
||||
* JAXP properties are configuration settings that are applied to XML processors.
|
||||
* They can be used to control and customize the behavior of a processor.
|
||||
* Depending on the JAXP API that is being used, JAXP properties may be referred
|
||||
* to as <em>Attributes, Properties</em>, or <em>Features</em>.
|
||||
*
|
||||
* <h3 id="Conf_SystemProperties">System Properties</h3>
|
||||
* Select JAXP properties have corresponding System Properties allowing the properties
|
||||
* to be set at runtime, on the command line, or within the
|
||||
* <a href="#Conf_CF">JAXP Configuration File</a>.
|
||||
* For example, the System Property {@code javax.xml.catalog.resolve} may be used
|
||||
* to set the {@link javax.xml.catalog.CatalogFeatures CatalogFeatures}' RESOLVE
|
||||
* property.
|
||||
* <p>
|
||||
* The exact time at which system properties are read is unspecified. In order to
|
||||
* ensure that the desired values are properly applied, applications should ensure
|
||||
* that system properties are set appropriately prior to the creation of the first
|
||||
* JAXP factory and are not modified thereafter.
|
||||
*
|
||||
* <h3 id="Conf_CF">Configuration File</h3>
|
||||
* JAXP supports the use of configuration files for
|
||||
* <a href="#LookupMechanism">specifying the implementation class to load for the JAXP factories</a>
|
||||
* as well as for setting JAXP properties.
|
||||
* <p>
|
||||
* Configuration files are Java {@link java.util.Properties} files that consist
|
||||
* of mappings between system properties and their values defined by various APIs
|
||||
* or processes. The following configuration file entries demonstrate setting the
|
||||
* {@code javax.xml.parsers.DocumentBuilderFactory}
|
||||
* and {@code CatalogFeatures.RESOLVE} properties:
|
||||
*
|
||||
* {@snippet :
|
||||
* javax.xml.parsers.DocumentBuilderFactory=packagename.DocumentBuilderFactoryImpl
|
||||
* javax.xml.catalog.resolve=strict
|
||||
* }
|
||||
*
|
||||
* <h4 id="Conf_CF_Default">{@code jaxp.properties} File</h4>
|
||||
* By default, JAXP looks for the configuration file {@code jaxp.properties},
|
||||
* located in the ${java.home}/conf directory; and if the file exists, loads the
|
||||
* specified properties to customize the behavior of the XML factories and processors.
|
||||
* <p>
|
||||
* The {@code jaxp.properties} file will be read only once during the initialization
|
||||
* of the JAXP implementation and cached in memory. If there is an error accessing
|
||||
* or reading the file, the configuration process proceeds as if the file does not exist.
|
||||
*
|
||||
* <h4 id="Conf_CF_SP">User-defined Configuration File</h4>
|
||||
* In addition to the {@code jaxp.properties} file, the system property
|
||||
* {@systemProperty java.xml.config.file} can be set to specify the location of
|
||||
* a configuration file. If the {@code java.xml.config.file} property is included
|
||||
* within a configuration file, it will be ignored.
|
||||
*
|
||||
* <p>
|
||||
* When the {@code java.xml.config.file} is specified, the configuration file will be
|
||||
* read and the included properties will override the same properties that were
|
||||
* defined in the {@code jaxp.properties} file. If the {@code java.xml.config.file}
|
||||
* has not been set when the JAXP implementation is initialized, no further attempt
|
||||
* will be made to check for its existence.
|
||||
* <p>
|
||||
* The {@code java.xml.config.file} value must contain a valid pathname
|
||||
* to a configuration file. If the pathname is not absolute, it will be considered
|
||||
* relative to the working directory of the JVM.
|
||||
* If there is an error reading the configuration file, the configuration process
|
||||
* proceeds as if the {@code java.xml.config.file} property was not set.
|
||||
* Implementations may optionally issue a warning message.
|
||||
*
|
||||
* <h3 id="PP">Property Precedence</h3>
|
||||
* JAXP properties can be set in multiple ways, including by API methods, system
|
||||
* properties, and the <a href="#Conf_CF">JAXP Configuration File</a>. When not
|
||||
* explicitly set, they will be initialized with default values or more restrictive
|
||||
* values when
|
||||
* {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING FEATURE_SECURE_PROCESSING}
|
||||
* (FSP) is enabled. The configuration order of precedence for properties is as
|
||||
* follows, from highest to lowest:
|
||||
*
|
||||
* <ul>
|
||||
* <li><p>
|
||||
* The APIs for factories or processors
|
||||
* </li>
|
||||
* <li><p>
|
||||
* System Property
|
||||
* </li>
|
||||
* <li><p>
|
||||
* User-defined <a href="#Conf_CF">Configuration File</a>
|
||||
* </li>
|
||||
* <li><p>
|
||||
* The default JAXP Configuration File <a href="#Conf_CF_Default">{@code jaxp.properties}</a>
|
||||
* </li>
|
||||
* <li><p>
|
||||
* The default values for JAXP Properties. If the
|
||||
* {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING FSP} is true,
|
||||
* the default values will be set to process XML securely.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* Using the {@link javax.xml.catalog.CatalogFeatures CatalogFeatures}' RESOLVE
|
||||
* property as an example, the following illustrates how these rules are applied:
|
||||
* <ul>
|
||||
* <li><p>
|
||||
* Properties specified with factory or processor APIs have the highest
|
||||
* precedence. The following code effectively sets the RESOLVE property to
|
||||
* {@code strict}, regardless of settings in any other configuration sources.
|
||||
*
|
||||
* {@snippet :
|
||||
* DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
* dbf.setAttribute(CatalogFeatures.Feature.RESOLVE.getPropertyName(), "strict");
|
||||
* }
|
||||
*
|
||||
* </li>
|
||||
* <li><p>
|
||||
* If the property is not set on the factory as in the above code, a
|
||||
* system property setting will be in effect.
|
||||
* {@snippet :
|
||||
* // in the following example, the RESOLVE property is set to 'continue'
|
||||
* // for the entire application
|
||||
* java -Djavax.xml.catalog.resolve=continue myApp
|
||||
* }
|
||||
* </li>
|
||||
* <li><p>
|
||||
* If the property is not set on the factory, or using a system property,
|
||||
* the setting in a configuration file will take effect. The following entry
|
||||
* sets the property to '{@code continue}'.
|
||||
* {@snippet :
|
||||
* javax.xml.catalog.resolve=continue
|
||||
* }
|
||||
*
|
||||
* </li>
|
||||
* <li><p>
|
||||
* If the property is not set anywhere, it will be resolved to its
|
||||
* default value that is '{@code strict}'.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* <h2 id="LookupMechanism">JAXP Lookup Mechanism</h2>
|
||||
* JAXP defines an ordered lookup procedure to determine the implementation class
|
||||
* to load for the JAXP factories. Factories that support the mechanism are listed
|
||||
* in the table below along with the method, System Property name, Configuration
|
||||
* File, and System Default method to be used in the procedure.
|
||||
* in the table below along with the method, System Property, and System
|
||||
* Default method to be used in the procedure.
|
||||
*
|
||||
* <table class="plain" id="Factories">
|
||||
* <caption>JAXP Factories</caption>
|
||||
@ -39,8 +247,7 @@
|
||||
* <tr>
|
||||
* <th scope="col">Factory</th>
|
||||
* <th scope="col">Method</th>
|
||||
* <th scope="col">System Property Name</th>
|
||||
* <th scope="col">Configuration File</th>
|
||||
* <th scope="col">System Property</th>
|
||||
* <th scope="col">System Default</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
@ -52,7 +259,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.datatype.DatatypeFactory#newInstance() newInstance()}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.datatype.DatatypeFactory}</td>
|
||||
* <td style="text-align:center"><a href="#JaxpProperties">jaxp.properties</a></td>
|
||||
* <td style="text-align:center">{@link javax.xml.datatype.DatatypeFactory#newDefaultInstance() newDefaultInstance()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -61,7 +267,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.parsers.DocumentBuilderFactory#newInstance() newInstance()}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.parsers.DocumentBuilderFactory}</td>
|
||||
* <td style="text-align:center"><a href="#JaxpProperties">jaxp.properties</a></td>
|
||||
* <td style="text-align:center">{@link javax.xml.parsers.DocumentBuilderFactory#newDefaultInstance() newDefaultInstance()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -70,7 +275,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.parsers.SAXParserFactory#newInstance() newInstance()}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.parsers.SAXParserFactory}</td>
|
||||
* <td style="text-align:center"><a href="#JaxpProperties">jaxp.properties</a></td>
|
||||
* <td style="text-align:center">{@link javax.xml.parsers.SAXParserFactory#newDefaultInstance() newDefaultInstance()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -79,10 +283,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.stream.XMLEventFactory#newFactory() newFactory()}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.stream.XMLEventFactory}</td>
|
||||
* <td style="text-align:center">
|
||||
* <a href="#StAXProperties">stax.properties</a> and then
|
||||
* <a href="#JaxpProperties">jaxp.properties</a>
|
||||
* </td>
|
||||
* <td style="text-align:center">{@link javax.xml.stream.XMLEventFactory#newDefaultFactory() newDefaultFactory()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -91,10 +291,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.stream.XMLInputFactory#newFactory() newFactory()}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.stream.XMLInputFactory}</td>
|
||||
* <td style="text-align:center">
|
||||
* <a href="#StAXProperties">stax.properties</a> and then
|
||||
* <a href="#JaxpProperties">jaxp.properties</a>
|
||||
* </td>
|
||||
* <td style="text-align:center">{@link javax.xml.stream.XMLInputFactory#newDefaultFactory() newDefaultFactory()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -103,10 +299,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.stream.XMLOutputFactory#newFactory() newFactory()}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.stream.XMLOutputFactory}</td>
|
||||
* <td style="text-align:center">
|
||||
* <a href="#StAXProperties">stax.properties</a> and then
|
||||
* <a href="#JaxpProperties">jaxp.properties</a>
|
||||
* </td>
|
||||
* <td style="text-align:center">{@link javax.xml.stream.XMLOutputFactory#newDefaultFactory() newDefaultFactory()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -115,7 +307,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.transform.TransformerFactory#newInstance() newInstance()}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.transform.TransformerFactory}</td>
|
||||
* <td style="text-align:center"><a href="#JaxpProperties">jaxp.properties</a></td>
|
||||
* <td style="text-align:center">{@link javax.xml.transform.TransformerFactory#newDefaultInstance() newDefaultInstance()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -124,7 +315,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.validation.SchemaFactory#newInstance(java.lang.String) newInstance(schemaLanguage)}</td>
|
||||
* <td style="text-align:center">{@code javax.xml.validation.SchemaFactory:}<i>schemaLanguage</i>[1]</td>
|
||||
* <td style="text-align:center"><a href="#JaxpProperties">jaxp.properties</a></td>
|
||||
* <td style="text-align:center">{@link javax.xml.validation.SchemaFactory#newDefaultInstance() newDefaultInstance()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -133,7 +323,6 @@
|
||||
* </th>
|
||||
* <td style="text-align:center">{@link javax.xml.xpath.XPathFactory#newInstance(java.lang.String) newInstance(uri)}</td>
|
||||
* <td style="text-align:center">{@link javax.xml.xpath.XPathFactory#DEFAULT_PROPERTY_NAME DEFAULT_PROPERTY_NAME} + ":uri"[2]</td>
|
||||
* <td style="text-align:center"><a href="#JaxpProperties">jaxp.properties</a></td>
|
||||
* <td style="text-align:center">{@link javax.xml.xpath.XPathFactory#newDefaultInstance() newDefaultInstance()}</td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
@ -147,42 +336,21 @@
|
||||
* {@link javax.xml.xpath.XPathFactory#newInstance(java.lang.String) newInstance(uri)}
|
||||
* method.
|
||||
*
|
||||
* <h3 id="JaxpProperties">jaxp.properties</h3>
|
||||
* {@code jaxp.properties} is a configuration file in standard
|
||||
* {@link java.util.Properties} format and typically located in the {@code conf}
|
||||
* directory of the Java installation. It contains the fully qualified
|
||||
* name of the implementation class with the key being the system property name
|
||||
* defined in <a href="#Factories">the table</a> above.
|
||||
* <p>
|
||||
* The {@code jaxp.properties} file is read only once by the implementation and
|
||||
* the values are then cached for future use. If the file does not exist when
|
||||
* the first attempt is made to read from it, no further attempts
|
||||
* are made to check for its existence. It is not possible to change the value
|
||||
* of any property after it has been read for the first time.
|
||||
*
|
||||
* <h3 id="StAXProperties">stax.properties</h3>
|
||||
* {@code stax.properties} is a configuration file that functions the same as
|
||||
* {@code jaxp.properties} except that it is only used by StAX factory lookup.
|
||||
*
|
||||
* <h3 id="LookupProcedure">Lookup Procedure</h3>
|
||||
* The <a href="#Factories">JAXP Factories</a> follow the procedure described
|
||||
* below in order to locate and load the implementation class:
|
||||
*
|
||||
* The order of precedence for locating the implementation class of a
|
||||
* <a href="#Factories">JAXP Factory</a> is as follows, from highest to lowest:
|
||||
* <ul>
|
||||
* <li>
|
||||
* Use the system property as described in column System Property of the table
|
||||
* <a href="#Factories">JAXP Factories</a> above.
|
||||
* The system property as listed in the column System Property of the table
|
||||
* <a href="#Factories">JAXP Factories</a> above
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
* Use the configuration file <a href="#JaxpProperties">jaxp.properties</a> as
|
||||
* indicated in the table <a href="#Factories">JAXP Factories</a>. For StAX,
|
||||
* if <a href="#StAXProperties">stax.properties</a> exists, the factories will
|
||||
* first attempt to read from it instead of <a href="#JaxpProperties">jaxp.properties</a>.
|
||||
* The <a href="#Conf_CF">Configuration File</a>
|
||||
* </li>
|
||||
* <li>
|
||||
* <p>
|
||||
* Use the service-provider loading facility, defined by the
|
||||
* The service-provider loading facility, defined by the
|
||||
* {@link java.util.ServiceLoader} class, to attempt to locate and load an
|
||||
* implementation of the service using the {@linkplain
|
||||
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}:
|
||||
@ -229,87 +397,34 @@
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <div id="implNote"></div>
|
||||
* @implNote
|
||||
* <h2>Implementation Specific Features and Properties</h2>
|
||||
*
|
||||
* In addition to the standard features and properties described within the public
|
||||
* APIs of this module, the JDK implementation supports a further number of
|
||||
* implementation specific features and properties. This section describes the
|
||||
* naming convention, System Properties, jaxp.properties, scope and order,
|
||||
* and processors to which a property applies. A table listing the implementation
|
||||
* specific features and properties which the implementation currently supports
|
||||
* can be found at the end of this note.
|
||||
* <ul>
|
||||
* <li><a href="#IN_ISFP">Implementation Specific Properties</a>
|
||||
* <ul>
|
||||
* <li><a href="#Processor">Processor Support</a></li>
|
||||
* <li><a href="#IN_ISFPtable">List of Implementation Specific Properties</a></li>
|
||||
* <li><a href="#IN_Legacy">Legacy Property Names (deprecated)</a></li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3 id="NamingConvention">Naming Convention</h3>
|
||||
* The names of the features and properties are fully qualified, composed of a
|
||||
* prefix and name.
|
||||
*
|
||||
* <h4>Prefix</h4>
|
||||
* The prefix for JDK features and properties, as well as their corresponding
|
||||
* System Properties if any, is defined as:
|
||||
* <pre>
|
||||
* {@code jdk.xml.}
|
||||
* </pre>
|
||||
*
|
||||
* <h4>Name</h4>
|
||||
* A name may consist of one or multiple words that are case-sensitive.
|
||||
* All letters of the first word are in lowercase, while the first letter of
|
||||
* each subsequent word is capitalized.
|
||||
* <h2 id="IN_ISFP">Implementation Specific Properties</h2>
|
||||
* In addition to the standard <a href="#Conf_Properties">JAXP Properties</a>,
|
||||
* the JDK implementation supports a number of implementation specific properties
|
||||
* whose name is prefixed by "{@code jdk.xml.}". These properties also follow the
|
||||
* configuration process as defined in the <a href="#Conf">Configuration</a> section.
|
||||
* <p>
|
||||
* An example of a property that indicates whether an XML document is standalone
|
||||
* would thus have a format:
|
||||
* <pre>
|
||||
* {@code jdk.xml.isStandalone}
|
||||
* </pre>
|
||||
* and a corresponding System Property:
|
||||
* <pre>
|
||||
* {@systemProperty jdk.xml.isStandalone}
|
||||
* </pre>
|
||||
*
|
||||
* <h3>System Properties</h3>
|
||||
* A property may have a corresponding System Property with the same name.
|
||||
* A System Property should be set prior to the creation of a processor and
|
||||
* may be cleared afterwards.
|
||||
*
|
||||
* <h3>jaxp.properties</h3>
|
||||
* A system property can be specified in the <a href="#JaxpProperties">jaxp.properties</a>
|
||||
* file to set the behavior for all invocations of the JDK. The format is
|
||||
* {@code system-property-name=value}. For example:
|
||||
* <pre>
|
||||
* {@code jdk.xml.isStandalone=true}
|
||||
* </pre>
|
||||
*
|
||||
* <h3 id="ScopeAndOrder">Scope and Order</h3>
|
||||
* The {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature
|
||||
* (hereafter referred to as secure processing) is required for XML processors
|
||||
* including DOM, SAX, Schema Validation, XSLT, and XPath. When secure processing
|
||||
* is set to true, security related features and properties, such as those flagged
|
||||
* as {@code "security: yes"} (hereafter referred to as security properties) in
|
||||
* table <a href="#Features">Implementation Specific Features</a> and
|
||||
* <a href="#Properties">Properties</a>,
|
||||
* are enforced. Such enforcement includes setting security properties and features
|
||||
* to more restrictive values and limits as shown in {@code "Value"}'s
|
||||
* subcolumn {@code "Enforced"} in the tables. When secure processing
|
||||
* is set to false, however, the property values will not be affected.
|
||||
* <p>
|
||||
* When the Java Security Manager is present, secure processing is set to true
|
||||
* and can not be turned off. The security properties are therefore enforced.
|
||||
* <p>
|
||||
* Properties specified in the jaxp.properties file affect all invocations of
|
||||
* the JDK, and will override their default values, or those that may have been
|
||||
* set by secure processing.
|
||||
* <p>
|
||||
* System properties, when set, affect the invocation of the JDK and override
|
||||
* the default settings or those that may have been set in jaxp.properties or
|
||||
* by secure processing.
|
||||
* <p>
|
||||
* JAXP properties specified through JAXP factories or processors (e.g. SAXParser)
|
||||
* take preference over system properties, the jaxp.properties file, as well as
|
||||
* secure processing.
|
||||
* Refer to the <a href="#Properties">Implementation Specific Properties</a> table
|
||||
* for the list of properties supported by the JDK implementation.
|
||||
*
|
||||
* <h3 id="Processor">Processor Support</h3>
|
||||
* Features and properties may be supported by one or more processors. The
|
||||
* following table lists the processors by IDs that can be used for reference.
|
||||
* The properties may be supported by one or more processors as listed in the table
|
||||
* below. Depending on the type of the property, they may be set via
|
||||
* Method 1: setAttribute/Parameter/Property or 2: setFeature as illustrated
|
||||
* in the relevant columns.
|
||||
*
|
||||
* <table class="plain" id="Processors">
|
||||
* <caption>Processors</caption>
|
||||
@ -317,8 +432,8 @@
|
||||
* <tr>
|
||||
* <th scope="col">ID</th>
|
||||
* <th scope="col">Name</th>
|
||||
* <th scope="col">How to set the property</th>
|
||||
* <th scope="col">How to set the feature</th>
|
||||
* <th scope="col">Method 1: setAttribute/Parameter/Property</th>
|
||||
* <th scope="col">Method 2: setFeature</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
*
|
||||
@ -419,34 +534,27 @@
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
* <h3>Implementation Specific Features and Properties</h3>
|
||||
* The Implementation Specific Features and Properties reflect JDK's choice to
|
||||
* manage the limitations on resources while complying with the API specification,
|
||||
* or allow applications to alter behaviors beyond those required by the standards.
|
||||
* <p>
|
||||
* The table below lists the Implementation Specific Properties currently supported
|
||||
* by the JDK. More properties may be added in the future if necessary.
|
||||
*
|
||||
* <div id="IN_ISFPtable"></div>
|
||||
* <table class="striped" id="Properties">
|
||||
* <caption>Implementation Specific Properties</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th scope="col" rowspan="2">Full Name (<a href="#NamingConvention">prefix + name</a>)
|
||||
* <th scope="col" rowspan="2">Full Name (prefix {@code jdk.xml.})
|
||||
* <a href="#Note1">[1]</a></th>
|
||||
* <th scope="col" rowspan="2">Description</th>
|
||||
* <th scope="col" rowspan="2">API Property <a href="#Note2">[2]</a></th>
|
||||
* <th scope="col" rowspan="2">System Property <a href="#Note3">[3]</a></th>
|
||||
* <th scope="col" rowspan="2">jaxp.properties <a href="#Note3">[3]</a></th>
|
||||
* <th scope="col" colspan="4" style="text-align:center">Value <a href="#Note4">[4]</a></th>
|
||||
* <th scope="col" rowspan="2">Security <a href="#Note5">[5]</a></th>
|
||||
* <th scope="col" rowspan="2">Supported Processor <a href="#Note6">[6]</a></th>
|
||||
* <th scope="col" rowspan="2">Since <a href="#Note7">[7]</a></th>
|
||||
* <th scope="col" rowspan="2">System Property <a href="#Note2">[2]</a></th>
|
||||
* <th scope="col" colspan="4" style="text-align:center">Value <a href="#Note3">[3]</a></th>
|
||||
* <th scope="col" rowspan="2">Security <a href="#Note4">[4]</a></th>
|
||||
* <th scope="col" colspan="2">Supported Processor <a href="#Note5">[5]</a></th>
|
||||
* <th scope="col" rowspan="2">Since <a href="#Note6">[6]</a></th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="col">Type</th>
|
||||
* <th scope="col">Value</th>
|
||||
* <th scope="col">Default</th>
|
||||
* <th scope="col">Enforced</th>
|
||||
* <th scope="col">ID</th>
|
||||
* <th scope="col">Set Method</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
*
|
||||
@ -456,9 +564,7 @@
|
||||
* <td id="EELimit">{@systemProperty jdk.xml.entityExpansionLimit}</td>
|
||||
* <td>Limits the number of entity expansions.
|
||||
* </td>
|
||||
* <td style="text-align:center" rowspan="9">yes</td>
|
||||
* <td style="text-align:center" rowspan="9">yes</td>
|
||||
* <td style="text-align:center" rowspan="9">yes</td>
|
||||
* <td style="text-align:center" rowspan="11">yes</td>
|
||||
* <td style="text-align:center" rowspan="9">Integer</td>
|
||||
* <td rowspan="9">
|
||||
* A positive integer. A value less than or equal to 0 indicates no limit.
|
||||
@ -474,6 +580,7 @@
|
||||
* <a href="#Validation">Validation</a><br>
|
||||
* <a href="#Transform">Transform</a>
|
||||
* </td>
|
||||
* <td style="text-align:center" rowspan="16"><a href="#Processor">Method 1</a></td>
|
||||
* <td style="text-align:center" rowspan="9">8</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -546,9 +653,6 @@
|
||||
* {@link org.w3c.dom.ls.LSSerializer#getDomConfig() xml-declaration}, this property
|
||||
* does not have an effect on whether an XML declaration should be written out.
|
||||
* </td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">boolean</td>
|
||||
* <td style="text-align:center">true/false</td>
|
||||
* <td style="text-align:center">false</td>
|
||||
@ -570,9 +674,6 @@
|
||||
* except that it is for the <a href="#XSLTCSerializer">XSLTC Serializer</a>
|
||||
* and its value is a String.
|
||||
* </td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">String</td>
|
||||
* <td style="text-align:center">yes/no</td>
|
||||
* <td style="text-align:center">no</td>
|
||||
@ -589,8 +690,6 @@
|
||||
* larger than the specified size to ones that are equal to or smaller than the size.
|
||||
* </td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">Integer</td>
|
||||
* <td>A positive integer. A value less than
|
||||
* or equal to 0 indicates that the property is not specified. If the value is not
|
||||
@ -606,8 +705,6 @@
|
||||
* <td>Sets a non-null ClassLoader instance to be used for loading XSLTC java
|
||||
* extension functions.
|
||||
* </td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">no</td>
|
||||
* <td style="text-align:center">no</td>
|
||||
* <td style="text-align:center">Object</td>
|
||||
* <td>A reference to a ClassLoader object. Null if the value is not specified.</td>
|
||||
@ -621,11 +718,6 @@
|
||||
* <td id="xpathExprGrpLimit">jdk.xml.xpathExprGrpLimit</td>
|
||||
* <td>Limits the number of groups an XPath expression can contain.
|
||||
* </td>
|
||||
* <td style="text-align:center" rowspan="2">
|
||||
* <a href="#Transform">Transform</a>:yes<br>
|
||||
* <a href="#XPATH">XPath</a>:no
|
||||
* </td>
|
||||
* <td style="text-align:center" rowspan="3">yes</td>
|
||||
* <td style="text-align:center" rowspan="3">yes</td>
|
||||
* <td style="text-align:center" rowspan="3">Integer</td>
|
||||
* <td rowspan="3">A positive integer. A value less than or equal to 0 indicates no limit.
|
||||
@ -640,7 +732,7 @@
|
||||
* <td style="text-align:center" rowspan="3">19</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td id="xpathExprGrpLimit">jdk.xml.xpathExprGrpLimit</td>
|
||||
* <td id="xpathExprOpLimit">jdk.xml.xpathExprOpLimit</td>
|
||||
* <td>Limits the number of operators an XPath expression can contain.
|
||||
* </td>
|
||||
* <td style="text-align:center">100</td>
|
||||
@ -650,49 +742,17 @@
|
||||
* <td id="xpathTotalOpLimit">jdk.xml.xpathTotalOpLimit</td>
|
||||
* <td>Limits the total number of XPath operators in an XSL Stylesheet.
|
||||
* </td>
|
||||
* <td style="text-align:center">yes</td>
|
||||
* <td style="text-align:center">10000</td>
|
||||
* <td style="text-align:center">10000</td>
|
||||
* <td style="text-align:center">
|
||||
* <a href="#Transform">Transform</a><br>
|
||||
* </td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
* <p>
|
||||
* The table below lists the Implementation Specific Features currently supported
|
||||
* by the JDK. More features may be added in the future if necessary.
|
||||
*
|
||||
* <table class="striped" id="Features">
|
||||
* <caption>Implementation Specific Features</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th scope="col" rowspan="2">Full Name (<a href="#NamingConvention">prefix + name</a>)
|
||||
* <a href="#Note1">[1]</a></th>
|
||||
* <th scope="col" rowspan="2">Description</th>
|
||||
* <th scope="col" rowspan="2">API Property <a href="#Note2">[2]</a></th>
|
||||
* <th scope="col" rowspan="2">System Property <a href="#Note3">[3]</a></th>
|
||||
* <th scope="col" rowspan="2">jaxp.properties <a href="#Note3">[3]</a></th>
|
||||
* <th scope="col" colspan="4" style="text-align:center">Value <a href="#Note4">[4]</a></th>
|
||||
* <th scope="col" rowspan="2">Security <a href="#Note5">[5]</a></th>
|
||||
* <th scope="col" rowspan="2">Supported Processor <a href="#Note6">[6]</a></th>
|
||||
* <th scope="col" rowspan="2">Since <a href="#Note7">[7]</a></th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="col">Type</th>
|
||||
* <th scope="col">Value</th>
|
||||
* <th scope="col">Default</th>
|
||||
* <th scope="col">Enforced</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <td id="ExtFunc">{@systemProperty jdk.xml.enableExtensionFunctions}</td>
|
||||
* <td>Determines if XSLT and XPath extension functions are to be allowed.
|
||||
* </td>
|
||||
* <td style="text-align:center" rowspan="3">yes</td>
|
||||
* <td style="text-align:center" rowspan="3">yes</td>
|
||||
* <td style="text-align:center" rowspan="3">yes</td>
|
||||
* <td style="text-align:center" rowspan="3">Boolean</td>
|
||||
* <td>
|
||||
* true or false. True indicates that extension functions are allowed; False otherwise.
|
||||
@ -704,6 +764,7 @@
|
||||
* <a href="#Transform">Transform</a><br>
|
||||
* <a href="#XPAth">XPath</a>
|
||||
* </td>
|
||||
* <td style="text-align:center"><a href="#Processor">Method 2</a></td>
|
||||
* <td style="text-align:center">8</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -725,6 +786,7 @@
|
||||
* <a href="#Validation">Validation</a><br>
|
||||
* <a href="#XPAth">XPath</a>
|
||||
* </td>
|
||||
* <td style="text-align:center"><a href="#Processor">Method 2</a></td>
|
||||
* <td style="text-align:center">9</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
@ -743,6 +805,7 @@
|
||||
* <td style="text-align:center">
|
||||
* <a href="#SAX">SAX</a>
|
||||
* </td>
|
||||
* <td style="text-align:center"><a href="#Processor">Method 2</a></td>
|
||||
* <td style="text-align:center">9</td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
@ -750,14 +813,12 @@
|
||||
* <p id="Note1">
|
||||
* <b>[1]</b> The full name of a property should be used to set the property.
|
||||
* <p id="Note2">
|
||||
* <b>[2]</b> A value "yes" indicates that the property can be set through the
|
||||
* processor or its factory, "no" otherwise.
|
||||
* <p id="Note3">
|
||||
* <b>[3]</b> A value "yes" indicates there is a corresponding System Property
|
||||
* for the property, "no" otherwise.
|
||||
* <b>[2]</b> A value "yes" indicates there is a corresponding System Property
|
||||
* for the property, "no" otherwise. The name of the System Property is the same
|
||||
* as that of the property.
|
||||
*
|
||||
* <p id="Note4">
|
||||
* <b>[4]</b> The value must be exactly as listed in this table, case-sensitive.
|
||||
* <p id="Note3">
|
||||
* <b>[3]</b> The value must be exactly as listed in this table, case-sensitive.
|
||||
* The value of the corresponding System Property is the String representation of
|
||||
* the property value. If the type is boolean, the system property is true only
|
||||
* if it is "true"; If the type is String, the system property is true only if
|
||||
@ -766,31 +827,32 @@
|
||||
* is Integer, the value of the System Property is the String representation of
|
||||
* the value (e.g. "64000" for {@code entityExpansionLimit}).
|
||||
*
|
||||
* <p id="Note5">
|
||||
* <b>[5]</b> A value "yes" indicates the property is a Security Property. Refer
|
||||
* to the <a href="#ScopeAndOrder">Scope and Order</a> on how secure processing
|
||||
* may affect the value of a Security Property.
|
||||
* <p id="Note6">
|
||||
* <b>[6]</b> One or more processors that support the property. The values of the
|
||||
* field are IDs described in table <a href="#Processor">Processors</a>.
|
||||
* <p id="Note7">
|
||||
* <b>[7]</b> Indicates the initial release the property is introduced.
|
||||
* <p id="Note4">
|
||||
* <b>[4]</b> A value "yes" indicates the property is a Security Property. As indicated
|
||||
* in the <a href="#PP">Property Precedence</a>, the values listed in the column
|
||||
* {@code enforced} will be used to initialize these properties when
|
||||
* {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING FSP} is true.
|
||||
*
|
||||
* <h3>Legacy Property Names (deprecated)</h3>
|
||||
* <p id="Note5">
|
||||
* <b>[5]</b> One or more processors that support the property. The IDs and Set Method
|
||||
* are as shown in the table <a href="#Processor">Processors</a>.
|
||||
* <p id="Note6">
|
||||
* <b>[6]</b> Indicates the initial release the property is introduced.
|
||||
*
|
||||
* <h3 id="IN_Legacy">Legacy Property Names (deprecated)</h3>
|
||||
* JDK releases prior to JDK 17 support the use of URI style prefix for properties.
|
||||
* These legacy property names are <b>deprecated</b> as of JDK 17 and may be removed
|
||||
* in future releases. If both new and legacy properties are set, the new property
|
||||
* names take precedence regardless of how and where they are set. The overriding order
|
||||
* as defined in <a href="#ScopeAndOrder">Scope and Order</a> thus becomes, in
|
||||
* descending order:
|
||||
* as defined in <a href="#PropPrec">Property Precedence</a> thus becomes:
|
||||
*
|
||||
* <ul>
|
||||
* <li>The default value;</li>
|
||||
* <li>Value set by FEATURE_SECURE_PROCESSING;</li>
|
||||
* <li>Value set in jaxp.properties;</li>
|
||||
* <li>Value set as System Property;</li>
|
||||
* <li>Value set on factories or processors using <b>legacy property names</b>;</li>
|
||||
* <li>Value set on factories or processors using new property names.</li>
|
||||
* <li>Value set on factories or processors using <b>legacy property names</b>;</li>
|
||||
* <li>Value set as System Property;</li>
|
||||
* <li>Value set in the configuration file;</li>
|
||||
* <li>Value set by FEATURE_SECURE_PROCESSING;</li>
|
||||
* <li>The default value;</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* The following table lists the properties and their corresponding legacy names.
|
||||
|
180
src/java.xml/share/conf/jaxp.properties
Normal file
180
src/java.xml/share/conf/jaxp.properties
Normal file
@ -0,0 +1,180 @@
|
||||
################################################################################
|
||||
# JAXP Configuration File
|
||||
#
|
||||
# jaxp.properties (this file) is the default configuration file for JAXP, the API
|
||||
# defined in the java.xml module. It is in java.util.Properties format and typically
|
||||
# located in the {java.home}/conf directory. It may contain key/value pairs for
|
||||
# specifying the implementation classes of JAXP factories and/or properties
|
||||
# that have corresponding system properties.
|
||||
#
|
||||
# A user-specified configuration file can be set up using the system property
|
||||
# java.xml.config.file to override any or all of the entries in jaxp.properties.
|
||||
# The following statement provides myConfigurationFile as a custom configuration
|
||||
# file:
|
||||
# java -Djava.xml.config.file=myConfigurationFile
|
||||
################################################################################
|
||||
|
||||
# ---- JAXP Default Configuration ----
|
||||
#
|
||||
# The JAXP default configuration (jaxp.properties) contains entries for the
|
||||
# Factory Lookup Mechanism and properties with corresponding system properties.
|
||||
# The values are generally set to the default values of the properties.
|
||||
#
|
||||
#
|
||||
# JAXP Lookup Mechanism:
|
||||
#
|
||||
# The JAXP configuration file ranks 2nd to the System Property in the precedent
|
||||
# order of the JAXP Lookup Mechanism. When the System Property is not specified,
|
||||
# a JAXP factory reads the configuration file in order to locate an implementation
|
||||
# class. If found, the class specified will be used as the factory implementation
|
||||
# class.
|
||||
#
|
||||
# The format of an entry is key=value where the key is the fully qualified name
|
||||
# of the factory and value that of the implementation class. The following entry
|
||||
# set a DocumentBuilderFactory implementation class:
|
||||
#
|
||||
# javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
|
||||
#
|
||||
#
|
||||
# Java SE and JDK Implementation Specific Properties:
|
||||
#
|
||||
# The JAXP configuration file ranks above the default settings in the Property
|
||||
# Precedence in that its entries will override the default values of the corresponding
|
||||
# properties.
|
||||
#
|
||||
# All properties that have System Properties defined in Java SE or supported
|
||||
# by the JDK Implementation can be placed in the configuration file to override
|
||||
# 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
|
||||
# is:
|
||||
# javax.xml.catalog.files=strict
|
||||
#
|
||||
#
|
||||
# Extension Functions:
|
||||
#
|
||||
# This property determines whether XSLT and XPath extension functions are allowed.
|
||||
# The value type is boolean and the default value is true (allowing
|
||||
# extension functions). The following entry would override the default value and
|
||||
# disallow extension functions:
|
||||
#
|
||||
# jdk.xml.enableExtensionFunctions=false
|
||||
#
|
||||
#
|
||||
# Overriding the default parser:
|
||||
#
|
||||
# This property allows using a third party implementation to override the default
|
||||
# parser provided by the JDK. The value type is boolean and the default value is
|
||||
# false, disallowing overriding the default parser. The setting below reflects
|
||||
# the default property setting:
|
||||
#
|
||||
jdk.xml.overrideDefaultParser=false
|
||||
#
|
||||
#
|
||||
# External Access Properties:
|
||||
#
|
||||
# The External Access Properties are defined in javax.xml.XMLConstants. Their
|
||||
# system properties are javax.xml.accessExternalDTD, javax.xml.accessExternalSchema,
|
||||
# and javax.xml.accessExternalStylesheet. The values are a list of protocols separated
|
||||
# by comma, plus empty string ("") to represent no protocol allowed and the key
|
||||
# word "all" for all access. The default is "all", allowing all external resources
|
||||
# to be fetched. The followings are example of external access settings:
|
||||
#
|
||||
# allow local (file) DTDs to be retrieved
|
||||
# javax.xml.accessExternalDTD=file
|
||||
#
|
||||
# allow local (file) and remote (http) external schemas
|
||||
# javax.xml.accessExternalSchema=file, http
|
||||
#
|
||||
# reject any external stylesheets
|
||||
# javax.xml.accessExternalStylesheet=""
|
||||
#
|
||||
# allow all external stylesheets
|
||||
# javax.xml.accessExternalStylesheet="all"
|
||||
#
|
||||
#
|
||||
# Catalog Properties:
|
||||
#
|
||||
# The Catalog API defines four features: FILES, PREFER, DEFER and RESOLVE.
|
||||
# Except PREFER, all other properties can be placed in the configuration file
|
||||
# using the system properties defined for them.
|
||||
#
|
||||
# FILES: A semicolon-delimited list of URIs to locate the catalog files. The URIs
|
||||
# must be absolute and have a URL protocol handler for the URI scheme. The following
|
||||
# is an example of setting up a catalog file:
|
||||
#
|
||||
# javax.xml.catalog.files = file:///users/auser/catalog/catalog.xml
|
||||
#
|
||||
# DEFER: Indicates that the alternative catalogs including those specified in
|
||||
# delegate entries or nextCatalog are not read until they are needed. The value
|
||||
# is a boolean and the default value is true.
|
||||
#
|
||||
# javax.xml.catalog.defer=true
|
||||
#
|
||||
# RESOLVE: Determines the action if there is no matching entry found after all of
|
||||
# the specified catalogs are exhausted. The values are key words: strict, continue,
|
||||
# and ignore. The default is strict. The following setting reflects the default
|
||||
# setting.
|
||||
#
|
||||
# javax.xml.catalog.resolve=strict
|
||||
#
|
||||
#
|
||||
# useCatalog:
|
||||
# This property instructs XML processors to use XML Catalogs to resolve entity
|
||||
# references. The value is a boolean and the default value is true.
|
||||
#
|
||||
# javax.xml.useCatalog=true
|
||||
#
|
||||
#
|
||||
# Implementation Specific Properties - Limits
|
||||
#
|
||||
# Limits have a value type Integer. The values must be positive integers. Zero
|
||||
# means no limit.
|
||||
#
|
||||
# Limits the number of entity expansions. The default value is 64000
|
||||
# jdk.xml.entityExpansionLimit=64000
|
||||
#
|
||||
# Limits the total size of all entities that include general and parameter entities.
|
||||
# The size is calculated as an aggregation of all entities. The default value is 5x10^7.
|
||||
# jdk.xml.totalEntitySizeLimit=5E7
|
||||
#
|
||||
# Limits the maximum size of any general entities. The default value is 0.
|
||||
# jdk.xml.maxGeneralEntitySizeLimit=0
|
||||
#
|
||||
# Limits the maximum size of any parameter entities, including the result of
|
||||
# nesting multiple parameter entities. The default value is 10^6.
|
||||
# jdk.xml.maxParameterEntitySizeLimit=1E6
|
||||
#
|
||||
# Limits the total number of nodes in all entity references. The default value is 3x10^6.
|
||||
# jdk.xml.entityReplacementLimit=3E6
|
||||
#
|
||||
# Limits the number of attributes an element can have. The default value is 10000.
|
||||
# jdk.xml.elementAttributeLimit=10000
|
||||
#
|
||||
# Limits the number of content model nodes that may be created when building a
|
||||
# grammar for a W3C XML Schema that contains maxOccurs attributes with values
|
||||
# other than "unbounded". The default value is 5000.
|
||||
# jdk.xml.maxOccurLimit=5000
|
||||
#
|
||||
# Limits the maximum element depth. The default value is 0.
|
||||
# jdk.xml.maxElementDepth=0
|
||||
#
|
||||
# Limits the maximum size of XML names, including element name, attribute name
|
||||
# and namespace prefix and URI. The default value is 1000.
|
||||
jdk.xml.maxXMLNameLimit=1000
|
||||
#
|
||||
#
|
||||
# XPath Limits
|
||||
#
|
||||
# Limits the number of groups an XPath expression can contain. The default value is 10.
|
||||
jdk.xml.xpathExprGrpLimit=10
|
||||
#
|
||||
# Limits the number of operators an XPath expression can contain. The default value is 100.
|
||||
jdk.xml.xpathExprOpLimit=100
|
||||
#
|
||||
# Limits the total number of XPath operators in an XSL Stylesheet. The default value is 10000.
|
||||
jdk.xml.xpathTotalOpLimit=10000
|
||||
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
/**
|
||||
* Verifies the configuration file and precedence:
|
||||
* settings in the configuration file are used as the default values of properties;
|
||||
* any settings in a custom configuration file override those in the default
|
||||
* configuration.
|
||||
*/
|
||||
public class ConfigurationTest {
|
||||
// system property for custom configuration file
|
||||
static final String SP_CONFIG = "java.xml.config.file";
|
||||
// Impl-Specific Property: entity expansion
|
||||
static final String ISP_ENTITY_EXPANSION = "jdk.xml.entityExpansionLimit";
|
||||
// Impl-Specific Property: parameter entity limit
|
||||
static final String ISP_PARAMETER_ENTITY = "jdk.xml.maxParameterEntitySizeLimit";
|
||||
// Impl-Specific Property: element attribute limit
|
||||
static final String ISP_ELEMENT_ATTRIBUTE = "jdk.xml.elementAttributeLimit";
|
||||
// Impl-Specific Property: XML name limit
|
||||
static final String ISP_NAME_LIMIT = "jdk.xml.maxXMLNameLimit";
|
||||
|
||||
// Impl-Specific Feature: extension functions
|
||||
static final String ISF_EXTENSION_FUNCTIONS = "jdk.xml.enableExtensionFunctions";
|
||||
// Catalog feature: resolve
|
||||
static final String CATALOG_RESOLVE = "javax.xml.catalog.resolve";
|
||||
// The USE_CATALOG property indicates whether Catalog is enabled for a processor
|
||||
static final String USE_CATALOG = "http://javax.xml.XMLConstants/feature/useCatalog";
|
||||
static final String SP_USE_CATALOG = "javax.xml.useCatalog";
|
||||
|
||||
|
||||
static final boolean IS_WINDOWS = System.getProperty("os.name").contains("Windows");
|
||||
static final String SRC_DIR;
|
||||
static final String TEST_SOURCE_DIR;
|
||||
static {
|
||||
String srcDir = System.getProperty("test.src", ".");
|
||||
if (IS_WINDOWS) {
|
||||
srcDir = srcDir.replace('\\', '/');
|
||||
}
|
||||
SRC_DIR = srcDir;
|
||||
TEST_SOURCE_DIR = srcDir + "/files/";
|
||||
}
|
||||
|
||||
static enum PropertyType { FEATURE, PROPERTY };
|
||||
|
||||
/*
|
||||
* DataProvider for testing the configuration file and system property.
|
||||
*
|
||||
* Fields:
|
||||
* configuration file, property name, property type, property value
|
||||
*/
|
||||
@DataProvider(name = "getProperty")
|
||||
public Object[][] getProperty() {
|
||||
/**
|
||||
* Test cases for verifying the configuration file
|
||||
*/
|
||||
return new Object[][]{
|
||||
// default value is expected for property (PARAMETER_ENTITY) not
|
||||
// set in the default and custom configuration files
|
||||
{null, ISP_PARAMETER_ENTITY, "1000000"},
|
||||
// this property is set in the default (jaxp.properties),
|
||||
// but not the custom configuration file. Expects readings from the
|
||||
// default config
|
||||
{null, ISP_NAME_LIMIT, "1000"},
|
||||
// the property in the default configuration file (jaxp.properties)
|
||||
// will be read and used as the default value of the property
|
||||
{null, ISP_ENTITY_EXPANSION, "64000"},
|
||||
};
|
||||
}
|
||||
|
||||
@DataProvider(name = "getProperty0")
|
||||
public Object[][] getProperty0() {
|
||||
/**
|
||||
* Duplicate of getProperty to include the case that uses the system
|
||||
* property to set up a custom configuration file. This is to avoid
|
||||
* interfering with other test cases.
|
||||
*/
|
||||
return new Object[][]{
|
||||
// the setting in the custom configuration file will override that
|
||||
// in the default one
|
||||
{"customJaxp.properties", ISP_ENTITY_EXPANSION, "1000"},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static String getPath(String file) {
|
||||
String temp = TEST_SOURCE_DIR + file;
|
||||
if (IS_WINDOWS) {
|
||||
temp = "/" + temp;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.SP_CONFIG;
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.DOMImplTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class DOMImplTest extends DocumentBuilderFactory {
|
||||
/*
|
||||
* DataProvider for testing the configuration file and system property.
|
||||
*
|
||||
* Fields:
|
||||
* configuration file, factory implementation class
|
||||
*/
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{"jaxpImpls.properties", "common.config.DOMImplTest"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testDOMImpl(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(SP_CONFIG, getPath(config));
|
||||
}
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
System.clearProperty(SP_CONFIG);
|
||||
Assert.assertEquals(dbf.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) throws IllegalArgumentException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) throws IllegalArgumentException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFeature(String name, boolean value) throws ParserConfigurationException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeature(String name) throws ParserConfigurationException {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.SP_CONFIG;
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.DOMImplTest0
|
||||
* @summary the tests with the default and custom configurations files have to be
|
||||
* separate because they both are loaded once.
|
||||
*/
|
||||
public class DOMImplTest0 {
|
||||
/*
|
||||
* DataProvider for testing the configuration file and system property.
|
||||
*
|
||||
* Fields:
|
||||
* configuration file, factory implementation class
|
||||
*/
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testDOMImpl(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(SP_CONFIG, getPath(config));
|
||||
}
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
System.clearProperty(SP_CONFIG);
|
||||
Assert.assertEquals(dbf.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.DOMPropertyTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class DOMPropertyTest extends ConfigurationTest {
|
||||
|
||||
@Test(dataProvider = "getProperty")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(SP_CONFIG, getPath(config));
|
||||
}
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
Assert.assertEquals(dbf.getAttribute(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.DOMPropertyTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
* Note: this test is a duplicate of DOMPropertyTest. This test runs the
|
||||
* case with a custom configuration file only to avoid interfering with other
|
||||
* test cases.
|
||||
*/
|
||||
public class DOMPropertyTest0 extends ConfigurationTest {
|
||||
|
||||
@Test(dataProvider = "getProperty0")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(SP_CONFIG, getPath(config));
|
||||
}
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
Assert.assertEquals(dbf.getAttribute(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.XMLEventFactory;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.Characters;
|
||||
import javax.xml.stream.events.Comment;
|
||||
import javax.xml.stream.events.DTD;
|
||||
import javax.xml.stream.events.EndDocument;
|
||||
import javax.xml.stream.events.EndElement;
|
||||
import javax.xml.stream.events.EntityDeclaration;
|
||||
import javax.xml.stream.events.EntityReference;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.ProcessingInstruction;
|
||||
import javax.xml.stream.events.StartDocument;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.EventFactoryTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class EventFactoryTest extends XMLEventFactory {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{"jaxpImpls.properties", "common.config.EventFactoryTest"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testEventFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XMLEventFactory ef = XMLEventFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(ef.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(Location location) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute createAttribute(String prefix, String namespaceURI, String localName, String value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute createAttribute(String localName, String value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute createAttribute(QName name, String value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Namespace createNamespace(String namespaceURI) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Namespace createNamespace(String prefix, String namespaceUri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartElement createStartElement(QName name, Iterator<? extends Attribute> attributes, Iterator<? extends Namespace> namespaces) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartElement createStartElement(String prefix, String namespaceUri, String localName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator<? extends Attribute> attributes, Iterator<? extends Namespace> namespaces) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator<? extends Attribute> attributes, Iterator<? extends Namespace> namespaces, NamespaceContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EndElement createEndElement(QName name, Iterator<? extends Namespace> namespaces) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EndElement createEndElement(String prefix, String namespaceUri, String localName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EndElement createEndElement(String prefix, String namespaceUri, String localName, Iterator<? extends Namespace> namespaces) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Characters createCharacters(String content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Characters createCData(String content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Characters createSpace(String content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Characters createIgnorableSpace(String content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartDocument createStartDocument() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartDocument createStartDocument(String encoding, String version, boolean standalone) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartDocument createStartDocument(String encoding, String version) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartDocument createStartDocument(String encoding) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EndDocument createEndDocument() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comment createComment(String text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessingInstruction createProcessingInstruction(String target, String data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DTD createDTD(String dtd) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.stream.XMLEventFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.EventFactoryTest0
|
||||
* @summary the tests with the default and custom configurations files have to be
|
||||
* separate because they both are loaded once.
|
||||
*/
|
||||
public class EventFactoryTest0 {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.xml.internal.stream.events.XMLEventFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testEventFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XMLEventFactory ef = XMLEventFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(ef.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import javax.xml.stream.EventFilter;
|
||||
import javax.xml.stream.StreamFilter;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLReporter;
|
||||
import javax.xml.stream.XMLResolver;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.util.XMLEventAllocator;
|
||||
import javax.xml.transform.Source;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.InputFactoryTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class InputFactoryTest extends XMLInputFactory {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{"jaxpImpls.properties", "common.config.InputFactoryTest"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testInputFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XMLInputFactory xif = XMLInputFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xif.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader createXMLStreamReader(InputStream stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader createXMLStreamReader(InputStream stream, String encoding) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader createXMLStreamReader(String systemId, InputStream stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createXMLEventReader(Reader reader) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createXMLEventReader(String systemId, Reader reader) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createXMLEventReader(Source source) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createXMLEventReader(InputStream stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createXMLEventReader(InputStream stream, String encoding) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createXMLEventReader(String systemId, InputStream stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLResolver getXMLResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setXMLResolver(XMLResolver resolver) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLReporter getXMLReporter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setXMLReporter(XMLReporter reporter) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String name, Object value) throws IllegalArgumentException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(String name) throws IllegalArgumentException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPropertySupported(String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEventAllocator(XMLEventAllocator allocator) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventAllocator getEventAllocator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.InputFactoryTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class InputFactoryTest0 {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.xml.internal.stream.XMLInputFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testInputFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XMLInputFactory xif = XMLInputFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xif.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import javax.xml.stream.XMLEventWriter;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Result;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.OutputFactoryTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class OutputFactoryTest extends XMLOutputFactory {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{"jaxpImpls.properties", "common.config.OutputFactoryTest"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testOutputFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XMLOutputFactory xof = XMLOutputFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xof.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamWriter createXMLStreamWriter(Writer stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamWriter createXMLStreamWriter(OutputStream stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamWriter createXMLStreamWriter(OutputStream stream, String encoding) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventWriter createXMLEventWriter(OutputStream stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventWriter createXMLEventWriter(OutputStream stream, String encoding) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLEventWriter createXMLEventWriter(Writer stream) throws XMLStreamException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String name, Object value) throws IllegalArgumentException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(String name) throws IllegalArgumentException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPropertySupported(String name) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.OutputFactoryTest0
|
||||
* @summary the tests with the default and custom configurations files have to be
|
||||
* separate because they both are loaded once.
|
||||
*/
|
||||
public class OutputFactoryTest0 {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.xml.internal.stream.XMLOutputFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testOutputFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XMLOutputFactory xof = XMLOutputFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xof.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.SP_CONFIG;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.PathTest
|
||||
* @summary verifies that the system property "java.xml.config.file" may be set
|
||||
* with a relative path.
|
||||
*/
|
||||
public class PathTest extends ConfigurationTest {
|
||||
private static final String FILE_DIR = "files";
|
||||
private static final String CUSTOM_CONFIG = "customJaxp.properties";
|
||||
|
||||
/*
|
||||
* Sets up the test environment by copying the customJaxp.properties file
|
||||
* to a directory under the current working directory of the JVM.
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setup() throws IOException {
|
||||
Path userDir = Paths.get(System.getProperty("user.dir", "."));
|
||||
Path fileDir = Paths.get(userDir.toString(), FILE_DIR);
|
||||
|
||||
if (Files.notExists(fileDir)) {
|
||||
Files.createDirectory(fileDir);
|
||||
}
|
||||
|
||||
Path source = Paths.get(TEST_SOURCE_DIR, CUSTOM_CONFIG);
|
||||
Path dest = Paths.get(fileDir.toString(), CUSTOM_CONFIG);
|
||||
Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verifies a user-defined configuration file can be set with a relative path.
|
||||
* This test is the same as other Property tests, except the java.xml.config.file
|
||||
* system property is set with a relative path.
|
||||
*/
|
||||
@Test(dataProvider = "getProperty0")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
// set with a relative path instead of the absolute path from getPath
|
||||
System.setProperty(SP_CONFIG, FILE_DIR + "/" + config);
|
||||
}
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
Assert.assertEquals(dbf.getAttribute(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXNotRecognizedException;
|
||||
import org.xml.sax.SAXNotSupportedException;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SAXImplTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class SAXImplTest extends SAXParserFactory {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{"jaxpImpls.properties", "common.config.SAXImplTest"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testSAXImpl(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(spf.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFeature(String name, boolean value)
|
||||
throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeature(String name)
|
||||
throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SAXImplTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class SAXImplTest0 {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testSAXImpl(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(spf.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SAXPropertyTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class SAXPropertyTest extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
SAXParser sp = spf.newSAXParser();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(sp.getProperty(property), expected);
|
||||
XMLReader reader = sp.getXMLReader();
|
||||
Assert.assertEquals(reader.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SAXPropertyTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
* Note: this test is a duplicate of SAXPropertyTest. This test runs the
|
||||
* case with a custom configuration file only to avoid interfering with other
|
||||
* test cases.
|
||||
*/
|
||||
public class SAXPropertyTest0 extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty0")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
SAXParser sp = spf.newSAXParser();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(sp.getProperty(property), expected);
|
||||
XMLReader reader = sp.getXMLReader();
|
||||
Assert.assertEquals(reader.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.validation.Schema;
|
||||
import javax.xml.validation.SchemaFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.w3c.dom.ls.LSResourceResolver;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SchemaFactoryTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class SchemaFactoryTest extends SchemaFactory {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{"jaxpImpls.properties", "common.config.SchemaFactoryTest"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(sf.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSchemaLanguageSupported(String schemaLanguage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorHandler(ErrorHandler errorHandler) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorHandler getErrorHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceResolver(LSResourceResolver resourceResolver) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public LSResourceResolver getResourceResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema newSchema(Source[] schemas) throws SAXException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema newSchema() throws SAXException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.validation.SchemaFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SchemaFactoryTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class SchemaFactoryTest0 {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(sf.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.validation.SchemaFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SchemaPropertyTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class SchemaPropertyTest extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(sf.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.validation.SchemaFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.SchemaPropertyTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
* Note: this test is a duplicate of SchemaPropertyTest. This test runs the
|
||||
* case with a custom configuration file only to avoid interfering with other
|
||||
* test cases.
|
||||
*/
|
||||
public class SchemaPropertyTest0 extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty0")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(sf.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.StAXPropertyTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class StAXPropertyTest extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
XMLInputFactory xif = XMLInputFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xif.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.StAXPropertyTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
* Note: this test is a duplicate of DOMPropertyTest. This test runs the
|
||||
* case with a custom configuration file only to avoid interfering with other
|
||||
* test cases.
|
||||
*/
|
||||
public class StAXPropertyTest0 extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty0")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
XMLInputFactory xif = XMLInputFactory.newFactory();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xif.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.transform.ErrorListener;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Templates;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.URIResolver;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.TransformerFactoryTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class TransformerFactoryTest extends TransformerFactory {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(tf.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transformer newTransformer(Source source) throws TransformerConfigurationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transformer newTransformer() throws TransformerConfigurationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Templates newTemplates(Source source) throws TransformerConfigurationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setURIResolver(URIResolver resolver) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public URIResolver getURIResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFeature(String name, boolean value) throws TransformerConfigurationException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeature(String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorListener(ErrorListener listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorListener getErrorListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.TransformerFactoryTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class TransformerFactoryTest0 {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(tf.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.TransformerPropertyTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class TransformerPropertyTest extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(tf.getAttribute(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.TransformerPropertyTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
* Note: this test is a duplicate of TransformerPropertyTest. This test runs the
|
||||
* case with a custom configuration file only to avoid interfering with other
|
||||
* test cases.
|
||||
*/
|
||||
public class TransformerPropertyTest0 extends ConfigurationTest {
|
||||
@Test(dataProvider = "getProperty0")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(tf.getAttribute(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import javax.xml.xpath.XPathFactoryConfigurationException;
|
||||
import javax.xml.xpath.XPathFunctionResolver;
|
||||
import javax.xml.xpath.XPathVariableResolver;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.XPathFactoryTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class XPathFactoryTest extends XPathFactory {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{"jaxpImpls.properties", "common.config.XPathFactoryTest"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XPathFactory xf = XPathFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xf.getClass().getName(), expected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObjectModelSupported(String objectModel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFeature(String name, boolean value) throws XPathFactoryConfigurationException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeature(String name) throws XPathFactoryConfigurationException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setXPathVariableResolver(XPathVariableResolver resolver) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setXPathFunctionResolver(XPathFunctionResolver resolver) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public XPath newXPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import static common.config.ConfigurationTest.getPath;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.XPathFactoryTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class XPathFactoryTest0 {
|
||||
@DataProvider(name = "getImpl")
|
||||
public Object[][] getImpl() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getImpl")
|
||||
public void testFactory(String config, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
|
||||
XPathFactory xf = XPathFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xf.getClass().getName(), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.XPathPropertyTest
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
*/
|
||||
public class XPathPropertyTest extends ConfigurationTest {
|
||||
/*
|
||||
* DataProvider for testing the configuration file and system property.
|
||||
*
|
||||
* Fields:
|
||||
* configuration file, property name, property value
|
||||
*/
|
||||
@DataProvider(name = "getProperty")
|
||||
public Object[][] getProperty() {
|
||||
|
||||
return new Object[][]{
|
||||
{null, "jdk.xml.xpathExprOpLimit", "100"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getProperty")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
XPathFactory xf = XPathFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xf.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package common.config;
|
||||
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test @bug 8303530
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @modules java.xml/jdk.xml.internal
|
||||
* @run testng/othervm common.config.XPathPropertyTest0
|
||||
* @summary verifies that JAXP configuration file is customizable with a system
|
||||
* property "java.xml.config.file".
|
||||
* Note: this test is a duplicate of XPathPropertyTest. This test runs the
|
||||
* case with a custom configuration file only to avoid interfering with other
|
||||
* test cases.
|
||||
*/
|
||||
public class XPathPropertyTest0 extends ConfigurationTest {
|
||||
/*
|
||||
* DataProvider for testing the configuration file and system property.
|
||||
*
|
||||
* Fields:
|
||||
* configuration file, property name, property value
|
||||
*/
|
||||
@DataProvider(name = "getProperty")
|
||||
public Object[][] getProperty() {
|
||||
|
||||
return new Object[][]{
|
||||
{"customJaxp.properties", "jdk.xml.xpathExprOpLimit", "200"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "getProperty")
|
||||
public void testProperty(String config, String property, String expected) throws Exception {
|
||||
if (config != null) {
|
||||
System.setProperty(ConfigurationTest.SP_CONFIG, getPath(config));
|
||||
}
|
||||
XPathFactory xf = XPathFactory.newInstance();
|
||||
System.clearProperty(ConfigurationTest.SP_CONFIG);
|
||||
Assert.assertEquals(xf.getProperty(property), expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
################################################################################
|
||||
# XML Library (java.xml) Configuration File
|
||||
#
|
||||
# This file is in java.util.Properties format and typically located in the conf
|
||||
# directory of the Java installation. It may contain key/value pairs for specifying
|
||||
# the implementation class of a factory and/or properties that have corresponding
|
||||
# system properties.
|
||||
#
|
||||
# This file can be replaced by specifying a filename with the jdk.xml.config.file
|
||||
# system property. For example java -Djava.xml.config.file=myfile
|
||||
################################################################################
|
||||
|
||||
# ---- Custom Configuration File ----
|
||||
# Sets more restrictive values for: extension functions, overriding default
|
||||
# parsers, and DTD related limits.
|
||||
#
|
||||
# Disable Extension Functions
|
||||
jdk.xml.enableExtensionFunctions=false
|
||||
# Disallow overriding the default parser
|
||||
jdk.xml.overrideDefaultParser=false
|
||||
#
|
||||
# Implementation specific limits:
|
||||
jdk.xml.entityExpansionLimit=1000
|
||||
jdk.xml.totalEntitySizeLimit=100000
|
||||
jdk.xml.maxGeneralEntitySizeLimit=1024
|
||||
jdk.xml.maxParameterEntitySizeLimit=1024
|
||||
jdk.xml.entityReplacementLimit=10000
|
||||
#
|
||||
# XPath limits
|
||||
jdk.xml.xpathExprOpLimit=200
|
||||
|
@ -0,0 +1,180 @@
|
||||
################################################################################
|
||||
# JAXP Configuration File
|
||||
#
|
||||
# jaxp.properties (this file) is the default configuration file for JAXP, the API
|
||||
# defined in the java.xml module. It is in java.util.Properties format and typically
|
||||
# located in the {java.home}/conf directory. It may contain key/value pairs for
|
||||
# specifying the implementation classes of JAXP factories and/or properties
|
||||
# that have corresponding system properties.
|
||||
#
|
||||
# A user-specified configuration file can be set up using the system property
|
||||
# java.xml.config.file to override any or all of the entries in jaxp.properties.
|
||||
# The following statement provides myConfigurationFile as a custom configuration
|
||||
# file:
|
||||
# java -Djava.xml.config.file=myConfigurationFile
|
||||
################################################################################
|
||||
|
||||
# ---- JAXP Default Configuration ----
|
||||
#
|
||||
# The JAXP default configuration (jaxp.properties) contains entries for the
|
||||
# Factory Lookup Mechanism and properties with corresponding system properties.
|
||||
# The values are generally set to the default values of the properties.
|
||||
#
|
||||
#
|
||||
# JAXP Lookup Mechanism:
|
||||
#
|
||||
# The JAXP configuration file ranks 2nd to the System Property in the precedent
|
||||
# order of the JAXP Lookup Mechanism. When the System Property is not specified,
|
||||
# a JAXP factory reads the configuration file in order to locate an implementation
|
||||
# class. If found, the class specified will be used as the factory implementation
|
||||
# class.
|
||||
#
|
||||
# The format of an entry is key=value where the key is the fully qualified name
|
||||
# of the factory and value that of the implementation class. The following entry
|
||||
# set a DocumentBuilderFactory implementation class:
|
||||
#
|
||||
# javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
|
||||
#
|
||||
#
|
||||
# Java SE and JDK Implementation Specific Properties:
|
||||
#
|
||||
# The JAXP configuration file ranks above the default settings in the Property
|
||||
# Precedence in that its entries will override the default values of the corresponding
|
||||
# properties.
|
||||
#
|
||||
# All properties that have System Properties defined in Java SE or supported
|
||||
# by the JDK Implementation can be placed in the configuration file to override
|
||||
# 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
|
||||
# is:
|
||||
# javax.xml.catalog.files=strict
|
||||
#
|
||||
#
|
||||
# Extension Functions:
|
||||
#
|
||||
# This property determines whether XSLT and XPath extension functions are allowed.
|
||||
# The value type is boolean and the default value is true (allowing
|
||||
# extension functions). The following entry would override the default value and
|
||||
# disallow extension functions:
|
||||
#
|
||||
# jdk.xml.enableExtensionFunctions=false
|
||||
#
|
||||
#
|
||||
# Overriding the default parser:
|
||||
#
|
||||
# This property allows using a third party implementation to override the default
|
||||
# parser provided by the JDK. The value type is boolean and the default value is
|
||||
# false, disallowing overriding the default parser. The setting below reflects
|
||||
# the default property setting:
|
||||
#
|
||||
jdk.xml.overrideDefaultParser=false
|
||||
#
|
||||
#
|
||||
# External Access Properties:
|
||||
#
|
||||
# The External Access Properties are defined in javax.xml.XMLConstants. Their
|
||||
# system properties are javax.xml.accessExternalDTD, javax.xml.accessExternalSchema,
|
||||
# and javax.xml.accessExternalStylesheet. The values are a list of protocols separated
|
||||
# by comma, plus empty string ("") to represent no protocol allowed and the key
|
||||
# word "all" for all access. The default is "all", allowing all external resources
|
||||
# to be fetched. The followings are example of external access settings:
|
||||
#
|
||||
# allow local (file) DTDs to be retrieved
|
||||
# javax.xml.accessExternalDTD=file
|
||||
#
|
||||
# allow local (file) and remote (http) external schemas
|
||||
# javax.xml.accessExternalSchema=file, http
|
||||
#
|
||||
# reject any external stylesheets
|
||||
# javax.xml.accessExternalStylesheet=""
|
||||
#
|
||||
# allow all external stylesheets
|
||||
# javax.xml.accessExternalStylesheet="all"
|
||||
#
|
||||
#
|
||||
# Catalog Properties:
|
||||
#
|
||||
# The Catalog API defines four features: FILES, PREFER, DEFER and RESOLVE.
|
||||
# Except PREFER, all other properties can be placed in the configuration file
|
||||
# using the system properties defined for them.
|
||||
#
|
||||
# FILES: A semicolon-delimited list of URIs to locate the catalog files. The URIs
|
||||
# must be absolute and have a URL protocol handler for the URI scheme. The following
|
||||
# is an example of setting up a catalog file:
|
||||
#
|
||||
# javax.xml.catalog.files = file:///users/auser/catalog/catalog.xml
|
||||
#
|
||||
# DEFER: Indicates that the alternative catalogs including those specified in
|
||||
# delegate entries or nextCatalog are not read until they are needed. The value
|
||||
# is a boolean and the default value is true.
|
||||
#
|
||||
# javax.xml.catalog.defer=true
|
||||
#
|
||||
# RESOLVE: Determines the action if there is no matching entry found after all of
|
||||
# the specified catalogs are exhausted. The values are key words: strict, continue,
|
||||
# and ignore. The default is strict. The following setting reflects the default
|
||||
# setting.
|
||||
#
|
||||
# javax.xml.catalog.resolve=strict
|
||||
#
|
||||
#
|
||||
# useCatalog:
|
||||
# This property instructs XML processors to use XML Catalogs to resolve entity
|
||||
# references. The value is a boolean and the default value is true.
|
||||
#
|
||||
# javax.xml.useCatalog=true
|
||||
#
|
||||
#
|
||||
# Implementation Specific Properties - Limits
|
||||
#
|
||||
# Limits have a value type Integer. The values must be positive integers. Zero
|
||||
# means no limit.
|
||||
#
|
||||
# Limits the number of entity expansions. The default value is 64000
|
||||
# jdk.xml.entityExpansionLimit=64000
|
||||
#
|
||||
# Limits the total size of all entities that include general and parameter entities.
|
||||
# The size is calculated as an aggregation of all entities. The default value is 5x10^7.
|
||||
# jdk.xml.totalEntitySizeLimit=5E7
|
||||
#
|
||||
# Limits the maximum size of any general entities. The default value is 0.
|
||||
# jdk.xml.maxGeneralEntitySizeLimit=0
|
||||
#
|
||||
# Limits the maximum size of any parameter entities, including the result of
|
||||
# nesting multiple parameter entities. The default value is 10^6.
|
||||
# jdk.xml.maxParameterEntitySizeLimit=1E6
|
||||
#
|
||||
# Limits the total number of nodes in all entity references. The default value is 3x10^6.
|
||||
# jdk.xml.entityReplacementLimit=3E6
|
||||
#
|
||||
# Limits the number of attributes an element can have. The default value is 10000.
|
||||
# jdk.xml.elementAttributeLimit=10000
|
||||
#
|
||||
# Limits the number of content model nodes that may be created when building a
|
||||
# grammar for a W3C XML Schema that contains maxOccurs attributes with values
|
||||
# other than "unbounded". The default value is 5000.
|
||||
# jdk.xml.maxOccurLimit=5000
|
||||
#
|
||||
# Limits the maximum element depth. The default value is 0.
|
||||
# jdk.xml.maxElementDepth=0
|
||||
#
|
||||
# Limits the maximum size of XML names, including element name, attribute name
|
||||
# and namespace prefix and URI. The default value is 1000.
|
||||
jdk.xml.maxXMLNameLimit=1000
|
||||
#
|
||||
#
|
||||
# XPath Limits
|
||||
#
|
||||
# Limits the number of groups an XPath expression can contain. The default value is 10.
|
||||
jdk.xml.xpathExprGrpLimit=10
|
||||
#
|
||||
# Limits the number of operators an XPath expression can contain. The default value is 100.
|
||||
jdk.xml.xpathExprOpLimit=100
|
||||
#
|
||||
# Limits the total number of XPath operators in an XSL Stylesheet. The default value is 10000.
|
||||
jdk.xml.xpathTotalOpLimit=10000
|
||||
|
@ -0,0 +1,48 @@
|
||||
################################################################################
|
||||
# XML Library (java.xml) Configuration File
|
||||
#
|
||||
# This file is in java.util.Properties format and typically located in the conf
|
||||
# directory of the Java installation. It may contain key/value pairs for specifying
|
||||
# the implementation class of a factory and/or properties that have corresponding
|
||||
# system properties.
|
||||
#
|
||||
# This file can be replaced by specifying a filename with the jdk.xml.config.file
|
||||
# system property. For example java -Djava.xml.config.file=myfile
|
||||
################################################################################
|
||||
|
||||
# ---- Configuration for test ----
|
||||
#
|
||||
# Factory implementation class
|
||||
javax.xml.parsers.DocumentBuilderFactory=common.config.DOMImplTest
|
||||
javax.xml.parsers.SAXParserFactory=common.config.SAXImplTest
|
||||
javax.xml.stream.XMLEventFactory=common.config.EventFactoryTest
|
||||
javax.xml.stream.XMLInputFactory=common.config.InputFactoryTest
|
||||
javax.xml.stream.XMLOutputFactory=common.config.OutputFactoryTest
|
||||
javax.xml.transform.TransformerFactory=common.config.TransformerFactoryTest
|
||||
javax.xml.validation.SchemaFactory\:http\://www.w3.org/2001/XMLSchema=common.config.SchemaFactoryTest
|
||||
javax.xml.xpath.XPathFactory\:http\://java.sun.com/jaxp/xpath/dom=common.config.XPathFactoryTest
|
||||
#
|
||||
# Disable Extension Functions
|
||||
jdk.xml.enableExtensionFunctions=false
|
||||
# Disallow overriding the default parser
|
||||
jdk.xml.overrideDefaultParser=false
|
||||
#
|
||||
# Implementation specific limits:
|
||||
#
|
||||
jdk.xml.entityExpansionLimit=1000
|
||||
jdk.xml.totalEntitySizeLimit=100000
|
||||
jdk.xml.maxGeneralEntitySizeLimit=1024
|
||||
jdk.xml.maxParameterEntitySizeLimit=1024
|
||||
jdk.xml.entityReplacementLimit=10000
|
||||
#
|
||||
# General XML limits
|
||||
jdk.xml.elementAttributeLimit=100
|
||||
jdk.xml.maxOccurLimit=5000
|
||||
jdk.xml.maxElementDepth=0
|
||||
jdk.xml.maxXMLNameLimit=1000
|
||||
#
|
||||
# XPath Limits
|
||||
jdk.xml.xpathExprGrpLimit=10
|
||||
jdk.xml.xpathExprOpLimit=100
|
||||
jdk.xml.xpathTotalOpLimit=10000
|
||||
|
Loading…
x
Reference in New Issue
Block a user