--- old/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java 2015-01-28 03:06:26.013897960 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java 2015-01-28 03:06:25.859878385 -0800 @@ -26,27 +26,37 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FilePermission; import java.io.FileReader; + import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; + import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR; import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; + import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; + import jaxp.library.JAXPFileBaseTest; import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.compareWithGold; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; + +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -59,6 +69,42 @@ * This checks the methods of DocumentBuilderFactoryImpl. */ public class DocumentBuilderFactoryTest extends JAXPFileBaseTest { + private static final String DOCUMENT_BUILDER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { DOCUMENT_BUILDER_FACTORY_CLASSNAME, null }, { DOCUMENT_BUILDER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + } + + /* + * test for DocumentBuilderFactory.newInstance(java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName + * points to correct implementation of + * javax.xml.parsers.DocumentBuilderFactory , should return newInstance of + * DocumentBuilderFactory + */ + @Test(dataProvider = "parameters") + public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws ParserConfigurationException { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(factoryClassName, classLoader); + DocumentBuilder builder = dbf.newDocumentBuilder(); + assertNotNull(builder); + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { null, null }, { null, this.getClass().getClassLoader() } }; + } + + /* + * test for DocumentBuilderFactory.newInstance(java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is + * null , should throw FactoryConfigurationError + */ + @Test(expectedExceptions = FactoryConfigurationError.class, dataProvider = "invalid-parameters") + public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) { + DocumentBuilderFactory.newInstance(factoryClassName, classLoader); + } + /** * Test the default functionality of schema support method. * @throws Exception If any errors occur. --- old/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java 2015-01-28 03:06:26.344940034 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java 2015-01-28 03:06:26.271930755 -0800 @@ -23,25 +23,67 @@ package javax.xml.transform.ptests; import java.io.*; -import java.io.FileOutputStream; + import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; + import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; + import javax.xml.transform.stream.*; + import jaxp.library.JAXPFileBaseTest; 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 org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.w3c.dom.*; /** * Class containing the test cases for TransformerFactory API's - * getAssociatedStyleSheet method. + * getAssociatedStyleSheet method and TransformerFactory.newInstance(factoryClassName , classLoader). */ public class TransformerFactoryTest extends JAXPFileBaseTest { + private static final String TRANSFORMER_FACTORY_CLASSNAME = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { TRANSFORMER_FACTORY_CLASSNAME, null }, { TRANSFORMER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + } + + /* + * test for TransformerFactory.newInstance(java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName + * points to correct implementation of + * javax.xml.transform.TransformerFactory , should return newInstance of + * TransformerFactory + */ + @Test(dataProvider = "parameters") + public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws TransformerConfigurationException { + TransformerFactory tf = TransformerFactory.newInstance(factoryClassName, classLoader); + Transformer transformer = tf.newTransformer(); + assertNotNull(transformer); + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { null, null }, { null, this.getClass().getClassLoader() } }; + } + + /* + * test for TransformerFactory.newInstance(java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is + * null , should throw TransformerFactoryConfigurationError + */ + @Test(expectedExceptions = TransformerFactoryConfigurationError.class, dataProvider = "invalid-parameters") + public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) { + TransformerFactory.newInstance(factoryClassName, classLoader); + } + /** * This test case checks for the getAssociatedStylesheet method * of TransformerFactory. --- old/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java 2015-01-28 03:06:26.677982362 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java 2015-01-28 03:06:26.597972193 -0800 @@ -24,10 +24,15 @@ package javax.xml.xpath.ptests; import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL; + +import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactoryConfigurationException; + import jaxp.library.JAXPBaseTest; -import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.Assert.assertNotNull; + +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -43,6 +48,62 @@ * Invalid URL not able to create a XPath factory. */ private static final String INVALID_URL = "http://java.sun.com/jaxp/xpath/dom1"; + + private static final String URI = "http://java.sun.com/jaxp/xpath/dom"; + private static final String XPATH_FACTORY_CLASSNAME = "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { URI, XPATH_FACTORY_CLASSNAME, null }, { URI, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + } + + /* + * test for XPathFactory.newInstance(java.lang.String uri, java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName + * points to correct implementation of javax.xml.xpath.XPathFactory , should + * return newInstance of XPathFactory + */ + @Test(dataProvider = "parameters") + public void testNewInstance(String uri, String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException { + XPathFactory xpf = XPathFactory.newInstance(uri, factoryClassName, classLoader); + XPath xpath = xpf.newXPath(); + assertNotNull(xpath); + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { URI, null, null }, { URI, null, this.getClass().getClassLoader() } }; + } + + /* + * test for XPathFactory.newInstance(java.lang.String uri, java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is + * null , should throw XPathFactoryConfigurationException + */ + @Test(expectedExceptions = XPathFactoryConfigurationException.class, dataProvider = "invalid-parameters") + public void testNewInstanceWithNullFactoryClassName(String uri, String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException { + XPathFactory.newInstance(uri, factoryClassName, classLoader); + } + + /* + * test for XPathFactory.newInstance(java.lang.String uri, java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) uri is null , should + * throw NPE + */ + @Test(expectedExceptions = NullPointerException.class) + public void testNewInstanceWithNullUri() throws XPathFactoryConfigurationException { + XPathFactory.newInstance(null, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + } + + /* + * test for XPathFactory.newInstance(java.lang.String uri, java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) uri is empty, should + * throw IllegalArgumentException + */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNewInstanceWithEmptyUri() throws XPathFactoryConfigurationException { + XPathFactory.newInstance("", XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + } /** * Test for constructor - XPathFactory.newInstance(). --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java 2015-01-28 03:06:26.919012995 -0800 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2015, 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.datatype.ptests; + +import static org.testng.Assert.assertNotNull; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; + +import jaxp.library.JAXPBaseTest; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/* + * @summary Tests for DatatypeFactory.newInstance(factoryClassName , classLoader) + */ +public class FactoryNewInstanceTest extends JAXPBaseTest { + + private static final String DATATYPE_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { DATATYPE_FACTORY_CLASSNAME, null }, { DATATYPE_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + } + + /* + * test for DatatypeFactory.newInstance(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName points to correct + * implementation of javax.xml.datatype.DatatypeFactory , should return + * newInstance of DatatypeFactory + */ + @Test(dataProvider = "parameters") + public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(DATATYPE_FACTORY_CLASSNAME, null); + Duration duration = dtf.newDuration(true, 1, 1, 1, 1, 1, 1); + assertNotNull(duration); + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { null, null }, { null, this.getClass().getClassLoader() } }; + } + + /* + * test for DatatypeFactory.newInstance(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName is null , should + * throw DatatypeConfigurationException + */ + @Test(expectedExceptions = DatatypeConfigurationException.class, dataProvider = "invalid-parameters") + public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) throws DatatypeConfigurationException { + DatatypeFactory.newInstance(factoryClassName, classLoader); + } + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java 2015-01-28 03:06:27.221051383 -0800 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1999, 2015, 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.parsers.ptests; + +import static org.testng.Assert.assertNotNull; + +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import jaxp.library.JAXPBaseTest; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + +/* + * @summary Tests for SAXParserFactory.newInstance(factoryClassName , classLoader) + */ +public class SAXFactoryNewInstanceTest extends JAXPBaseTest { + + private static final String SAXPARSER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { SAXPARSER_FACTORY_CLASSNAME, null }, { SAXPARSER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + } + + /* + * test for SAXParserFactory.newInstance(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName points to correct + * implementation of javax.xml.parsers.SAXParserFactory , should return + * newInstance of SAXParserFactory + */ + @Test(dataProvider = "parameters") + public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws ParserConfigurationException, SAXException { + SAXParserFactory spf = SAXParserFactory.newInstance(factoryClassName, classLoader); + SAXParser sp = spf.newSAXParser(); + assertNotNull(sp); + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { null, null }, { null, this.getClass().getClassLoader() } }; + } + + /* + * test for SAXParserFactory.newInstance(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName is null , should + * throw FactoryConfigurationError + */ + @Test(expectedExceptions = FactoryConfigurationError.class, dataProvider = "invalid-parameters") + public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) { + SAXParserFactory.newInstance(factoryClassName, classLoader); + } + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java 2015-01-28 03:06:27.560094474 -0800 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1999, 2015, 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 org.testng.Assert.assertNotNull; + +import javax.xml.stream.XMLEventFactory; + +import jaxp.library.JAXPBaseTest; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/* + * @summary Tests for XMLEventFactory.newFactory(factoryId , classLoader) + */ +public class XMLEventFactoryNewInstanceTest extends JAXPBaseTest { + + 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"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { XMLEVENT_FACRORY_ID, null }, { XMLEVENT_FACRORY_ID, this.getClass().getClassLoader() } }; + } + + /* + * test for XMLEventFactory.newFactory(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName points to correct + * implementation of javax.xml.stream.XMLEventFactory , should return + * newInstance of XMLEventFactory + */ + @Test(dataProvider = "parameters") + public void testNewFactory(String factoryId, ClassLoader classLoader) { + setSystemProperty(XMLEVENT_FACRORY_ID, XMLEVENT_FACTORY_CLASSNAME); + try { + XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader); + assertNotNull(xef); + } finally { + setSystemProperty(XMLEVENT_FACRORY_ID, null); + } + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { null, null }, { null, this.getClass().getClassLoader() } }; + } + + /* + * test for XMLEventFactory.newFactory(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName is null , should + * throw NullPointerException + */ + @Test(expectedExceptions = NullPointerException.class, dataProvider = "invalid-parameters") + public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) { + XMLEventFactory.newFactory(null, null); + } + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java 2015-01-28 03:06:27.860132607 -0800 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1999, 2015, 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 org.testng.Assert.assertNotNull; + +import javax.xml.stream.XMLInputFactory; + +import jaxp.library.JAXPBaseTest; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/* + * @summary Tests for XMLInputFactory.newFactory(factoryId , classLoader) + */ +public class XMLInputFactoryNewInstanceTest extends JAXPBaseTest { + + private static final String XMLINPUT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.XMLInputFactoryImpl"; + private static final String XMLINPUT_FACRORY_ID = "javax.xml.stream.XMLInputFactory"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { XMLINPUT_FACRORY_ID, null }, { XMLINPUT_FACRORY_ID, this.getClass().getClassLoader() } }; + } + + /* + * test for XMLInputFactory.newFactory(java.lang.String factoryId, + * java.lang.ClassLoader classLoader) factoryClassName points to correct + * implementation of javax.xml.stream.XMLInputFactory , should return + * newInstance of XMLInputFactory + */ + @Test(dataProvider = "parameters") + public void testNewFactory(String factoryId, ClassLoader classLoader) { + setSystemProperty(XMLINPUT_FACRORY_ID, XMLINPUT_FACTORY_CLASSNAME); + try { + XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader); + assertNotNull(xif); + } finally { + setSystemProperty(XMLINPUT_FACRORY_ID, null); + } + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { null, null }, { null, this.getClass().getClassLoader() } }; + } + + /* + * test for XMLInputFactory.newFactory(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName is null , should + * throw NullPointerException + */ + @Test(expectedExceptions = NullPointerException.class, dataProvider = "invalid-parameters") + public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) { + XMLInputFactory.newFactory(factoryId, classLoader); + } + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java 2015-01-28 03:06:28.188174299 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1999, 2015, 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.transform.ptests; + +import java.io.ByteArrayOutputStream; +import java.io.File; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import jaxp.library.JAXPFileBaseTest; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; + +/* + * @bug 6384418 + * @summary verify the transforming won't throw any exception + */ +public class Bug6384418Test extends JAXPFileBaseTest { + + @Test + public void test() throws Exception { + TransformerFactory tfactory = TransformerFactory.newInstance(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document document = db.parse(new File(XML_DIR + "dataentry.xsl")); + DOMSource domSource = new DOMSource(document); + + Transformer transformer = tfactory.newTransformer(domSource); + StreamSource streamSource = new StreamSource(new File(XML_DIR + "test.xml")); + StreamResult streamResult = new StreamResult(new ByteArrayOutputStream()); + transformer.transform(streamSource, streamResult); + } + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java 2015-01-28 03:06:28.462209128 -0800 @@ -0,0 +1,387 @@ +/* + * Copyright (c) 1999, 2015, 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.transform.ptests; + +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; + +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.function.Supplier; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stax.StAXResult; +import javax.xml.transform.stax.StAXSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import jaxp.library.JAXPFileBaseTest; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; + +/* + * @summary Tests for variable combination of Transformer.transform(Source, Result) + */ +@Test(singleThreaded = true) +public class TransformTest extends JAXPFileBaseTest { + + /** + * Initialize the share objects. + * + * @throws IOException + * @throws SAXException + * @throws ParserConfigurationException + */ + @BeforeClass + public void setup() throws SAXException, IOException, ParserConfigurationException { + ifac = XMLInputFactory.newInstance(); + ofac = XMLOutputFactory.newInstance(); + tfac = TransformerFactory.newInstance(); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + db = dbf.newDocumentBuilder(); + + xml = Files.readAllBytes(Paths.get(XML_DIR + "cities.xml")); + template = Files.readAllBytes(Paths.get(XML_DIR + "cities.xsl")); + + xmlDoc = db.parse(xmlInputStream()); + } + + @DataProvider(name = "input-provider") + public Object[][] prepareTestCombination() throws Exception { + + Supplier staxStreamSource = () -> new StAXSource(getXMLStreamReader()); + Supplier staxEventSource = this::getStAXEventSource; + Supplier domSource = () -> new DOMSource(xmlDoc); + Supplier saxSource = () -> new SAXSource(new InputSource(xmlInputStream())); + Supplier streamSource = () -> new StreamSource(xmlInputStream()); + + Supplier staxStreamResult = () -> new StAXResult(getXMLStreamWriter()); + Supplier staxEventResult = () -> new StAXResult(getXMLEventWriter()); + Supplier saxResult = this::getHandlerSAXResult; + Supplier streamResult = () -> new StreamResult(transOutputStream()); + + Transformer domTemplateTransformer = createTransformer(getDomTemplate()); + Transformer saxTemplateTransformer = createTransformer(getSAXTemplate()); + Transformer streamTemplateTransformer = createTransformer(getStreamTemplate()); + Transformer noTemplateTransformer = createTransformer(null); + Transformer staxStreamTemplateTransformer = createTransformer(getStAXStreamTemplate()); + Transformer staxEventTemplateTransformer = createTransformer(getStAXEventTemplate()); + + return new Object[][] { + // StAX Stream + { staxStreamSource, staxStreamResult, domTemplateTransformer }, + { staxStreamSource, staxStreamResult, saxTemplateTransformer }, + { staxStreamSource, staxStreamResult, streamTemplateTransformer }, + { staxStreamSource, staxStreamResult, noTemplateTransformer }, + { staxStreamSource, staxStreamResult, staxStreamTemplateTransformer }, + { staxStreamSource, saxResult, domTemplateTransformer }, + { staxStreamSource, streamResult, domTemplateTransformer }, + { domSource, staxStreamResult, domTemplateTransformer }, + { saxSource, staxStreamResult, domTemplateTransformer }, + { streamSource, staxStreamResult, domTemplateTransformer }, + { staxStreamSource, streamResult, saxTemplateTransformer }, + { domSource, staxStreamResult, saxTemplateTransformer }, + { saxSource, staxStreamResult, saxTemplateTransformer }, + { streamSource, staxStreamResult, saxTemplateTransformer }, + { staxStreamSource, streamResult, streamTemplateTransformer }, + { domSource, staxStreamResult, streamTemplateTransformer }, + { saxSource, staxStreamResult, streamTemplateTransformer }, + { streamSource, staxStreamResult, streamTemplateTransformer }, + // StAX Event + { staxEventSource, staxEventResult, domTemplateTransformer }, + { staxEventSource, staxEventResult, saxTemplateTransformer }, + { staxEventSource, staxEventResult, streamTemplateTransformer }, + { staxEventSource, staxEventResult, noTemplateTransformer }, + { staxEventSource, staxEventResult, staxEventTemplateTransformer }, + { staxEventSource, saxResult, domTemplateTransformer }, + { staxEventSource, streamResult, domTemplateTransformer }, + { domSource, staxEventResult, domTemplateTransformer }, + { saxSource, staxEventResult, domTemplateTransformer }, + { streamSource, staxEventResult, domTemplateTransformer }, + { staxEventSource, streamResult, saxTemplateTransformer }, + { domSource, staxEventResult, saxTemplateTransformer }, + { saxSource, staxEventResult, saxTemplateTransformer }, + { streamSource, staxEventResult, saxTemplateTransformer }, + { staxEventSource, streamResult, streamTemplateTransformer }, + { domSource, staxEventResult, streamTemplateTransformer }, + { saxSource, staxEventResult, streamTemplateTransformer }, + { streamSource, staxEventResult, streamTemplateTransformer } }; + } + + /* + * run Transformer.transform(Source, Result) + */ + @Test(dataProvider = "input-provider") + public void testTransform(Supplier src, Supplier res, Transformer transformer) throws Throwable { + try { + transformer.transform(src.get(), res.get()); + } catch (WrapperException e) { + throw e.getCause(); + } + } + + private InputStream xmlInputStream() { + return new ByteArrayInputStream(xml); + } + + private InputStream templateInputStream() { + return new ByteArrayInputStream(template); + } + + private OutputStream transOutputStream() { + return new ByteArrayOutputStream(xml.length); + } + + private XMLStreamReader getXMLStreamReader() { + try { + return ifac.createXMLStreamReader(xmlInputStream()); + } catch (XMLStreamException e) { + throw new WrapperException(e); + } + } + + private XMLStreamWriter getXMLStreamWriter() { + try { + return ofac.createXMLStreamWriter(transOutputStream()); + } catch (XMLStreamException e) { + throw new WrapperException(e); + } + } + + private StAXSource getStAXEventSource() { + try { + return new StAXSource(ifac.createXMLEventReader(xmlInputStream())); + } catch (XMLStreamException e) { + throw new WrapperException(e); + } + } + + private XMLEventWriter getXMLEventWriter() { + try { + return ofac.createXMLEventWriter(transOutputStream()); + } catch (XMLStreamException e) { + throw new WrapperException(e); + } + } + + private SAXResult getHandlerSAXResult() { + SAXResult res = new SAXResult(); + MyContentHandler myContentHandler = new MyContentHandler(transOutputStream()); + res.setHandler(myContentHandler); + return res; + } + + private Source getDomTemplate() throws SAXException, IOException { + return new DOMSource(db.parse(templateInputStream())); + } + + private Source getSAXTemplate() { + return new SAXSource(new InputSource(templateInputStream())); + } + + private Source getStreamTemplate() { + return new StreamSource(templateInputStream()); + } + + private Source getStAXStreamTemplate() throws XMLStreamException { + return new StAXSource(ifac.createXMLStreamReader(templateInputStream())); + } + + private Source getStAXEventTemplate() throws XMLStreamException { + return new StAXSource(ifac.createXMLEventReader(templateInputStream())); + } + + private Transformer createTransformer(Source templateSource) throws TransformerConfigurationException { + Transformer transformer = (templateSource == null) ? tfac.newTransformer() : tfac.newTransformer(templateSource); + transformer.setOutputProperty("indent", "yes"); + return transformer; + + } + + private static class MyContentHandler implements ContentHandler { + private BufferedWriter bWriter; + + public MyContentHandler(OutputStream os) { + bWriter = new BufferedWriter(new OutputStreamWriter(os)); + } + + public void setDocumentLocator(Locator locator) { + } + + public void startDocument() throws SAXException { + String str = "startDocument"; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void endDocument() throws SAXException { + String str = "endDocument"; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + bWriter.flush(); + bWriter.close(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void startPrefixMapping(String prefix, String uri) throws SAXException { + String str = "startPrefixMapping: " + prefix + ", " + uri; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void endPrefixMapping(String prefix) throws SAXException { + String str = "endPrefixMapping: " + prefix; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { + StringBuilder str = new StringBuilder("startElement: ").append(namespaceURI).append(", ").append(namespaceURI).append(", ").append(qName).append(" : "); + int n = atts.getLength(); + for (int i = 0; i < n; i++) { + str.append(", ").append(atts.getQName(i)).append(" : ").append(atts.getValue(i)); + } + + try { + bWriter.write(str.toString(), 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void endElement(String namespaceURI, String localName, String qName) throws SAXException { + String str = "endElement: " + namespaceURI + ", " + namespaceURI + ", " + qName; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + + } + + public void characters(char ch[], int start, int length) throws SAXException { + String str = new String(ch, start, length); + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { + String str = "ignorableWhitespace"; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void processingInstruction(String target, String data) throws SAXException { + String str = "processingInstruction: " + target + ", " + target; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + + public void skippedEntity(String name) throws SAXException { + String str = "skippedEntity: " + name; + try { + bWriter.write(str, 0, str.length()); + bWriter.newLine(); + } catch (IOException e) { + System.out.println("bWriter error"); + } + } + } + + private static class WrapperException extends RuntimeException { + public WrapperException(Throwable cause) { + super(cause); + } + } + + private XMLInputFactory ifac; + private XMLOutputFactory ofac; + private TransformerFactory tfac; + private DocumentBuilder db; + private byte[] xml; + private byte[] template; + private Document xmlDoc; + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/dataentry.xsl 2015-01-28 03:06:28.756246498 -0800 @@ -0,0 +1,20 @@ + + + + + +
+ +
+ + + + + +
--- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/test.xml 2015-01-28 03:06:29.043282979 -0800 @@ -0,0 +1,8 @@ + + + + TypeOfLifeApp + + + + --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java 2015-01-28 03:06:29.369324417 -0800 @@ -0,0 +1,357 @@ +/* + * Copyright (c) 1999, 2015, 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.validation.ptests; + +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertSame; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.SAXParseException; + +/* + * @summary Class containing the test cases for SchemaFactory + */ +@Test(singleThreaded = true) +public class SchemaFactoryTest { + + @BeforeClass + public void setup() throws SAXException, IOException, ParserConfigurationException { + sf = newSchemaFactory(); + + assertNotNull(sf); + + xsd1 = Files.readAllBytes(Paths.get(XML_DIR + "test.xsd")); + xsd2 = Files.readAllBytes(Paths.get(XML_DIR + "test1.xsd")); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + DocumentBuilder db = dbf.newDocumentBuilder(); + xsdDoc1 = db.parse(newInputStream(xsd1)); + xsdDoc2 = db.parse(newInputStream(xsd2)); + + xml = Files.readAllBytes(Paths.get(XML_DIR + "test.xml")); + } + + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, null }, + { W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + } + + /* + * test for SchemaFactory.newInstance(java.lang.String schemaLanguage, + * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) + * factoryClassName points to correct implementation of + * javax.xml.validation.SchemaFactory , should return newInstance of + * SchemaFactory + */ + @Test(dataProvider = "parameters") + public void testNewInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader) throws SAXException { + SchemaFactory sf = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, null); + Schema schema = sf.newSchema(); + assertNotNull(schema); + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { W3C_XML_SCHEMA_NS_URI, null, null }, { W3C_XML_SCHEMA_NS_URI, null, this.getClass().getClassLoader() } }; + } + + /* + * test for SchemaFactory.newInstance(java.lang.String schemaLanguage, + * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) + * factoryClassName is null , should throw IllegalArgumentException + */ + @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "invalid-parameters") + public void testNewInstanceWithNullFactoryClassName(String schemaLanguage, String factoryClassName, ClassLoader classLoader) { + + SchemaFactory.newInstance(schemaLanguage, factoryClassName, classLoader); + } + + /* + * test for SchemaFactory.newInstance(java.lang.String schemaLanguage, + * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) + * schemaLanguage is null , should throw NPE + */ + @Test(expectedExceptions = NullPointerException.class) + public void testNewInstanceWithNullSchemaLanguage() { + SchemaFactory.newInstance(null, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + } + + /* + * test for SchemaFactory.newInstance(java.lang.String schemaLanguage, + * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) + * schemaLanguage is empty , should throw IllegalArgumentException + */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNewInstanceWithEmptySchemaLanguage() { + SchemaFactory.newInstance("", SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + } + + + @Test(expectedExceptions = SAXParseException.class) + public void testNewSchemaDefault() throws SAXException, IOException { + validate(sf.newSchema()); + } + + @Test + public void testNewSchemaWithFile() throws SAXException, IOException { + validate(sf.newSchema(new File(XML_DIR + "test.xsd"))); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNewSchemaWithNullFile() throws SAXException { + sf.newSchema((File) null); + } + + @DataProvider(name = "valid-source") + public Object[][] getValidSource() { + return new Object[][] { + { streamSource(xsd1) }, + { saxSource(xsd1) }, + { domSource(xsdDoc1) } }; + + } + + @Test(dataProvider = "valid-source") + public void testNewSchemaWithValidSource(Source schema) throws SAXException, IOException { + validate(sf.newSchema(schema)); + } + + @DataProvider(name = "invalid-source") + public Object[][] getInvalidSource() { + return new Object[][] { + { nullStreamSource() }, + { nullSaxSource() } }; + } + + @Test(dataProvider = "invalid-source", expectedExceptions = SAXParseException.class) + public void testNewSchemaWithInvalidSource(Source schema) throws SAXException { + sf.newSchema(schema); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNewSchemaWithNullSource() throws SAXException { + sf.newSchema((Source)null); + } + + @DataProvider(name = "valid-sources") + public Object[][] getValidSources() { + return new Object[][] { + { streamSource(xsd1), streamSource(xsd2) }, + { saxSource(xsd1), saxSource(xsd2) }, + { domSource(xsdDoc1), domSource(xsdDoc2) } }; + + } + + @Test(dataProvider = "valid-sources") + public void testNewSchemaWithValidSourceArray(Source schema1, Source schema2) throws SAXException, IOException { + validate(sf.newSchema(new Source[] { schema1, schema2 })); + } + + @DataProvider(name = "invalid-sources") + public Object[][] getInvalidSources() { + return new Object[][] { + { streamSource(xsd1), nullStreamSource() }, + { nullStreamSource(), nullStreamSource() }, + { saxSource(xsd1), nullSaxSource() }, + { nullSaxSource(), nullSaxSource() } }; + } + + @Test(dataProvider = "invalid-sources", expectedExceptions = SAXParseException.class) + public void testNewSchemaWithInvalidSourceArray(Source schema1, Source schema2) throws SAXException { + sf.newSchema(new Source[] { schema1, schema2 }); + } + + @DataProvider(name = "null-sources") + public Object[][] getNullSources() { + return new Object[][] { + { new Source[] { domSource(xsdDoc1), null } }, + { new Source[] { null, null } }, + { null } }; + + } + + @Test(dataProvider = "null-sources", expectedExceptions = NullPointerException.class) + public void testNewSchemaWithNullSourceArray(Source[] schemas) throws SAXException { + sf.newSchema(schemas); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNewSchemaWithNullUrl() throws SAXException { + sf.newSchema((URL) null); + } + + + @Test + public void testErrorHandler() { + SchemaFactory sf = newSchemaFactory(); + assertNull(sf.getErrorHandler(), "When SchemaFactory is created, initially ErrorHandler should not be set."); + + ErrorHandler handler = new MyErrorHandler(); + sf.setErrorHandler(handler); + assertSame(sf.getErrorHandler(), handler); + + sf.setErrorHandler(null); + assertNull(sf.getErrorHandler()); + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + sf.getProperty(UNRECOGNIZED_NAME); + + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + sf.setProperty(UNRECOGNIZED_NAME, "test"); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + assertNotNull(sf); + sf.getProperty(null); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + assertNotNull(sf); + sf.setProperty(null, "test"); + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testGetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + sf.getFeature(UNRECOGNIZED_NAME); + + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testSetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + sf.setFeature(UNRECOGNIZED_NAME, true); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + assertNotNull(sf); + sf.getFeature(null); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testSetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + SchemaFactory sf = newSchemaFactory(); + assertNotNull(sf); + sf.setFeature(null, true); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidSchemaLanguage() { + final String INVALID_SCHEMA_LANGUAGE = "http://relaxng.org/ns/structure/1.0"; + SchemaFactory.newInstance(INVALID_SCHEMA_LANGUAGE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullSchemaLanguage() { + SchemaFactory.newInstance(null); + } + + private void validate(Schema schema) throws SAXException, IOException { + schema.newValidator().validate(new StreamSource(new ByteArrayInputStream(xml))); + } + private InputStream newInputStream(byte[] xsd) { + return new ByteArrayInputStream(xsd); + } + + private Source streamSource(byte[] xsd) { + return new StreamSource(newInputStream(xsd)); + } + + private Source nullStreamSource() { + return new StreamSource((InputStream) null); + } + + private Source saxSource(byte[] xsd) { + return new SAXSource(new InputSource(newInputStream(xsd))); + } + + private Source nullSaxSource() { + return new SAXSource(new InputSource((InputStream) null)); + } + + private Source domSource(Document xsdDoc) { + return new DOMSource(xsdDoc); + } + + private SchemaFactory newSchemaFactory() { + return SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); + } + + 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 SchemaFactory sf; + private byte[] xsd1; + private byte[] xsd2; + private Document xsdDoc1; + private Document xsdDoc2; + private byte[] xml; +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java 2015-01-28 03:06:29.782376914 -0800 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1999, 2015, 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.validation.ptests; + +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static jaxp.library.JAXPTestUtilities.filenameToURL; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.TypeInfoProvider; +import javax.xml.validation.ValidatorHandler; + +import jaxp.library.JAXPFileBaseTest; + +import org.testng.annotations.Test; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @summary test ValidatorHandler.getTypeInfoProvider() + */ +public class TypeInfoProviderTest extends JAXPFileBaseTest { + + private ValidatorHandler validatorHandler; + + @Test + public void test() throws SAXException, ParserConfigurationException, IOException { + + SchemaFactory sf = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); + Schema schema = sf.newSchema(new File(XML_DIR + "shiporder11.xsd")); + validatorHandler = schema.newValidatorHandler(); + MyDefaultHandler myDefaultHandler = new MyDefaultHandler(); + validatorHandler.setContentHandler(myDefaultHandler); + + InputSource is = new InputSource(filenameToURL(XML_DIR + "shiporder11.xml")); + + SAXParserFactory parserFactory = SAXParserFactory.newInstance(); + parserFactory.setNamespaceAware(true); + XMLReader xmlReader = parserFactory.newSAXParser().getXMLReader(); + xmlReader.setContentHandler(validatorHandler); + xmlReader.parse(is); + + } + + private class MyDefaultHandler extends DefaultHandler { + + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { + TypeInfoProvider typeInfoProvider = validatorHandler.getTypeInfoProvider(); + int index = atts.getIndex("orderid"); + if (index != -1) { + System.out.println(" Index " + index); + System.out.println(" ElementType " + typeInfoProvider.getElementTypeInfo().getTypeName()); + assertEquals(typeInfoProvider.getAttributeTypeInfo(index).getTypeName(), "string"); + assertTrue(typeInfoProvider.isSpecified(index)); + assertFalse(typeInfoProvider.isIdAttribute(index)); + } + + } + + } +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java 2015-01-28 03:06:30.222432843 -0800 @@ -0,0 +1,144 @@ +/* + * Copyright (c) 1999, 2015, 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.validation.ptests; + +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static org.testng.Assert.assertFalse; +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 java.io.File; + +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.ValidatorHandler; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.xml.sax.ContentHandler; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @summary Class containing the test cases for ValidatorHandler API + */ +public class ValidatorHandlerTest { + @BeforeClass + public void setup() throws SAXException { + schema = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI).newSchema(new File(XML_DIR + "test.xsd")); + + assertNotNull(schema); + } + + @Test + public void testErrorHandler() { + ValidatorHandler validatorHandler = getValidatorHandler(); + assertNull(validatorHandler.getErrorHandler(), "When ValidatorHandler is created, initially ErrorHandler should not be set."); + + ErrorHandler handler = new MyErrorHandler(); + validatorHandler.setErrorHandler(handler); + assertSame(validatorHandler.getErrorHandler(), handler); + + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + ValidatorHandler validatorHandler = getValidatorHandler(); + validatorHandler.getProperty(FEATURE_NAME); + + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + ValidatorHandler validatorHandler = getValidatorHandler(); + validatorHandler.setProperty(FEATURE_NAME, "test"); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + ValidatorHandler validatorHandler = getValidatorHandler(); + assertNotNull(validatorHandler); + validatorHandler.getProperty(null); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + ValidatorHandler validatorHandler = getValidatorHandler(); + assertNotNull(validatorHandler); + validatorHandler.setProperty(null, "test"); + } + + public void testFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + ValidatorHandler validatorHandler = getValidatorHandler(); + assertFalse(validatorHandler.getFeature(FEATURE_NAME), "The feature should be false by default."); + + validatorHandler.setFeature(FEATURE_NAME, true); + assertTrue(validatorHandler.getFeature(FEATURE_NAME), "The feature should be false by default."); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + ValidatorHandler validatorHandler = getValidatorHandler(); + assertNotNull(validatorHandler); + validatorHandler.getFeature(null); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testSetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + ValidatorHandler validatorHandler = getValidatorHandler(); + assertNotNull(validatorHandler); + validatorHandler.setFeature(null, true); + } + + @Test + public void testContentHandler() { + ValidatorHandler validatorHandler = getValidatorHandler(); + assertNull(validatorHandler.getContentHandler(), "When ValidatorHandler is created, initially ContentHandler should not be set."); + + ContentHandler handler = new DefaultHandler(); + validatorHandler.setContentHandler(handler); + assertSame(validatorHandler.getContentHandler(), handler); + + validatorHandler.setContentHandler(null); + assertNull(validatorHandler.getContentHandler()); + + } + + private ValidatorHandler getValidatorHandler() { + return schema.newValidatorHandler(); + } + + private static final String FEATURE_NAME = "http://xml.org/sax/features/namespace-prefixes"; + + private Schema schema; + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java 2015-01-28 03:06:30.576477840 -0800 @@ -0,0 +1,207 @@ +/* + * Copyright (c) 1999, 2015, 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.validation.ptests; + +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static jaxp.library.JAXPTestUtilities.filenameToURL; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertSame; + +import java.io.File; +import java.io.IOException; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +import jaxp.library.JAXPFileBaseTest; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @summary Class containing the test cases for Validator API + */ +public class ValidatorTest extends JAXPFileBaseTest { + + @BeforeClass + public void setup() throws SAXException, IOException, ParserConfigurationException { + schema = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI).newSchema(new File(XML_DIR + "test.xsd")); + + assertNotNull(schema); + + xmlFileUri = filenameToURL(XML_DIR + "test.xml"); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + xmlDoc = dbf.newDocumentBuilder().parse(xmlFileUri); + } + + @Test + public void testValidateStreamSource() throws SAXException, IOException { + Validator validator = getValidator(); + validator.setErrorHandler(new MyErrorHandler()); + validator.validate(getStreamSource()); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testValidateNullSource() throws SAXException, IOException { + Validator validator = getValidator(); + assertNotNull(validator); + validator.validate(null); + } + + @Test + public void testErrorHandler() { + Validator validator = getValidator(); + assertNull(validator.getErrorHandler(), "When Validator is created, initially ErrorHandler should not be set."); + + ErrorHandler mh = new MyErrorHandler(); + validator.setErrorHandler(mh); + assertSame(validator.getErrorHandler(), mh); + + } + + @DataProvider(name = "source-result") + public Object[][] getSourceAndResult() { + return new Object[][] { + { getStreamSource(), null }, + { getSAXSource(), getSAXResult() }, + { getDOMSource(), getDOMResult() }, + { getSAXSource(), null }, + { getDOMSource(), null } }; + } + + @Test(dataProvider = "source-result") + public void testValidateWithResult(Source source, Result result) throws SAXException, IOException { + Validator validator = getValidator(); + validator.validate(source, result); + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + validator.getProperty(UNRECOGNIZED_NAME); + + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + validator.setProperty(UNRECOGNIZED_NAME, "test"); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + assertNotNull(validator); + validator.getProperty(null); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + assertNotNull(validator); + validator.setProperty(null, "test"); + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testGetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + validator.getFeature(UNRECOGNIZED_NAME); + + } + + @Test(expectedExceptions = SAXNotRecognizedException.class) + public void testSetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + validator.setFeature(UNRECOGNIZED_NAME, true); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + assertNotNull(validator); + validator.getFeature(null); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testSetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + Validator validator = getValidator(); + assertNotNull(validator); + validator.setFeature(null, true); + } + + private Validator getValidator() { + return schema.newValidator(); + } + + private Source getStreamSource() { + return new StreamSource(xmlFileUri); + } + + private Source getSAXSource() { + return new SAXSource(new InputSource(xmlFileUri)); + } + + private Result getSAXResult() { + SAXResult saxResult = new SAXResult(); + saxResult.setHandler(new DefaultHandler()); + return saxResult; + } + + private Source getDOMSource() { + return new DOMSource(xmlDoc); + } + + private Result getDOMResult() { + return new DOMResult(); + } + + private static final String UNRECOGNIZED_NAME = "http://xml.org/sax/features/namespace-prefixes"; + private String xmlFileUri; + private Schema schema; + private Document xmlDoc; + +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/xmlfiles/shiporder11.xml 2015-01-28 03:06:30.883516864 -0800 @@ -0,0 +1,24 @@ + + + +John Smith + +Ola Nordmann +
Langgt 23
+4000 Stavanger +Norway +
+ +Empire Burlesque +Special Edition +1 +10.90 + + +Hide your heart +1 +9.90 + +
\ No newline at end of file --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/xmlfiles/shiporder11.xsd 2015-01-28 03:06:31.157551692 -0800 @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/xmlfiles/shiporder12.xml 2015-01-28 03:06:31.436587156 -0800 @@ -0,0 +1,24 @@ + + + +John Smith + +Ola Nordmann +
Langgt 23
+4000 Stavanger +Norway +
+ +Empire Burlesque +Special Edition +1 +10.90 + + +Hide your heart +1 +9.90 + +
\ No newline at end of file --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/xmlfiles/shiporder12.xsd 2015-01-28 03:06:31.773629992 -0800 @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/xmlfiles/test.xml 2015-01-28 03:06:32.070667744 -0800 @@ -0,0 +1,5 @@ + + + John +444-121-3434 + --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/xmlfiles/test.xsd 2015-01-28 03:06:32.452716301 -0800 @@ -0,0 +1,11 @@ + + + + + + + + + + + --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/functional/javax/xml/validation/xmlfiles/test1.xsd 2015-01-28 03:06:32.728751383 -0800 @@ -0,0 +1,11 @@ + + + + + + + + + + + --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/libs/javax/xml/validation/ptests/MyErrorHandler.java 2015-01-28 03:06:33.027789390 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015, 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.validation.ptests; + +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXParseException; + +class MyErrorHandler implements ErrorHandler { + public void error(SAXParseException exception) throws SAXParseException { + throw exception; + } + + public void warning(SAXParseException exception) throws SAXParseException { + throw exception; + } + + public void fatalError(SAXParseException exception) throws SAXParseException { + throw exception; + } +} --- /dev/null 2015-01-28 02:43:00.479395423 -0800 +++ new/test/javax/xml/jaxp/libs/javax/xml/validation/ptests/ValidationTestConst.java 2015-01-28 03:06:33.310825362 -0800 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, 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.validation.ptests; + +import static jaxp.library.JAXPTestUtilities.FILE_SEP; +import static jaxp.library.JAXPTestUtilities.getPathByClassName; + +/** + * This class defines the path constant + */ +public class ValidationTestConst { + /** + * XML source file directory. + */ + public static final String XML_DIR = getPathByClassName(ValidationTestConst.class, + ".." + FILE_SEP + "xmlfiles"); + + /** + * Golden validation files directory. + */ + public static final String GOLDEN_DIR = getPathByClassName(ValidationTestConst.class, + ".." + FILE_SEP + "xmlfiles" + FILE_SEP + "out"); +}