< prev index next >

test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java

Print this page

        

*** 1,7 **** /* ! * 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. --- 1,7 ---- /* ! * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,53 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.xml.transform.ptests; import java.io.File; import java.io.FileInputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; - import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; ! import jaxp.library.JAXPFileBaseTest; ! import static org.testng.Assert.assertEquals; ! import static org.testng.Assert.assertNotNull; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.InputSource; /** * URIResolver should be invoked when transform happens. */ ! public class URIResolverTest extends JAXPFileBaseTest implements URIResolver { /** * System ID constant. */ private final static String SYSTEM_ID = "file:///" + XML_DIR; --- 20,57 ---- * 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 static org.testng.Assert.assertEquals; + import static org.testng.Assert.assertNotNull; + import java.io.File; import java.io.FileInputStream; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; ! ! import org.testng.annotations.Listeners; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.InputSource; /** * URIResolver should be invoked when transform happens. */ ! @Listeners({jaxp.library.FilePolicy.class}) ! public class URIResolverTest implements URIResolver { /** * System ID constant. */ private final static String SYSTEM_ID = "file:///" + XML_DIR;
*** 113,123 **** * This is to test the URIResolver.resolve() method when a transformer is * created using StreamSource. style-sheet file has xsl:include in it. * * @throws Exception If any errors occur. */ ! @Test (groups = {"readLocalFiles"}) public static void resolver01() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) { TransformerFactory tfactory = TransformerFactory.newInstance(); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); tfactory.setURIResolver(resolver); --- 117,127 ---- * This is to test the URIResolver.resolve() method when a transformer is * created using StreamSource. style-sheet file has xsl:include in it. * * @throws Exception If any errors occur. */ ! @Test public static void resolver01() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) { TransformerFactory tfactory = TransformerFactory.newInstance(); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); tfactory.setURIResolver(resolver);
*** 132,142 **** * This is to test the URIResolver.resolve() method when a transformer is * created using DOMSource. style-sheet file has xsl:include in it. * * @throws Exception If any errors occur. */ ! @Test (groups = {"readLocalFiles"}) public static void resolver02() throws Exception { TransformerFactory tfactory = TransformerFactory.newInstance(); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); tfactory.setURIResolver(resolver); --- 136,146 ---- * This is to test the URIResolver.resolve() method when a transformer is * created using DOMSource. style-sheet file has xsl:include in it. * * @throws Exception If any errors occur. */ ! @Test public static void resolver02() throws Exception { TransformerFactory tfactory = TransformerFactory.newInstance(); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); tfactory.setURIResolver(resolver);
*** 153,163 **** * This is to test the URIResolver.resolve() method when a transformer is * created using SAXSource. style-sheet file has xsl:include in it. * * @throws Exception If any errors occur. */ ! @Test (groups = {"readLocalFiles"}) public static void resolver03() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)){ URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); --- 157,167 ---- * This is to test the URIResolver.resolve() method when a transformer is * created using SAXSource. style-sheet file has xsl:include in it. * * @throws Exception If any errors occur. */ ! @Test public static void resolver03() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)){ URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver);
*** 172,182 **** * This is to test the URIResolver.resolve() method when a transformer is * created using StreamSource. style-sheet file has xsl:import in it. * * @throws Exception If any errors occur. */ ! @Test (groups = {"readLocalFiles"}) public static void resolver04() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) { URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); --- 176,186 ---- * This is to test the URIResolver.resolve() method when a transformer is * created using StreamSource. style-sheet file has xsl:import in it. * * @throws Exception If any errors occur. */ ! @Test public static void resolver04() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) { URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver);
*** 190,200 **** * This is to test the URIResolver.resolve() method when a transformer is * created using DOMSource. style-sheet file has xsl:import in it. * * @throws Exception If any errors occur. */ ! @Test (groups = {"readLocalFiles"}) public static void resolver05() throws Exception { URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); --- 194,204 ---- * This is to test the URIResolver.resolve() method when a transformer is * created using DOMSource. style-sheet file has xsl:import in it. * * @throws Exception If any errors occur. */ ! @Test public static void resolver05() throws Exception { URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
*** 209,219 **** * This is to test the URIResolver.resolve() method when a transformer is * created using SAXSource. style-sheet file has xsl:import in it. * * @throws Exception If any errors occur. */ ! @Test (groups = {"readLocalFiles"}) public static void resolver06() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){ URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); --- 213,223 ---- * This is to test the URIResolver.resolve() method when a transformer is * created using SAXSource. style-sheet file has xsl:import in it. * * @throws Exception If any errors occur. */ ! @Test public static void resolver06() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){ URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver);
*** 228,238 **** * This is to test the URIResolver.resolve() method when there is an error * in the file. * * @throws Exception If any errors occur. */ ! @Test (groups = {"readLocalFiles"}) public static void docResolver01() throws Exception { try (FileInputStream fis = new FileInputStream(XML_DIR + "doctest.xsl")) { URIResolverTest resolver = new URIResolverTest("temp/colors.xml", SYSTEM_ID); StreamSource streamSource = new StreamSource(fis); streamSource.setSystemId(SYSTEM_ID); --- 232,242 ---- * This is to test the URIResolver.resolve() method when there is an error * in the file. * * @throws Exception If any errors occur. */ ! @Test public static void docResolver01() throws Exception { try (FileInputStream fis = new FileInputStream(XML_DIR + "doctest.xsl")) { URIResolverTest resolver = new URIResolverTest("temp/colors.xml", SYSTEM_ID); StreamSource streamSource = new StreamSource(fis); streamSource.setSystemId(SYSTEM_ID);
< prev index next >