< prev index next >

test/javax/xml/jaxp/unittest/dom/Bug6355326.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 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 dom;
  25 
  26 import java.io.ByteArrayInputStream;
  27 import java.io.IOException;
  28 import java.io.StringBufferInputStream;
  29 import java.io.UnsupportedEncodingException;
  30 
  31 import javax.xml.parsers.DocumentBuilder;
  32 import javax.xml.parsers.DocumentBuilderFactory;
  33 import javax.xml.parsers.ParserConfigurationException;
  34 
  35 import org.testng.Assert;
  36 import org.testng.annotations.BeforeMethod;

  37 import org.testng.annotations.Test;
  38 import org.w3c.dom.DOMImplementation;
  39 import org.w3c.dom.Document;
  40 import org.w3c.dom.ls.DOMImplementationLS;
  41 import org.w3c.dom.ls.LSInput;
  42 import org.w3c.dom.ls.LSParser;
  43 import org.xml.sax.SAXException;
  44 
  45 /*
  46  * @bug 6355326
  47  * @summary Test DOM implementation encoding.
  48  */

  49 public class Bug6355326 {
  50 
  51     DOMImplementationLS implLS = null;
  52     String encodingXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><encodingXML/>";
  53 
  54     @BeforeMethod
  55     protected void setUp() {
  56         Document doc = null;
  57         DocumentBuilder parser = null;
  58         String xml1 = "<?xml version=\"1.0\"?><ROOT></ROOT>";
  59         try {
  60             parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  61         } catch (ParserConfigurationException e) {
  62             e.printStackTrace();
  63         }
  64         StringBufferInputStream is = new StringBufferInputStream(xml1);
  65         try {
  66             doc = parser.parse(is);
  67         } catch (SAXException e) {
  68             e.printStackTrace();


   1 /*
   2  * Copyright (c) 2014, 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 dom;
  25 
  26 import java.io.ByteArrayInputStream;
  27 import java.io.IOException;
  28 import java.io.StringBufferInputStream;
  29 import java.io.UnsupportedEncodingException;
  30 
  31 import javax.xml.parsers.DocumentBuilder;
  32 import javax.xml.parsers.DocumentBuilderFactory;
  33 import javax.xml.parsers.ParserConfigurationException;
  34 
  35 import org.testng.Assert;
  36 import org.testng.annotations.BeforeMethod;
  37 import org.testng.annotations.Listeners;
  38 import org.testng.annotations.Test;
  39 import org.w3c.dom.DOMImplementation;
  40 import org.w3c.dom.Document;
  41 import org.w3c.dom.ls.DOMImplementationLS;
  42 import org.w3c.dom.ls.LSInput;
  43 import org.w3c.dom.ls.LSParser;
  44 import org.xml.sax.SAXException;
  45 
  46 /*
  47  * @bug 6355326
  48  * @summary Test DOM implementation encoding.
  49  */
  50 @Listeners({jaxp.library.BasePolicy.class})
  51 public class Bug6355326 {
  52 
  53     DOMImplementationLS implLS = null;
  54     String encodingXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><encodingXML/>";
  55 
  56     @BeforeMethod
  57     protected void setUp() {
  58         Document doc = null;
  59         DocumentBuilder parser = null;
  60         String xml1 = "<?xml version=\"1.0\"?><ROOT></ROOT>";
  61         try {
  62             parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  63         } catch (ParserConfigurationException e) {
  64             e.printStackTrace();
  65         }
  66         StringBufferInputStream is = new StringBufferInputStream(xml1);
  67         try {
  68             doc = parser.parse(is);
  69         } catch (SAXException e) {
  70             e.printStackTrace();


< prev index next >