< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2003, 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 java.io.File;
  27 import java.io.FileInputStream;
  28 import java.io.FileOutputStream;

  29 import javax.xml.parsers.DocumentBuilder;
  30 import javax.xml.parsers.DocumentBuilderFactory;
  31 import javax.xml.transform.Result;
  32 import javax.xml.transform.TransformerConfigurationException;
  33 import javax.xml.transform.TransformerFactory;
  34 import javax.xml.transform.dom.DOMSource;
  35 import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
  36 import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
  37 import javax.xml.transform.sax.SAXSource;
  38 import javax.xml.transform.sax.SAXTransformerFactory;
  39 import javax.xml.transform.sax.TemplatesHandler;
  40 import javax.xml.transform.sax.TransformerHandler;
  41 import javax.xml.transform.stream.StreamResult;
  42 import javax.xml.transform.stream.StreamSource;
  43 import jaxp.library.JAXPFileBaseTest;
  44 import static jaxp.library.JAXPTestUtilities.USER_DIR;
  45 import static jaxp.library.JAXPTestUtilities.compareWithGold;
  46 import static org.testng.Assert.assertTrue;
  47 import org.testng.annotations.Test;
  48 import org.w3c.dom.Document;
  49 import org.w3c.dom.Node;
  50 import org.xml.sax.InputSource;
  51 import org.xml.sax.XMLFilter;
  52 import org.xml.sax.XMLReader;
  53 import org.xml.sax.helpers.XMLReaderFactory;
  54 
  55 /**
  56  * Test newTransformerhandler() method which takes StreamSource as argument can
  57  * be set to XMLReader.
  58  */
  59 public class SAXTFactoryTest extends JAXPFileBaseTest {

  60     /**
  61      * Test style-sheet file.
  62      */
  63     private static final String XSLT_FILE = XML_DIR + "cities.xsl";
  64 
  65     /**
  66      * Test style-sheet file.
  67      */
  68     private static final String XSLT_INCL_FILE = XML_DIR + "citiesinclude.xsl";
  69 
  70     /**
  71      * Test XML file.
  72      */
  73     private static final String XML_FILE = XML_DIR + "cities.xml";
  74 
  75     /**
  76      * SAXTFactory.newTransformerhandler() method which takes SAXSource as
  77      * argument can be set to XMLReader. SAXSource has input XML file as its
  78      * input source. XMLReader has a transformer handler which write out the
  79      * result to output file. Test verifies output file is same as golden file.


   1 /*
   2  * Copyright (c) 2003, 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.GOLDEN_DIR;
  27 import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
  28 import static jaxp.library.JAXPTestUtilities.USER_DIR;
  29 import static jaxp.library.JAXPTestUtilities.compareWithGold;
  30 import static org.testng.Assert.assertTrue;
  31 
  32 import java.io.File;
  33 import java.io.FileInputStream;
  34 import java.io.FileOutputStream;
  35 
  36 import javax.xml.parsers.DocumentBuilder;
  37 import javax.xml.parsers.DocumentBuilderFactory;
  38 import javax.xml.transform.Result;
  39 import javax.xml.transform.TransformerConfigurationException;
  40 import javax.xml.transform.TransformerFactory;
  41 import javax.xml.transform.dom.DOMSource;


  42 import javax.xml.transform.sax.SAXSource;
  43 import javax.xml.transform.sax.SAXTransformerFactory;
  44 import javax.xml.transform.sax.TemplatesHandler;
  45 import javax.xml.transform.sax.TransformerHandler;
  46 import javax.xml.transform.stream.StreamResult;
  47 import javax.xml.transform.stream.StreamSource;
  48 
  49 import org.testng.annotations.Listeners;


  50 import org.testng.annotations.Test;
  51 import org.w3c.dom.Document;
  52 import org.w3c.dom.Node;
  53 import org.xml.sax.InputSource;
  54 import org.xml.sax.XMLFilter;
  55 import org.xml.sax.XMLReader;
  56 import org.xml.sax.helpers.XMLReaderFactory;
  57 
  58 /**
  59  * Test newTransformerhandler() method which takes StreamSource as argument can
  60  * be set to XMLReader.
  61  */
  62 @Listeners({jaxp.library.FilePolicy.class})
  63 public class SAXTFactoryTest {
  64     /**
  65      * Test style-sheet file.
  66      */
  67     private static final String XSLT_FILE = XML_DIR + "cities.xsl";
  68 
  69     /**
  70      * Test style-sheet file.
  71      */
  72     private static final String XSLT_INCL_FILE = XML_DIR + "citiesinclude.xsl";
  73 
  74     /**
  75      * Test XML file.
  76      */
  77     private static final String XML_FILE = XML_DIR + "cities.xml";
  78 
  79     /**
  80      * SAXTFactory.newTransformerhandler() method which takes SAXSource as
  81      * argument can be set to XMLReader. SAXSource has input XML file as its
  82      * input source. XMLReader has a transformer handler which write out the
  83      * result to output file. Test verifies output file is same as golden file.


< prev index next >