< prev index next >
test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * 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,34 +20,38 @@
* 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 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.Listeners;
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 {
+@Listeners({jaxp.library.FilePolicy.class})
+public class URIResolverTest implements URIResolver {
/**
* System ID constant.
*/
private final static String SYSTEM_ID = "file:///" + XML_DIR;
@@ -113,11 +117,11 @@
* 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"})
+ @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,11 +136,11 @@
* 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"})
+ @Test
public static void resolver02() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance();
URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
tfactory.setURIResolver(resolver);
@@ -153,11 +157,11 @@
* 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"})
+ @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,11 +176,11 @@
* 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"})
+ @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,11 +194,11 @@
* 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"})
+ @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,11 +213,11 @@
* 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"})
+ @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,11 +232,11 @@
* 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"})
+ @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 >