1 /* 2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package javax.xml.transform.ptests; 25 26 import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; 27 28 import java.io.BufferedWriter; 29 import java.io.ByteArrayInputStream; 30 import java.io.ByteArrayOutputStream; 31 import java.io.IOException; 32 import java.io.InputStream; 33 import java.io.OutputStream; 34 import java.io.OutputStreamWriter; 35 import java.nio.file.Files; 36 import java.nio.file.Paths; 37 import java.util.function.Supplier; 38 39 import javax.xml.parsers.DocumentBuilder; 40 import javax.xml.parsers.DocumentBuilderFactory; 41 import javax.xml.parsers.ParserConfigurationException; 42 import javax.xml.stream.XMLEventWriter; 43 import javax.xml.stream.XMLInputFactory; 44 import javax.xml.stream.XMLOutputFactory; 45 import javax.xml.stream.XMLStreamException; 46 import javax.xml.stream.XMLStreamReader; 47 import javax.xml.stream.XMLStreamWriter; 48 import javax.xml.transform.Result; 49 import javax.xml.transform.Source; 50 import javax.xml.transform.Transformer; 51 import javax.xml.transform.TransformerConfigurationException; 52 import javax.xml.transform.TransformerFactory; 53 import javax.xml.transform.dom.DOMSource; 54 import javax.xml.transform.sax.SAXResult; 55 import javax.xml.transform.sax.SAXSource; 56 import javax.xml.transform.stax.StAXResult; 57 import javax.xml.transform.stax.StAXSource; 58 import javax.xml.transform.stream.StreamResult; 59 import javax.xml.transform.stream.StreamSource; 60 61 import jaxp.library.JAXPFileBaseTest; 62 63 import org.testng.annotations.BeforeClass; 64 import org.testng.annotations.DataProvider; 65 import org.testng.annotations.Test; 66 import org.w3c.dom.Document; 67 import org.xml.sax.Attributes; 68 import org.xml.sax.ContentHandler; 69 import org.xml.sax.InputSource; 70 import org.xml.sax.Locator; 71 import org.xml.sax.SAXException; 72 73 /* 74 * @summary Tests for variable combination of Transformer.transform(Source, Result) 75 */ 76 @Test(singleThreaded = true) 77 public class TransformTest extends JAXPFileBaseTest { 78 79 /* 80 * Initialize the share objects. 81 */ 82 @BeforeClass 83 public void setup() throws Exception { 84 ifac = XMLInputFactory.newInstance(); 85 ofac = XMLOutputFactory.newInstance(); 86 tfac = TransformerFactory.newInstance(); 87 88 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 89 dbf.setNamespaceAware(true); 90 db = dbf.newDocumentBuilder(); 91 92 xml = Files.readAllBytes(Paths.get(XML_DIR + "cities.xml")); 93 template = Files.readAllBytes(Paths.get(XML_DIR + "cities.xsl")); 94 95 xmlDoc = db.parse(xmlInputStream()); 96 } 97 | 1 /* 2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package javax.xml.transform.ptests; 25 26 import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; 27 28 import java.io.BufferedWriter; 29 import java.io.ByteArrayInputStream; 30 import java.io.ByteArrayOutputStream; 31 import java.io.IOException; 32 import java.io.InputStream; 33 import java.io.OutputStream; 34 import java.io.OutputStreamWriter; 35 import java.nio.file.Files; 36 import java.nio.file.Paths; 37 import java.util.function.Supplier; 38 39 import javax.xml.parsers.DocumentBuilder; 40 import javax.xml.parsers.DocumentBuilderFactory; 41 import javax.xml.stream.XMLEventWriter; 42 import javax.xml.stream.XMLInputFactory; 43 import javax.xml.stream.XMLOutputFactory; 44 import javax.xml.stream.XMLStreamException; 45 import javax.xml.stream.XMLStreamReader; 46 import javax.xml.stream.XMLStreamWriter; 47 import javax.xml.transform.Result; 48 import javax.xml.transform.Source; 49 import javax.xml.transform.Transformer; 50 import javax.xml.transform.TransformerConfigurationException; 51 import javax.xml.transform.TransformerFactory; 52 import javax.xml.transform.dom.DOMSource; 53 import javax.xml.transform.sax.SAXResult; 54 import javax.xml.transform.sax.SAXSource; 55 import javax.xml.transform.stax.StAXResult; 56 import javax.xml.transform.stax.StAXSource; 57 import javax.xml.transform.stream.StreamResult; 58 import javax.xml.transform.stream.StreamSource; 59 60 import org.testng.annotations.BeforeClass; 61 import org.testng.annotations.DataProvider; 62 import org.testng.annotations.Listeners; 63 import org.testng.annotations.Test; 64 import org.w3c.dom.Document; 65 import org.xml.sax.Attributes; 66 import org.xml.sax.ContentHandler; 67 import org.xml.sax.InputSource; 68 import org.xml.sax.Locator; 69 import org.xml.sax.SAXException; 70 71 /* 72 * @summary Tests for variable combination of Transformer.transform(Source, Result) 73 */ 74 @Test(singleThreaded = true) 75 @Listeners({jaxp.library.FilePolicy.class}) 76 public class TransformTest { 77 78 /* 79 * Initialize the share objects. 80 */ 81 @BeforeClass 82 public void setup() throws Exception { 83 ifac = XMLInputFactory.newInstance(); 84 ofac = XMLOutputFactory.newInstance(); 85 tfac = TransformerFactory.newInstance(); 86 87 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 88 dbf.setNamespaceAware(true); 89 db = dbf.newDocumentBuilder(); 90 91 xml = Files.readAllBytes(Paths.get(XML_DIR + "cities.xml")); 92 template = Files.readAllBytes(Paths.get(XML_DIR + "cities.xsl")); 93 94 xmlDoc = db.parse(xmlInputStream()); 95 } 96 |