8052401: JAXP function gap tests conversion
authorjoehw
Wed, 28 Jan 2015 15:07:12 -0800
changeset 28696 dd8c7efde993
parent 28695 427254b89b9e
child 28697 fae50549d70d
8052401: JAXP function gap tests conversion Reviewed-by: lancea, joehw Contributed-by: frank.yuan@oracle.com
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/Bug4693341.dtd
jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/Bug4693341.xml
jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/Bug4848653.xml
jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/certificate.xml
jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/out/Bug4693341.dtd
jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/out/Bug4693341.xml
jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/out/Bug4858685.txt
jaxp/test/javax/xml/jaxp/libs/test/gaptest/GapTestConst.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2003, 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 test.gaptest;
+
+import java.io.StringReader;
+
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.Test;
+
+/*
+ * @bug 4511326
+ * @summary In forwards-compatible mode the attribute isn't ignored
+ */
+
+public class Bug4511326 extends JAXPBaseTest {
+
+    private static final String XSL = "<xsl:stylesheet version='2.0' "
+                               + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>"
+                               + "<xsl:template a='1' match='/'>"
+                               + "<H2><xsl:value-of select='//author'/></H2>"
+                               + "<H1><xsl:value-of select='//title'/></H1>"
+                               + "</xsl:template>"
+                               + "</xsl:stylesheet>";
+
+
+    @Test
+    public void ignoreAttTest() throws TransformerConfigurationException {
+        /* Create a TransformFactory instance */
+        TransformerFactory transformerFactory = TransformerFactory.newInstance();
+
+        /* Create and init a StreamSource instance */
+        StreamSource source = new StreamSource(new StringReader(XSL));
+
+        transformerFactory.newTransformer(source);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2003, 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 test.gaptest;
+
+import static javax.xml.transform.OutputKeys.ENCODING;
+import static javax.xml.transform.OutputKeys.INDENT;
+import static org.testng.Assert.assertEquals;
+
+import java.io.StringReader;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.Test;
+
+/*
+ * @bug 4512806
+ * @summary test transformer.setOutputProperties(null)
+ */
+public class Bug4512806 extends JAXPBaseTest {
+
+    @Test
+    public void testProperty() throws TransformerConfigurationException {
+        /* Create a transform factory instance */
+        TransformerFactory tfactory = TransformerFactory.newInstance();
+
+        /* Create a StreamSource instance */
+        StreamSource streamSource = new StreamSource(new StringReader(xslData));
+
+        transformer = tfactory.newTransformer(streamSource);
+        transformer.setOutputProperty(INDENT, "no");
+        transformer.setOutputProperty(ENCODING, "UTF-16");
+
+        assertEquals(printPropertyValue(INDENT), "indent=no");
+        assertEquals(printPropertyValue(ENCODING), "encoding=UTF-16");
+
+        transformer.setOutputProperties(null);
+
+        assertEquals(printPropertyValue(INDENT), "indent=yes");
+        assertEquals(printPropertyValue(ENCODING), "encoding=UTF-8");
+
+    }
+
+    private String printPropertyValue(String name) {
+        return name + "=" + transformer.getOutputProperty(name);
+    }
+
+    private Transformer transformer;
+
+    private static final String xslData = "<?xml version='1.0'?>"
+            + "<xsl:stylesheet"
+            + " version='1.0'"
+            + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"
+            + ">\n"
+            + "   <xsl:output method='xml' indent='yes'"
+            + " encoding='UTF-8'/>\n"
+            + "   <xsl:template match='/'>\n"
+            + "     Hello World! \n"
+            + "   </xsl:template>\n"
+            + "</xsl:stylesheet>";
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2003, 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 test.gaptest;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.Test;
+
+/*
+ * @bug 4515047
+ * @summary test transform an empty dom source
+ */
+
+public class Bug4515047 extends JAXPBaseTest {
+
+    @Test
+    public void testCreateTxDoc() throws TransformerException, ParserConfigurationException {
+        Transformer transformer = TransformerFactory.newInstance().newTransformer();
+
+        StreamResult result = new StreamResult(System.out);
+        DOMSource source = new DOMSource();
+
+        /* This should not throw an Illegal Argument Exception */
+        //Test empty DOMSource
+        transformer.transform(source, result);
+
+        //Test DOMSource having only an empty node
+        source.setNode(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
+        transformer.transform(source, result);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2003, 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 test.gaptest;
+
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/*
+ * @bug 4515660
+ * @summary verify property org.xml.sax.driver is used by SAXTransformerFactory
+ */
+@Test(singleThreaded = true)
+public class Bug4515660 extends JAXPBaseTest {
+
+    @BeforeClass
+    public void setSaxDrier() {
+        setSystemProperty("org.xml.sax.driver", ReaderStub.class.getName());
+    }
+
+    @AfterClass
+    public void clearSaxDrier() {
+        setSystemProperty("org.xml.sax.driver", null);
+    }
+
+    @Test
+    public void testTransformer() throws TransformerException {
+        String xml = "<?xml version='1.0'?><root/>";
+        ReaderStub.used = false;
+
+        TransformerFactory transFactory = TransformerFactory.newInstance();
+        Transformer transformer = transFactory.newTransformer();
+        InputSource in = new InputSource(new StringReader(xml));
+        SAXSource source = new SAXSource(in);
+        StreamResult result = new StreamResult(new StringWriter());
+
+        transformer.transform(source, result);
+
+        assertTrue(ReaderStub.used);
+
+    }
+
+    @Test
+    public void testSAXTransformerFactory() throws TransformerConfigurationException {
+        final String xsl = "<?xml version='1.0'?>\n" + "<xsl:stylesheet" + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" + " version='1.0'>\n"
+                + "   <xsl:template match='/'>Hello World!</xsl:template>\n" + "</xsl:stylesheet>\n";
+
+        ReaderStub.used = false;
+
+        TransformerFactory transFactory = TransformerFactory.newInstance();
+        assertTrue(transFactory.getFeature(SAXTransformerFactory.FEATURE));
+
+        InputSource in = new InputSource(new StringReader(xsl));
+        SAXSource source = new SAXSource(in);
+
+        transFactory.newTransformer(source);
+        assertTrue(ReaderStub.used);
+
+    }
+
+    public static class ReaderStub extends XMLFilterImpl {
+        static boolean used = false;
+
+        public ReaderStub() throws ParserConfigurationException, SAXException {
+            super();
+            super.setParent(SAXParserFactory.newInstance().newSAXParser().getXMLReader());
+            used = true;
+        }
+
+        public void parse(InputSource input) throws SAXException, IOException {
+            used = true;
+            super.parse(input);
+        }
+
+        public void parse(String systemId) throws SAXException, IOException {
+            used = true;
+            super.parse(systemId);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2003, 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 test.gaptest;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
+import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
+import static org.testng.Assert.assertTrue;
+import static test.gaptest.GapTestConst.GOLDEN_DIR;
+import static test.gaptest.GapTestConst.XML_DIR;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import jaxp.library.JAXPFileBaseTest;
+
+import org.testng.annotations.Test;
+import org.xml.sax.SAXException;
+
+/*
+ * @bug 4693341
+ * @summary test transforming to stream with external dtd
+ */
+
+public class Bug4693341 extends JAXPFileBaseTest {
+
+    @Test
+    public void test() throws TransformerException, ParserConfigurationException, SAXException, IOException {
+
+        Transformer transformer = TransformerFactory.newInstance().newTransformer();
+
+        String out = USER_DIR + File.separator + "Bug4693341.out";
+        StreamResult result = new StreamResult(new File(out));
+
+        String in = XML_DIR + "Bug4693341.xml";
+        String golden = GOLDEN_DIR + "Bug4693341.xml";
+        File file = new File(in);
+        StreamSource source = new StreamSource(file);
+        System.out.println(source.getSystemId());
+
+        Files.copy(Paths.get(XML_DIR + "Bug4693341.dtd"),
+                Paths.get(USER_DIR + File.separator + "Bug4693341.dtd"), REPLACE_EXISTING);
+
+        transformer.transform(source, result);
+
+        assertTrue(compareDocumentWithGold(golden, out));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2003, 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 test.gaptest;
+
+import static jaxp.library.JAXPTestUtilities.filenameToURL;
+import static test.gaptest.GapTestConst.XML_DIR;
+
+import java.io.IOException;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import jaxp.library.JAXPFileBaseTest;
+
+import org.testng.annotations.Test;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+
+/*
+ * @bug 4848653
+ * @summary Verify JAXP schemaLanguage property is ignored if setValidating(false)
+ */
+
+public class Bug4848653 extends JAXPFileBaseTest {
+
+    @Test
+    public void test() throws IOException, SAXException, ParserConfigurationException {
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        factory.setValidating(false);
+        SAXParser parser = factory.newSAXParser();
+        parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+        String filename = XML_DIR + "Bug4848653.xml";
+        InputSource is = new InputSource(filenameToURL(filename));
+        XMLReader xmlReader = parser.getXMLReader();
+        xmlReader.setErrorHandler(new MyErrorHandler());
+        xmlReader.parse(is);
+    }
+
+    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	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2003, 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 test.gaptest;
+
+import static jaxp.library.JAXPTestUtilities.filenameToURL;
+import static org.testng.Assert.assertEquals;
+import static test.gaptest.GapTestConst.GOLDEN_DIR;
+import static test.gaptest.GapTestConst.XML_DIR;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+import jaxp.library.JAXPFileBaseTest;
+
+import org.testng.annotations.Test;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/*
+ * @bug 4858685 4894410
+ * @summary test transforming text node
+ */
+
+public class Bug4858685 extends JAXPFileBaseTest {
+    @Test
+    public void test() throws TransformerException, IOException {
+        String uri = XML_DIR + "certificate.xml";
+        TransformerFactory transformerFactory = TransformerFactory.newInstance();
+
+        Transformer transformer = transformerFactory.newTransformer();
+
+        // use URI as a StreamSource
+        StreamSource streamSource = new StreamSource(filenameToURL(uri));
+
+        DOMResult domResult = new DOMResult();
+
+        // StreamSource -> DOMResult
+        transformer.transform(streamSource, domResult);
+
+        // dump DOM in a human readable form
+        String gotString = DOMDump.dumpDom(domResult.getNode());
+
+        String goldenString = new String(Files.readAllBytes(Paths.get(GOLDEN_DIR + "Bug4858685.txt")));
+
+        assertEquals(gotString, goldenString);
+
+    }
+
+    /**
+     * DOMDump: dump a DOM to a String in human readable form. method dumpDOM()
+     * is static for easy calling:
+     */
+    private static class DOMDump {
+
+        /**
+         * the maximum level to indent with blanks
+         */
+        private static final int BLANKS_LEN = 64;
+
+        /**
+         * each level of the tree will be indented with blanks for readability
+         */
+        private static final String BLANKS = "                                                              ";
+
+        /**
+         * dumpDOM will dump the DOM into a String for human readability
+         *
+         * @param domNode
+         *            the DOM Node to dump
+         * @return human readabile DOM as a String
+         */
+        public static String dumpDom(Node domNode) {
+            return dumpInternal(domNode, 0);
+        }
+
+        /**
+         * dumpInternal is used internaly to recursively dump DOM Nodes
+         *
+         * @param domNode
+         *            to dump
+         * @param indent
+         *            level
+         * @return domNode as human readable String
+         */
+        private static String dumpInternal(Node domNode, int indent) {
+
+            String result = "";
+
+            // indent for readability
+            result += indentBlanks(indent);
+            indent += 2;
+
+            // protect against null
+            if (domNode == null) {
+                result = result + "[null]" + "\n";
+                return result;
+            }
+
+            // what to output depends on NodeType
+            short type = domNode.getNodeType();
+            switch (type) {
+                case Node.ATTRIBUTE_NODE: {
+                    result += "[attribute] " + domNode.getNodeName() + "=\"" + domNode.getNodeValue() + "\"";
+                    break;
+                }
+                case Node.CDATA_SECTION_NODE: {
+                    result += "[cdata] " + domNode.getNodeValue();
+                    break;
+                }
+                case Node.COMMENT_NODE: {
+                    result += "[comment] " + domNode.getNodeValue();
+                    break;
+                }
+                case Node.DOCUMENT_FRAGMENT_NODE: {
+                    result += "[document fragment]";
+                    break;
+                }
+                case Node.DOCUMENT_NODE: {
+                    result += "[document]";
+                    break;
+                }
+                case Node.DOCUMENT_TYPE_NODE: {
+                    result += "[document type] " + domNode.getNodeName();
+                    break;
+                }
+                case Node.ELEMENT_NODE: {
+                    result += "[element] " + domNode.getNodeName();
+                    // output all attributes for Element
+                    if (domNode.hasAttributes()) {
+                        NamedNodeMap attributes = domNode.getAttributes();
+                        for (int onAttribute = 0; onAttribute < attributes.getLength(); onAttribute++) {
+
+                            // seprate each attribute with a space
+                            result += " ";
+
+                            Node attribute = attributes.item(onAttribute);
+                            String namespaceURI = attribute.getNamespaceURI();
+                            String prefix = attribute.getPrefix();
+                            String localName = attribute.getLocalName();
+                            String name = attribute.getNodeName();
+                            String value = attribute.getNodeValue();
+
+                            // using Namespaces?
+                            if (namespaceURI != null) {
+                                result += "{" + namespaceURI + "}";
+                            }
+                            if (prefix != null) {
+                                result += prefix + ":";
+                            }
+
+                            // name="value"
+                            result += attribute.getNodeName() + "=\"" + attribute.getNodeValue() + "\"";
+                        }
+                    }
+
+                    break;
+                }
+                case Node.ENTITY_NODE: {
+                    result += "[entity] " + domNode.getNodeName();
+                    break;
+                }
+                case Node.ENTITY_REFERENCE_NODE: {
+                    result += "[entity reference] " + domNode.getNodeName();
+                    break;
+                }
+                case Node.NOTATION_NODE: {
+                    result += "[notation] " + domNode.getNodeName();
+                    break;
+                }
+                case Node.PROCESSING_INSTRUCTION_NODE: {
+                    result += "[pi] target=\"" + domNode.getNodeName() + "\" content=\"" + domNode.getNodeValue() + "\"";
+                    break;
+                }
+                case Node.TEXT_NODE: {
+                    result += "[text] " + domNode.getNodeValue();
+                    break;
+                }
+                default: {
+                    result += "[unknown]";
+                    break;
+                }
+            }
+
+            // humans read in lines
+            result += "\n";
+
+            // process children
+            NodeList children = domNode.getChildNodes();
+            for (int onChild = 0; onChild < children.getLength(); onChild++) {
+                Node child = children.item(onChild);
+                result += dumpInternal(child, indent);
+            }
+
+            // return human readable DOM as String
+            return result;
+        }
+
+        /**
+         * indentBlanks will return a String of indent blanks
+         *
+         * @param indent
+         *            level
+         * @return String of blanks
+         */
+        private static String indentBlanks(int indent) {
+            if (indent == 0) {
+                return "";
+            }
+
+            if (indent > BLANKS_LEN) {
+                return BLANKS;
+            }
+
+            return BLANKS.substring(0, indent + 1);
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/Bug4693341.dtd	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,39 @@
+<!ELEMENT SupplierOrder (OrderId, OrderDate, ShippingAddress, LineItems)>
+
+<!ELEMENT OrderId (#PCDATA)>
+
+<!ELEMENT OrderDate (#PCDATA)>
+
+<!ELEMENT ShippingAddress (FirstName, LastName, Street, City, State, Country, ZipCode, Email, Phone)>
+
+<!ELEMENT FirstName (#PCDATA)>
+
+<!ELEMENT LastName (#PCDATA)>
+
+<!ELEMENT Street (#PCDATA)>
+
+<!ELEMENT City (#PCDATA)>
+
+<!ELEMENT State (#PCDATA)>
+
+<!ELEMENT Country (#PCDATA)>
+
+<!ELEMENT ZipCode (#PCDATA)>
+
+<!ELEMENT Email (#PCDATA)>
+
+<!ELEMENT Phone (#PCDATA)>
+
+<!ELEMENT LineItems (LineItem+)>
+
+<!ELEMENT LineItem EMPTY>
+
+<!ATTLIST LineItem
+     categoryId CDATA #REQUIRED
+     productId CDATA #REQUIRED
+     itemId CDATA #REQUIRED
+     lineNo CDATA #REQUIRED
+     quantity CDATA #REQUIRED
+     unitPrice CDATA #REQUIRED
+>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/Bug4693341.xml	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE SupplierOrder SYSTEM "Bug4693341.dtd" >
+<SupplierOrder>
+<OrderId>10016</OrderId>
+<OrderDate>Wed May 29 12:45:00 PDT 2002</OrderDate>
+<ShippingAddress>
+<FirstName>ABC</FirstName>
+<LastName>XYZ</LastName>
+<Street>1234 Anywhere Street</Street>
+<City>Palo Alto</City>
+<State>California</State>
+<Country>USA</Country>
+<ZipCode>94303</ZipCode>
+<Email>NULL</Email>
+<Phone>NULL</Phone>
+</ShippingAddress>
+<LineItems>
+<LineItem categoryId="BIRDS" itemId="EST-18" lineNo="0" productId="AV-CB-01" quantity="1" unitPrice="193.5"/>
+</LineItems>
+</SupplierOrder>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/Bug4848653.xml	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,1 @@
+<a/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/certificate.xml	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<env:Envelope xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" 
+    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" 
+    xmlns:ns0="http://headertest.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+   <env:Body>
+	<ds:X509Certificate xmlns="" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+MIIDVjCCAxICBD6kKrMwCwYHKoZIzjgEAwUAMIGPMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0Ex
+FDASBgNVBAcTC1NhbnRhIENsYXJhMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0ZW1zLCBJbmMuMR4w
+HAYDVQQLExVKYXZhIGFuZCBYTUwgU29mdHdhcmUxHDAaBgNVBAMTE0pXUy1TZWN1cml0eSBDbGll
+bnQwHhcNMDMwNDIxMTczMDI3WhcNMDMwNzIwMTczMDI3WjCBjzELMAkGA1UEBhMCVVMxCzAJBgNV
+BAgTAkNBMRQwEgYDVQQHEwtTYW50YSBDbGFyYTEfMB0GA1UEChMWU3VuIE1pY3Jvc3lzdGVtcywg
+SW5jLjEeMBwGA1UECxMVSmF2YSBhbmQgWE1MIFNvZnR3YXJlMRwwGgYDVQQDExNKV1MtU2VjdXJp
+dHkgQ2xpZW50MIIBtzCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9E
+AMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up
+1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUj
+C8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZ
+T+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7
+zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAV3R+bUfh+u0yaPBV75umKvFB
+ucv37ETDak889b7k72kZdGoHz3oDmp69tiNDg5r7IvKtjHGbZ6C3Nv0ycNR7Sed1QPOF4nn/tgUl
+j+BvtVW3iiIRgBJ82KP+28QtwPkkxSp7n5HG0v7bE29E/juLduuhKBQTaaCvajuCFxiBrmAwCwYH
+KoZIzjgEAwUAAzEAMC4CFQCCuDNmMKjgY6MV1SmAcCdnhuT6VwIVAJBOiPDnDWp2WlKAERF6nOAf
+vKz9
+   </ds:X509Certificate>
+   </env:Body>
+</env:Envelope>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/out/Bug4693341.dtd	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,39 @@
+<!ELEMENT SupplierOrder (OrderId, OrderDate, ShippingAddress, LineItems)>
+
+<!ELEMENT OrderId (#PCDATA)>
+
+<!ELEMENT OrderDate (#PCDATA)>
+
+<!ELEMENT ShippingAddress (FirstName, LastName, Street, City, State, Country, ZipCode, Email, Phone)>
+
+<!ELEMENT FirstName (#PCDATA)>
+
+<!ELEMENT LastName (#PCDATA)>
+
+<!ELEMENT Street (#PCDATA)>
+
+<!ELEMENT City (#PCDATA)>
+
+<!ELEMENT State (#PCDATA)>
+
+<!ELEMENT Country (#PCDATA)>
+
+<!ELEMENT ZipCode (#PCDATA)>
+
+<!ELEMENT Email (#PCDATA)>
+
+<!ELEMENT Phone (#PCDATA)>
+
+<!ELEMENT LineItems (LineItem+)>
+
+<!ELEMENT LineItem EMPTY>
+
+<!ATTLIST LineItem
+     categoryId CDATA #REQUIRED
+     productId CDATA #REQUIRED
+     itemId CDATA #REQUIRED
+     lineNo CDATA #REQUIRED
+     quantity CDATA #REQUIRED
+     unitPrice CDATA #REQUIRED
+>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/out/Bug4693341.xml	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE SupplierOrder SYSTEM "Bug4693341.dtd" >
+<SupplierOrder>
+<OrderId>10016</OrderId>
+<OrderDate>Wed May 29 12:45:00 PDT 2002</OrderDate>
+<ShippingAddress>
+<FirstName>ABC</FirstName>
+<LastName>XYZ</LastName>
+<Street>1234 Anywhere Street</Street>
+<City>Palo Alto</City>
+<State>California</State>
+<Country>USA</Country>
+<ZipCode>94303</ZipCode>
+<Email>NULL</Email>
+<Phone>NULL</Phone>
+</ShippingAddress>
+<LineItems>
+<LineItem categoryId="BIRDS" itemId="EST-18" lineNo="0" productId="AV-CB-01" quantity="1" unitPrice="193.5"/>
+</LineItems>
+</SupplierOrder>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/xmlfiles/out/Bug4858685.txt	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,30 @@
+[document]
+   [element] env:Envelope {http://www.w3.org/2000/xmlns/}xmlns:xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" {http://www.w3.org/2000/xmlns/}xmlns:xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" {http://www.w3.org/2000/xmlns/}xmlns:xmlns:ns0="http://headertest.org/" {http://www.w3.org/2000/xmlns/}xmlns:xmlns:xsd="http://www.w3.org/2001/XMLSchema" {http://www.w3.org/2000/xmlns/}xmlns:xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     [text] 
+   
+     [element] env:Body
+       [text] 
+	
+       [element] ds:X509Certificate xmlns="" {http://www.w3.org/2000/xmlns/}xmlns:xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+         [text] 
+MIIDVjCCAxICBD6kKrMwCwYHKoZIzjgEAwUAMIGPMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0Ex
+FDASBgNVBAcTC1NhbnRhIENsYXJhMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0ZW1zLCBJbmMuMR4w
+HAYDVQQLExVKYXZhIGFuZCBYTUwgU29mdHdhcmUxHDAaBgNVBAMTE0pXUy1TZWN1cml0eSBDbGll
+bnQwHhcNMDMwNDIxMTczMDI3WhcNMDMwNzIwMTczMDI3WjCBjzELMAkGA1UEBhMCVVMxCzAJBgNV
+BAgTAkNBMRQwEgYDVQQHEwtTYW50YSBDbGFyYTEfMB0GA1UEChMWU3VuIE1pY3Jvc3lzdGVtcywg
+SW5jLjEeMBwGA1UECxMVSmF2YSBhbmQgWE1MIFNvZnR3YXJlMRwwGgYDVQQDExNKV1MtU2VjdXJp
+dHkgQ2xpZW50MIIBtzCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9E
+AMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up
+1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUj
+C8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZ
+T+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7
+zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAV3R+bUfh+u0yaPBV75umKvFB
+ucv37ETDak889b7k72kZdGoHz3oDmp69tiNDg5r7IvKtjHGbZ6C3Nv0ycNR7Sed1QPOF4nn/tgUl
+j+BvtVW3iiIRgBJ82KP+28QtwPkkxSp7n5HG0v7bE29E/juLduuhKBQTaaCvajuCFxiBrmAwCwYH
+KoZIzjgEAwUAAzEAMC4CFQCCuDNmMKjgY6MV1SmAcCdnhuT6VwIVAJBOiPDnDWp2WlKAERF6nOAf
+vKz9
+   
+       [text] 
+   
+     [text] 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/test/gaptest/GapTestConst.java	Wed Jan 28 15:07:12 2015 -0800
@@ -0,0 +1,41 @@
+/*
+ * 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 test.gaptest;
+
+import static jaxp.library.JAXPTestUtilities.FILE_SEP;
+import static jaxp.library.JAXPTestUtilities.getPathByClassName;
+
+/**
+ * This class defines the path constant
+ */
+public class GapTestConst {
+    /**
+     * XML source file directory.
+     */
+    public static final String XML_DIR = getPathByClassName(GapTestConst.class, "xmlfiles");
+
+    /**
+     * Golden validation files directory.
+     */
+    public static final String GOLDEN_DIR = getPathByClassName(GapTestConst.class, "xmlfiles" + FILE_SEP + "out");
+}