< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1999, 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.ByteArrayOutputStream;
  27 import java.io.File;
  28 
  29 import javax.xml.parsers.DocumentBuilder;
  30 import javax.xml.parsers.DocumentBuilderFactory;
  31 import javax.xml.transform.Transformer;
  32 import javax.xml.transform.TransformerFactory;
  33 import javax.xml.transform.dom.DOMSource;
  34 import javax.xml.transform.stream.StreamResult;
  35 import javax.xml.transform.stream.StreamSource;
  36 
  37 import jaxp.library.JAXPFileBaseTest;
  38 import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
  39 
  40 import org.testng.annotations.Test;
  41 import org.w3c.dom.Document;
  42 
  43 /*
  44  * @bug 6384418
  45  * @summary verify the transforming won't throw any exception
  46  */
  47 public class Bug6384418Test extends JAXPFileBaseTest {

  48 
  49     @Test
  50     public void test() throws Exception {
  51         TransformerFactory tfactory = TransformerFactory.newInstance();
  52         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  53         dbf.setNamespaceAware(true);
  54         DocumentBuilder db = dbf.newDocumentBuilder();
  55         Document document = db.parse(new File(XML_DIR + "dataentry.xsl"));
  56         DOMSource domSource = new DOMSource(document);
  57 
  58         Transformer transformer = tfactory.newTransformer(domSource);
  59         StreamSource streamSource = new StreamSource(new File(XML_DIR + "test.xml"));
  60         StreamResult streamResult = new StreamResult(new ByteArrayOutputStream());
  61         transformer.transform(streamSource, streamResult);
  62     }
  63 
  64 }
   1 /*
   2  * Copyright (c) 1999, 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.XML_DIR;
  27 
  28 import java.io.ByteArrayOutputStream;
  29 import java.io.File;
  30 
  31 import javax.xml.parsers.DocumentBuilder;
  32 import javax.xml.parsers.DocumentBuilderFactory;
  33 import javax.xml.transform.Transformer;
  34 import javax.xml.transform.TransformerFactory;
  35 import javax.xml.transform.dom.DOMSource;
  36 import javax.xml.transform.stream.StreamResult;
  37 import javax.xml.transform.stream.StreamSource;
  38 
  39 import org.testng.annotations.Listeners;


  40 import org.testng.annotations.Test;
  41 import org.w3c.dom.Document;
  42 
  43 /*
  44  * @bug 6384418
  45  * @summary verify the transforming won't throw any exception
  46  */
  47 @Listeners({jaxp.library.FilePolicy.class})
  48 public class Bug6384418Test {
  49 
  50     @Test
  51     public void test() throws Exception {
  52         TransformerFactory tfactory = TransformerFactory.newInstance();
  53         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  54         dbf.setNamespaceAware(true);
  55         DocumentBuilder db = dbf.newDocumentBuilder();
  56         Document document = db.parse(new File(XML_DIR + "dataentry.xsl"));
  57         DOMSource domSource = new DOMSource(document);
  58 
  59         Transformer transformer = tfactory.newTransformer(domSource);
  60         StreamSource streamSource = new StreamSource(new File(XML_DIR + "test.xml"));
  61         StreamResult streamResult = new StreamResult(new ByteArrayOutputStream());
  62         transformer.transform(streamSource, streamResult);
  63     }
  64 
  65 }
< prev index next >