< prev index next >

test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.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 package javax.xml.transform.ptests;
  24 




  25 import java.io.File;
  26 import java.io.FileInputStream;
  27 import java.io.IOException;
  28 import java.util.Arrays;
  29 import java.util.Properties;

  30 import javax.xml.parsers.DocumentBuilder;
  31 import javax.xml.parsers.DocumentBuilderFactory;
  32 import javax.xml.parsers.ParserConfigurationException;
  33 import javax.xml.transform.Transformer;
  34 import javax.xml.transform.TransformerException;
  35 import javax.xml.transform.TransformerFactory;
  36 import javax.xml.transform.dom.DOMSource;
  37 import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
  38 import javax.xml.transform.stream.StreamResult;
  39 import javax.xml.transform.stream.StreamSource;
  40 import jaxp.library.JAXPFileBaseTest;
  41 import static jaxp.library.JAXPTestUtilities.USER_DIR;
  42 import static jaxp.library.JAXPTestUtilities.failUnexpected;
  43 import org.testng.annotations.Test;
  44 import org.w3c.dom.Document;
  45 import org.xml.sax.SAXException;
  46 
  47 /**
  48  * Test a StreamResult using a file name that contains URL characters that need
  49  * to be encoded.
  50  */
  51 public class StreamResultTest extends JAXPFileBaseTest {

  52     /**
  53      * Unit test for StreamResult.
  54      */
  55     @Test
  56     public void testcase01() {
  57         // Set Transformer properties
  58         Properties transformProperties = new Properties();
  59         transformProperties.put("method", "xml");
  60         transformProperties.put("encoding", "UTF-8");
  61         transformProperties.put("omit-xml-declaration", "yes");
  62         transformProperties.put("{http://xml.apache.org/xslt}indent-amount", "0");
  63         transformProperties.put("indent", "no");
  64         transformProperties.put("standalone", "no");
  65         transformProperties.put("version", "1.0");
  66         transformProperties.put("media-type", "text/xml");
  67 
  68         String[] fileNames = {
  69             "StreamResult01.out",
  70             "StreamResult 02.out",
  71             "StreamResult#03.out"


   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 package javax.xml.transform.ptests;
  24 
  25 import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
  26 import static jaxp.library.JAXPTestUtilities.USER_DIR;
  27 import static jaxp.library.JAXPTestUtilities.failUnexpected;
  28 
  29 import java.io.File;
  30 import java.io.FileInputStream;
  31 import java.io.IOException;
  32 import java.util.Arrays;
  33 import java.util.Properties;
  34 
  35 import javax.xml.parsers.DocumentBuilder;
  36 import javax.xml.parsers.DocumentBuilderFactory;
  37 import javax.xml.parsers.ParserConfigurationException;
  38 import javax.xml.transform.Transformer;
  39 import javax.xml.transform.TransformerException;
  40 import javax.xml.transform.TransformerFactory;
  41 import javax.xml.transform.dom.DOMSource;

  42 import javax.xml.transform.stream.StreamResult;
  43 import javax.xml.transform.stream.StreamSource;
  44 
  45 import org.testng.annotations.Listeners;

  46 import org.testng.annotations.Test;
  47 import org.w3c.dom.Document;
  48 import org.xml.sax.SAXException;
  49 
  50 /**
  51  * Test a StreamResult using a file name that contains URL characters that need
  52  * to be encoded.
  53  */
  54 @Listeners({jaxp.library.FilePolicy.class})
  55 public class StreamResultTest {
  56     /**
  57      * Unit test for StreamResult.
  58      */
  59     @Test
  60     public void testcase01() {
  61         // Set Transformer properties
  62         Properties transformProperties = new Properties();
  63         transformProperties.put("method", "xml");
  64         transformProperties.put("encoding", "UTF-8");
  65         transformProperties.put("omit-xml-declaration", "yes");
  66         transformProperties.put("{http://xml.apache.org/xslt}indent-amount", "0");
  67         transformProperties.put("indent", "no");
  68         transformProperties.put("standalone", "no");
  69         transformProperties.put("version", "1.0");
  70         transformProperties.put("media-type", "text/xml");
  71 
  72         String[] fileNames = {
  73             "StreamResult01.out",
  74             "StreamResult 02.out",
  75             "StreamResult#03.out"


< prev index next >