This commit is contained in:
Lana Steuck 2016-12-01 21:40:31 +00:00
commit 9c202409fc
24 changed files with 484 additions and 32 deletions

View File

@ -4,4 +4,3 @@
^drop_included/
^webrev
/nbproject/private/
^.hgtip

View File

@ -471,8 +471,7 @@ public final class TemplatesImpl implements Templates, Serializable {
String pn = _tfactory.getPackageName();
assert pn != null && pn.length() > 0;
ModuleDescriptor descriptor
= new ModuleDescriptor.Builder(mn)
ModuleDescriptor descriptor = ModuleDescriptor.module(mn)
.requires("java.xml")
.exports(pn)
.build();

View File

@ -30,6 +30,7 @@ import java.math.BigInteger;
import java.util.GregorianCalendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl;
/**
* Factory that creates new {@code javax.xml.datatype} {@code Object}s that map XML to/from Java {@code Object}s.
@ -135,6 +136,20 @@ public abstract class DatatypeFactory {
protected DatatypeFactory() {
}
/**
* Creates a new instance of the {@code DatatypeFactory} {@linkplain
* #DATATYPEFACTORY_IMPLEMENTATION_CLASS builtin system-default
* implementation}.
*
* @return A new instance of the {@code DatatypeFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static DatatypeFactory newDefaultInstance() {
return new DatatypeFactoryImpl();
}
/**
* Obtain a new instance of a {@code DatatypeFactory}.
*

View File

@ -25,6 +25,7 @@
package javax.xml.parsers;
import com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl;
import javax.xml.validation.Schema;
/**
@ -53,6 +54,19 @@ public abstract class DocumentBuilderFactory {
protected DocumentBuilderFactory () {
}
/**
* Creates a new instance of the {@code DocumentBuilderFactory} builtin
* system-default implementation.
*
* @return A new instance of the {@code DocumentBuilderFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static DocumentBuilderFactory newDefaultInstance() {
return new DocumentBuilderFactoryImpl();
}
/**
* Obtain a new instance of a
* {@code DocumentBuilderFactory}. This static method creates
@ -93,7 +107,8 @@ public abstract class DocumentBuilderFactory {
* </li>
* <li>
* <p>
* Otherwise, the system-default implementation is returned.
* Otherwise, the {@linkplain #newDefaultInstance() system-default}
* implementation is returned.
* </li>
* </ul>
*

View File

@ -25,6 +25,7 @@
package javax.xml.parsers;
import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
import javax.xml.validation.Schema;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@ -58,6 +59,19 @@ public abstract class SAXParserFactory {
}
/**
* Creates a new instance of the {@code SAXParserFactory} builtin
* system-default implementation.
*
* @return A new instance of the {@code SAXParserFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static SAXParserFactory newDefaultInstance() {
return new SAXParserFactoryImpl();
}
/**
* Obtain a new instance of a {@code SAXParserFactory}. This
* static method creates a new factory instance
@ -97,7 +111,8 @@ public abstract class SAXParserFactory {
* </li>
* <li>
* <p>
* Otherwise the system-default implementation is returned.
* Otherwise, the {@linkplain #newDefaultInstance() system-default}
* implementation is returned.
* </li>
* </ul>
*

View File

@ -27,6 +27,7 @@
*/
package javax.xml.stream;
import com.sun.xml.internal.stream.events.XMLEventFactoryImpl;
import java.util.Iterator;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
@ -53,6 +54,19 @@ public abstract class XMLEventFactory {
static final String DEFAULIMPL = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl";
/**
* Creates a new instance of the {@code XMLEventFactory} builtin
* system-default implementation.
*
* @return A new instance of the {@code XMLEventFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static XMLEventFactory newDefaultFactory() {
return new XMLEventFactoryImpl();
}
/**
* Creates a new instance of the factory in exactly the same manner as the
* {@link #newFactory()} method.
@ -108,7 +122,8 @@ public abstract class XMLEventFactory {
* </li>
* <li>
* <p>
* Otherwise, the system-default implementation is returned.
* Otherwise, the {@linkplain #newDefaultFactory() system-default}
* implementation is returned.
* </li>
* </ul>
* <p>

View File

@ -28,6 +28,7 @@
package javax.xml.stream;
import com.sun.xml.internal.stream.XMLInputFactoryImpl;
import javax.xml.stream.util.XMLEventAllocator;
import javax.xml.transform.Source;
@ -143,6 +144,19 @@ public abstract class XMLInputFactory {
protected XMLInputFactory(){}
/**
* Creates a new instance of the {@code XMLInputFactory} builtin
* system-default implementation.
*
* @return A new instance of the {@code XMLInputFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static XMLInputFactory newDefaultFactory() {
return new XMLInputFactoryImpl();
}
/**
* Creates a new instance of the factory in exactly the same manner as the
* {@link #newFactory()} method.
@ -195,7 +209,8 @@ public abstract class XMLInputFactory {
* ClassLoader#getSystemClassLoader() system class loader} will be used.
* </li>
* <li>
* <p>Otherwise, the system-default implementation is returned.
* <p>Otherwise, the {@linkplain #newDefaultFactory() system-default}
* implementation is returned.
* </li>
* </ul>
* <p>

View File

@ -28,6 +28,7 @@
package javax.xml.stream;
import com.sun.xml.internal.stream.XMLOutputFactoryImpl;
import javax.xml.transform.Result;
/**
@ -120,6 +121,19 @@ public abstract class XMLOutputFactory {
protected XMLOutputFactory(){}
/**
* Creates a new instance of the {@code XMLOutputFactory} builtin
* system-default implementation.
*
* @return A new instance of the {@code XMLOutputFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static XMLOutputFactory newDefaultFactory() {
return new XMLOutputFactoryImpl();
}
/**
* Creates a new instance of the factory in exactly the same manner as the
* {@link #newFactory()} method.
@ -175,7 +189,8 @@ public abstract class XMLOutputFactory {
* </li>
* <li>
* <p>
* Otherwise, the system-default implementation is returned.
* Otherwise, the {@linkplain #newDefaultFactory() system-default}
* implementation is returned.
* </li>
* </ul>
* <p>

View File

@ -25,6 +25,8 @@
package javax.xml.transform;
import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
/**
* <p>A TransformerFactory instance can be used to create
* {@link javax.xml.transform.Transformer} and
@ -50,6 +52,19 @@ public abstract class TransformerFactory {
/**
* Creates a new instance of the {@code TransformerFactory} builtin
* system-default implementation.
*
* @return A new instance of the {@code TransformerFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static TransformerFactory newDefaultInstance() {
return TransformerFactoryImpl.newTransformerFactoryNoServiceLoader();
}
/**
* Obtain a new instance of a {@code TransformerFactory}.
* This static method creates a new factory instance.
@ -89,7 +104,8 @@ public abstract class TransformerFactory {
* </li>
* <li>
* <p>
* Otherwise, the system-default implementation is returned.
* Otherwise, the {@linkplain #newDefaultInstance() system-default}
* implementation is returned.
* </li>
* </ul>
*

View File

@ -25,6 +25,7 @@
package javax.xml.validation;
import com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory;
import java.io.File;
import java.net.URL;
import javax.xml.transform.Source;
@ -123,6 +124,24 @@ public abstract class SchemaFactory {
protected SchemaFactory() {
}
/**
* Creates a new instance of the {@code SchemaFactory} builtin
* system-default implementation.
*
* @implSpec The {@code SchemaFactory} builtin
* system-default implementation is only required to support the
* <a href="http://www.w3.org/TR/xmlschema-1">W3C XML Schema 1.0</a>,
* but may support additional <a href="#schemaLanguage">schema languages</a>.
*
* @return A new instance of the {@code SchemaFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static SchemaFactory newDefaultInstance() {
return XMLSchemaFactory.newXMLSchemaFactoryNoServiceLoader();
}
/**
* Lookup an implementation of the {@code SchemaFactory} that supports the specified
* schema language and return it.
@ -179,7 +198,8 @@ public abstract class SchemaFactory {
* <li>
* <p>
* Platform default {@code SchemaFactory} is located
* in a implementation specific way. There must be a platform default
* in an implementation specific way. There must be a
* {@linkplain #newDefaultInstance() platform default}
* {@code SchemaFactory} for W3C XML Schema.
* </li>
* </ol>

View File

@ -25,6 +25,8 @@
package javax.xml.xpath;
import com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl;
/**
* <p>An {@code XPathFactory} instance can be used to create
* {@link javax.xml.xpath.XPath} objects.</p>
@ -73,6 +75,25 @@ public abstract class XPathFactory {
protected XPathFactory() {
}
/**
* Creates a new instance of the {@code XPathFactory} builtin
* system-default implementation.
*
* @implSpec The {@code XPathFactory} builtin
* system-default implementation is only required to support the
* {@link #DEFAULT_OBJECT_MODEL_URI default object model}, the
* {@linkplain org.w3c.dom W3C DOM}, but may support additional
* object models.
*
* @return A new instance of the {@code XPathFactory} builtin
* system-default implementation.
*
* @since 9
*/
public static XPathFactory newDefaultInstance() {
return XPathFactoryImpl.newXPathFactoryNoServiceLoader();
}
/**
* <p>Get a new {@code XPathFactory} instance using the default object model,
* {@link #DEFAULT_OBJECT_MODEL_URI},
@ -153,8 +174,11 @@ public abstract class XPathFactory {
* </li>
* <li>
* <p>
* Platform default {@code XPathFactory} is located in a platform specific way.
* There must be a platform default XPathFactory for the W3C DOM, i.e. {@link #DEFAULT_OBJECT_MODEL_URI}.
* Platform default {@code XPathFactory} is located in a platform
* specific way.
* There must be a {@linkplain #newDefaultInstance() platform default}
* {@code XPathFactory} for the W3C DOM, i.e.
* {@link #DEFAULT_OBJECT_MODEL_URI}.
* </li>
* </ol>
* <p>If everything fails, an {@code XPathFactoryConfigurationException} will be thrown.

View File

@ -24,7 +24,7 @@
*/
module jdk.xml.dom {
requires public java.xml;
requires transitive java.xml;
exports org.w3c.dom.css;
exports org.w3c.dom.html;
exports org.w3c.dom.stylesheets;

View File

@ -23,7 +23,7 @@ modules=java.xml
groups=TEST.groups
# Minimum jtreg version
requiredVersion=4.2 b03
requiredVersion=4.2 b04
# Use new module options
useNewOptions=true

View File

@ -45,6 +45,7 @@ import org.testng.annotations.Test;
* @test
* @bug 8077931
* @library /javax/xml/jaxp/libs
* @modules java.xml/javax.xml.catalog:open
* @run testng/othervm -DrunSecMngr=true catalog.DeferFeatureTest
* @run testng/othervm catalog.DeferFeatureTest
* @summary This case tests whether the catalogs specified in delegateSystem,

View File

@ -24,6 +24,9 @@
package javax.xml.datatype.ptests;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertEquals;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
@ -37,6 +40,7 @@ import org.testng.annotations.Test;
/*
* @test
* @bug 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.datatype.ptests.FactoryNewInstanceTest
* @run testng/othervm javax.xml.datatype.ptests.FactoryNewInstanceTest
@ -45,13 +49,30 @@ import org.testng.annotations.Test;
@Listeners({jaxp.library.BasePolicy.class})
public class FactoryNewInstanceTest {
private static final String DATATYPE_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl";
private static final String DEFAULT_IMPL_CLASS =
"com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl";
private static final String DATATYPE_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
@DataProvider(name = "parameters")
public Object[][] getValidateParameters() {
return new Object[][] { { DATATYPE_FACTORY_CLASSNAME, null }, { DATATYPE_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultInstance() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
DatatypeFactory dtf1 = DatatypeFactory.newDefaultInstance();
DatatypeFactory dtf2 = DatatypeFactory.newInstance();
assertNotSame(dtf1, dtf2, "same instance returned:");
assertSame(dtf1.getClass(), dtf2.getClass(),
"unexpected class mismatch for newDefaultInstance():");
assertEquals(dtf1.getClass().getName(), DEFAULT_IMPL_CLASS);
}
/*
* test for DatatypeFactory.newInstance(java.lang.String factoryClassName,
* java.lang.ClassLoader classLoader) factoryClassName points to correct

View File

@ -34,6 +34,8 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertNotSame;
import java.io.BufferedReader;
import java.io.Closeable;
@ -66,7 +68,7 @@ import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
/**
* @bug 8080907
* @bug 8080907 8169778
* This checks the methods of DocumentBuilderFactoryImpl.
*/
/*
@ -77,10 +79,17 @@ import org.xml.sax.helpers.DefaultHandler;
*/
@Listeners({jaxp.library.FilePolicy.class})
public class DocumentBuilderFactoryTest {
/**
* DocumentBuilderFactory builtin system-default implementation class name.
*/
private static final String DEFAULT_IMPL_CLASS =
"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl";
/**
* DocumentBuilderFactory implementation class name.
*/
private static final String DOCUMENT_BUILDER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl";
private static final String DOCUMENT_BUILDER_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
/**
* Provide valid DocumentBuilderFactory instantiation parameters.
@ -92,6 +101,21 @@ public class DocumentBuilderFactoryTest {
return new Object[][] { { DOCUMENT_BUILDER_FACTORY_CLASSNAME, null }, { DOCUMENT_BUILDER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultInstance() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
DocumentBuilderFactory dbf1 = DocumentBuilderFactory.newDefaultInstance();
DocumentBuilderFactory dbf2 = DocumentBuilderFactory.newInstance();
assertNotSame(dbf1, dbf2, "same instance returned:");
assertSame(dbf1.getClass(), dbf2.getClass(),
"unexpected class mismatch for newDefaultInstance():");
assertEquals(dbf1.getClass().getName(), DEFAULT_IMPL_CLASS);
}
/**
* Test for DocumentBuilderFactory.newInstance(java.lang.String
* factoryClassName, java.lang.ClassLoader classLoader) factoryClassName

View File

@ -24,6 +24,9 @@
package javax.xml.parsers.ptests;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertEquals;
import javax.xml.parsers.SAXParserFactory;
@ -35,6 +38,7 @@ import org.testng.annotations.Test;
*/
/*
* @test
* @bug 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.SAXParserFactTest
* @run testng/othervm javax.xml.parsers.ptests.SAXParserFactTest
@ -48,6 +52,23 @@ public class SAXParserFactTest {
private static final String VALIDATION = "http://xml.org/sax/features/validation";
private static final String EXTERNAL_G_ENTITIES = "http://xml.org/sax/features/external-general-entities";
private static final String EXTERNAL_P_ENTITIES = "http://xml.org/sax/features/external-parameter-entities";
private static final String DEFAULT_IMPL_CLASS =
"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
/**
* Test if newDefaultInstance() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
SAXParserFactory spf1 = SAXParserFactory.newDefaultInstance();
SAXParserFactory spf2 = SAXParserFactory.newInstance();
assertNotSame(spf1, spf2, "same instance returned:");
assertSame(spf1.getClass(), spf2.getClass(),
"unexpected class mismatch for newDefaultInstance():");
assertEquals(spf1.getClass().getName(), DEFAULT_IMPL_CLASS);
}
/**
* Test if newSAXParser() method returns SAXParser.

View File

@ -27,6 +27,9 @@ import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertEquals;
import javax.xml.stream.XMLEventFactory;
@ -38,6 +41,7 @@ import org.testng.annotations.Test;
/*
* @test
* @bug 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest
* @run testng/othervm javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest
@ -46,12 +50,31 @@ import org.testng.annotations.Test;
@Listeners({jaxp.library.BasePolicy.class})
public class XMLEventFactoryNewInstanceTest {
private static final String XMLEVENT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl";
private static final String XMLEVENT_FACRORY_ID = "javax.xml.stream.XMLEventFactory";
private static final String DEFAULT_IMPL_CLASS =
"com.sun.xml.internal.stream.events.XMLEventFactoryImpl";
private static final String XMLEVENT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
private static final String XMLEVENT_FACTORY_ID = "javax.xml.stream.XMLEventFactory";
@DataProvider(name = "parameters")
public Object[][] getValidateParameters() {
return new Object[][] { { XMLEVENT_FACRORY_ID, null }, { XMLEVENT_FACRORY_ID, this.getClass().getClassLoader() } };
return new Object[][] {
{ XMLEVENT_FACTORY_ID, null },
{ XMLEVENT_FACTORY_ID, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultFactory() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
XMLEventFactory ef1 = XMLEventFactory.newDefaultFactory();
XMLEventFactory ef2 = XMLEventFactory.newFactory();
assertNotSame(ef1, ef2, "same instance returned:");
assertSame(ef1.getClass(), ef2.getClass(),
"unexpected class mismatch for newDefaultFactory():");
assertEquals(ef1.getClass().getName(), DEFAULT_IMPL_CLASS);
}
/*
@ -62,12 +85,12 @@ public class XMLEventFactoryNewInstanceTest {
*/
@Test(dataProvider = "parameters")
public void testNewFactory(String factoryId, ClassLoader classLoader) {
setSystemProperty(XMLEVENT_FACRORY_ID, XMLEVENT_FACTORY_CLASSNAME);
setSystemProperty(XMLEVENT_FACTORY_ID, XMLEVENT_FACTORY_CLASSNAME);
try {
XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader);
assertNotNull(xef);
} finally {
clearSystemProperty(XMLEVENT_FACRORY_ID);
clearSystemProperty(XMLEVENT_FACTORY_ID);
}
}

View File

@ -27,6 +27,9 @@ import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertEquals;
import javax.xml.stream.XMLInputFactory;
@ -38,6 +41,7 @@ import org.testng.annotations.Test;
/*
* @test
* @bug 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest
* @run testng/othervm javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest
@ -46,12 +50,31 @@ import org.testng.annotations.Test;
@Listeners({jaxp.library.BasePolicy.class})
public class XMLInputFactoryNewInstanceTest {
private static final String XMLINPUT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
private static final String XMLINPUT_FACRORY_ID = "javax.xml.stream.XMLInputFactory";
private static final String DEFAULT_IMPL_CLASS =
"com.sun.xml.internal.stream.XMLInputFactoryImpl";
private static final String XMLINPUT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
private static final String XMLINPUT_FACTORY_ID = "javax.xml.stream.XMLInputFactory";
@DataProvider(name = "parameters")
public Object[][] getValidateParameters() {
return new Object[][] { { XMLINPUT_FACRORY_ID, null }, { XMLINPUT_FACRORY_ID, this.getClass().getClassLoader() } };
return new Object[][] {
{ XMLINPUT_FACTORY_ID, null },
{ XMLINPUT_FACTORY_ID, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultFactory() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
XMLInputFactory if1 = XMLInputFactory.newDefaultFactory();
XMLInputFactory if2 = XMLInputFactory.newFactory();
assertNotSame(if1, if2, "same instance returned:");
assertSame(if1.getClass(), if2.getClass(),
"unexpected class mismatch for newDefaultFactory():");
assertEquals(if1.getClass().getName(), DEFAULT_IMPL_CLASS);
}
/*
@ -62,12 +85,12 @@ public class XMLInputFactoryNewInstanceTest {
*/
@Test(dataProvider = "parameters")
public void testNewFactory(String factoryId, ClassLoader classLoader) {
setSystemProperty(XMLINPUT_FACRORY_ID, XMLINPUT_FACTORY_CLASSNAME);
setSystemProperty(XMLINPUT_FACTORY_ID, XMLINPUT_FACTORY_CLASSNAME);
try {
XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader);
assertNotNull(xif);
} finally {
clearSystemProperty(XMLINPUT_FACRORY_ID);
clearSystemProperty(XMLINPUT_FACTORY_ID);
}
}

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2016, 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 javax.xml.stream.ptests;
import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertEquals;
import javax.xml.stream.XMLOutputFactory;
import jaxp.library.JAXPDataProvider;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/*
* @test
* @bug 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLOutputFactoryNewInstanceTest
* @run testng/othervm javax.xml.stream.ptests.XMLOutputFactoryNewInstanceTest
* @summary Tests for XMLOutputFactory.newFactory(factoryId , classLoader)
*/
@Listeners({jaxp.library.BasePolicy.class})
public class XMLOutputFactoryNewInstanceTest {
private static final String DEFAULT_IMPL_CLASS =
"com.sun.xml.internal.stream.XMLOutputFactoryImpl";
private static final String XMLOUTPUT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
private static final String XMLOUTPUT_FACTORY_ID = "javax.xml.stream.XMLOutputFactory";
@DataProvider(name = "parameters")
public Object[][] getValidateParameters() {
return new Object[][] {
{ XMLOUTPUT_FACTORY_ID, null },
{ XMLOUTPUT_FACTORY_ID, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultFactory() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
XMLOutputFactory of1 = XMLOutputFactory.newDefaultFactory();
XMLOutputFactory of2 = XMLOutputFactory.newFactory();
assertNotSame(of1, of2, "same instance returned:");
assertSame(of1.getClass(), of2.getClass(),
"unexpected class mismatch for newDefaultFactory():");
assertEquals(of1.getClass().getName(), DEFAULT_IMPL_CLASS);
}
/*
* test for XMLOutputFactory.newFactory(java.lang.String factoryId,
* java.lang.ClassLoader classLoader) factoryClassName points to correct
* implementation of javax.xml.stream.XMLOutputFactory , should return
* newInstance of XMLOutputFactory
*/
@Test(dataProvider = "parameters")
public void testNewFactory(String factoryId, ClassLoader classLoader) {
setSystemProperty(XMLOUTPUT_FACTORY_ID, XMLOUTPUT_FACTORY_CLASSNAME);
try {
XMLOutputFactory xif = XMLOutputFactory.newFactory(factoryId, classLoader);
assertNotNull(xif);
} finally {
clearSystemProperty(XMLOUTPUT_FACTORY_ID);
}
}
/*
* test for XMLOutputFactory.newFactory(java.lang.String factoryClassName,
* java.lang.ClassLoader classLoader) factoryClassName is null , should
* throw NullPointerException
*/
@Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) {
XMLOutputFactory.newFactory(factoryId, classLoader);
}
}

View File

@ -28,6 +28,9 @@ import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertEquals;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -55,16 +58,23 @@ import org.w3c.dom.Document;
*/
/*
* @test
* @bug 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformerFactoryTest
* @run testng/othervm javax.xml.transform.ptests.TransformerFactoryTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class TransformerFactoryTest {
/**
* TransformerFactory builtin system-default implementation class name.
*/
private static final String DEFAULT_IMPL_CLASS =
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
/**
* TransformerFactory implementation class name.
*/
private static final String TRANSFORMER_FACTORY_CLASSNAME = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
private static final String TRANSFORMER_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
/**
* Provide valid TransformerFactory instantiation parameters.
@ -76,6 +86,21 @@ public class TransformerFactoryTest {
return new Object[][] { { TRANSFORMER_FACTORY_CLASSNAME, null }, { TRANSFORMER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultInstance() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
TransformerFactory tf1 = TransformerFactory.newDefaultInstance();
TransformerFactory tf2 = TransformerFactory.newInstance();
assertNotSame(tf1, tf2, "same instance returned:");
assertSame(tf1.getClass(), tf2.getClass(),
"unexpected class mismatch for newDefaultInstance():");
assertEquals(tf1.getClass().getName(), DEFAULT_IMPL_CLASS);
}
/**
* Test for TransformerFactory.newInstance(java.lang.String
* factoryClassName, java.lang.ClassLoader classLoader) factoryClassName

View File

@ -28,6 +28,9 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.File;
@ -66,7 +69,7 @@ import org.xml.sax.SAXParseException;
/*
* @test
* @bug 8080907
* @bug 8080907 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.validation.ptests.SchemaFactoryTest
* @run testng/othervm javax.xml.validation.ptests.SchemaFactoryTest
@ -102,6 +105,25 @@ public class SchemaFactoryTest {
{ W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultInstance() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
SchemaFactory sf1 = SchemaFactory.newDefaultInstance();
SchemaFactory sf2 = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
assertNotSame(sf1, sf2, "same instance returned:");
assertSame(sf1.getClass(), sf2.getClass(),
"unexpected class mismatch for newDefaultInstance():");
assertEquals(sf1.getClass().getName(), DEFAULT_IMPL_CLASS);
assertTrue(sf1.isSchemaLanguageSupported(W3C_XML_SCHEMA_NS_URI),
"isSchemaLanguageSupported(W3C_XML_SCHEMA_NS_URI):");
assertFalse(sf1.isSchemaLanguageSupported(UNRECOGNIZED_NAME),
"isSchemaLanguageSupported(UNRECOGNIZED_NAME):");
}
/*
* test for SchemaFactory.newInstance(java.lang.String schemaLanguage,
* java.lang.String factoryClassName, java.lang.ClassLoader classLoader)
@ -394,7 +416,10 @@ public class SchemaFactoryTest {
private static final String UNRECOGNIZED_NAME = "http://xml.org/sax/features/namespace-prefixes";
private static final String SCHEMA_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory";
private static final String DEFAULT_IMPL_CLASS =
"com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory";
private static final String SCHEMA_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
private SchemaFactory sf;
private XMLInputFactory ifac;

View File

@ -24,7 +24,13 @@
package javax.xml.xpath.ptests;
import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL;
import static javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertFalse;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
@ -41,6 +47,7 @@ import org.testng.annotations.Test;
*/
/*
* @test
* @bug 8169778
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.xpath.ptests.XPathFactoryTest
* @run testng/othervm javax.xml.xpath.ptests.XPathFactoryTest
@ -57,10 +64,16 @@ public class XPathFactoryTest {
*/
private static final String INVALID_URL = "http://java.sun.com/jaxp/xpath/dom1";
/**
* XPathFactory builtin system-default implementation class name.
*/
private static final String DEFAULT_IMPL_CLASS =
"com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl";
/**
* XPathFactory implementation class name.
*/
private static final String XPATH_FACTORY_CLASSNAME = "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl";
private static final String XPATH_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS;
/**
@ -73,6 +86,25 @@ public class XPathFactoryTest {
return new Object[][] { { VALID_URL, XPATH_FACTORY_CLASSNAME, null }, { VALID_URL, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
}
/**
* Test if newDefaultInstance() method returns an instance
* of the expected factory.
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultInstance() throws Exception {
XPathFactory xpf1 = XPathFactory.newDefaultInstance();
XPathFactory xpf2 = XPathFactory.newInstance(DEFAULT_OBJECT_MODEL_URI);
assertNotSame(xpf1, xpf2, "same instance returned:");
assertSame(xpf1.getClass(), xpf2.getClass(),
"unexpected class mismatch for newDefaultInstance():");
assertEquals(xpf1.getClass().getName(), DEFAULT_IMPL_CLASS);
assertTrue(xpf1.isObjectModelSupported(DEFAULT_OBJECT_MODEL_URI),
"isObjectModelSupported(DEFAULT_OBJECT_MODEL_URI):");
assertFalse(xpf1.isObjectModelSupported(INVALID_URL),
"isObjectModelSupported(INVALID_URL):");
}
/**
* Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String
* factoryClassName, java.lang.ClassLoader classLoader) factoryClassName

View File

@ -23,6 +23,7 @@
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
import java.lang.module.ModuleDescriptor.Provides;
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.util.Arrays;
@ -48,7 +49,8 @@ public class Main {
.map(xmlProviderName -> Layer.boot().findModule(xmlProviderName).get())
.mapToLong(
// services provided by the implementation in provider module
provider -> provider.getDescriptor().provides().keySet().stream()
provider -> provider.getDescriptor().provides().stream()
.map(Provides::service)
.filter(serviceName -> {
allServices.remove(serviceName); // remove service provided by
// customized module from allServices