< prev index next >
test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.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,66 ****
* 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 java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
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.StreamSource;
! import jaxp.library.JAXPFileReadOnlyBaseTest;
! import static org.testng.Assert.assertEquals;
! import static org.testng.Assert.assertNotNull;
! import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
/**
* Basic test cases for Transformer API
*/
! public class TransformerTest extends JAXPFileReadOnlyBaseTest {
/**
* XSLT file serves every test method.
*/
private final static String TEST_XSL = XML_DIR + "cities.xsl";
/**
* This tests if newTransformer(StreamSource) method returns Transformer.
* @throws TransformerConfigurationException If for some reason the
* TransformerHandler can not be created.
*/
! @Test (groups = {"readLocalFiles"})
public void transformer01() throws TransformerConfigurationException {
TransformerFactory tfactory = TransformerFactory.newInstance();
StreamSource streamSource = new StreamSource(
new File(TEST_XSL));
Transformer transformer = tfactory.newTransformer(streamSource);
--- 20,70 ----
* 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 static org.testng.Assert.assertTrue;
+
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
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;
/**
* Basic test cases for Transformer API
*/
! @Listeners({jaxp.library.FilePolicy.class})
! public class TransformerTest {
/**
* XSLT file serves every test method.
*/
private final static String TEST_XSL = XML_DIR + "cities.xsl";
/**
* This tests if newTransformer(StreamSource) method returns Transformer.
* @throws TransformerConfigurationException If for some reason the
* TransformerHandler can not be created.
*/
! @Test
public void transformer01() throws TransformerConfigurationException {
TransformerFactory tfactory = TransformerFactory.newInstance();
StreamSource streamSource = new StreamSource(
new File(TEST_XSL));
Transformer transformer = tfactory.newTransformer(streamSource);
*** 69,79 ****
/**
* This tests if newTransformer(SAXSource) method returns Transformer.
* @throws Exception If any errors occur.
*/
! @Test (groups = {"readLocalFiles"})
public void transformer02() throws Exception {
try (FileInputStream fis = new FileInputStream(TEST_XSL)) {
TransformerFactory tfactory = TransformerFactory.newInstance();
SAXSource saxSource = new SAXSource(new InputSource(fis));
Transformer transformer = tfactory.newTransformer(saxSource);
--- 73,83 ----
/**
* This tests if newTransformer(SAXSource) method returns Transformer.
* @throws Exception If any errors occur.
*/
! @Test
public void transformer02() throws Exception {
try (FileInputStream fis = new FileInputStream(TEST_XSL)) {
TransformerFactory tfactory = TransformerFactory.newInstance();
SAXSource saxSource = new SAXSource(new InputSource(fis));
Transformer transformer = tfactory.newTransformer(saxSource);
*** 84,94 ****
/**
* This tests if newTransformer(DOMSource) method returns Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test (groups = {"readLocalFiles"})
public void transformer03() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
--- 88,98 ----
/**
* This tests if newTransformer(DOMSource) method returns Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test
public void transformer03() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
*** 103,113 ****
/**
* This tests set/get ErrorListener methods of Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test (groups = {"readLocalFiles"})
public void transformer04() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new File(TEST_XSL));
--- 107,117 ----
/**
* This tests set/get ErrorListener methods of Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test
public void transformer04() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new File(TEST_XSL));
*** 123,133 ****
/**
* This tests getOutputProperties() method of Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test (groups = {"readLocalFiles"})
public void transformer05() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new File(TEST_XSL));
--- 127,137 ----
/**
* This tests getOutputProperties() method of Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test
public void transformer05() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new File(TEST_XSL));
*** 148,158 ****
/**
* This tests getOutputProperty() method of Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test (groups = {"readLocalFiles"})
public void transformer06() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
--- 152,162 ----
/**
* This tests getOutputProperty() method of Transformer.
*
* @throws Exception If any errors occur.
*/
! @Test
public void transformer06() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
< prev index next >