< prev index next >

test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.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.ls;
  25 
  26 import java.io.ByteArrayOutputStream;
  27 import java.io.IOException;
  28 import java.io.OutputStream;
  29 import java.io.StringBufferInputStream;
  30 import java.io.Writer;
  31 
  32 import javax.xml.parsers.DocumentBuilder;
  33 import javax.xml.parsers.DocumentBuilderFactory;
  34 import javax.xml.parsers.ParserConfigurationException;
  35 
  36 import org.testng.Assert;
  37 import org.testng.annotations.AfterMethod;
  38 import org.testng.annotations.BeforeMethod;

  39 import org.testng.annotations.Test;
  40 import org.w3c.dom.DOMError;
  41 import org.w3c.dom.DOMErrorHandler;
  42 import org.w3c.dom.DOMImplementation;
  43 import org.w3c.dom.Document;
  44 import org.w3c.dom.ls.DOMImplementationLS;
  45 import org.w3c.dom.ls.LSInput;
  46 import org.w3c.dom.ls.LSOutput;
  47 import org.w3c.dom.ls.LSParser;
  48 import org.w3c.dom.ls.LSSerializer;
  49 import org.xml.sax.SAXException;
  50 
  51 /*
  52  * @bug 4973153
  53  * @summary Test LSSerialiser.setEncoding() raises 'unsupported-encoding' error if encoding is invalid.
  54  */

  55 public class Bug4973153 {
  56 
  57     DOMImplementationLS implLS = null;
  58     public String xml1 = "<?xml version=\"1.0\"?><ROOT><ELEMENT1></ELEMENT1><ELEMENT2></ELEMENT2></ROOT>";
  59 
  60     @Test
  61     public void testOne() {
  62         LSParser db = createLSParser();
  63         if (db == null) {
  64             System.out.println("Unable to create LSParser !");
  65             return;
  66         }
  67         LSSerializer dw = createLSSerializer();
  68         if (dw == null) {
  69             System.out.println("Unable to create LSSerializer!");
  70             return;
  71         }
  72 
  73         DOMErrorHandlerImpl eh = new DOMErrorHandlerImpl();
  74         dw.getDomConfig().setParameter("error-handler", eh);


   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.ls;
  25 
  26 import java.io.ByteArrayOutputStream;
  27 import java.io.IOException;
  28 import java.io.OutputStream;
  29 import java.io.StringBufferInputStream;
  30 import java.io.Writer;
  31 
  32 import javax.xml.parsers.DocumentBuilder;
  33 import javax.xml.parsers.DocumentBuilderFactory;
  34 import javax.xml.parsers.ParserConfigurationException;
  35 
  36 import org.testng.Assert;
  37 import org.testng.annotations.AfterMethod;
  38 import org.testng.annotations.BeforeMethod;
  39 import org.testng.annotations.Listeners;
  40 import org.testng.annotations.Test;
  41 import org.w3c.dom.DOMError;
  42 import org.w3c.dom.DOMErrorHandler;
  43 import org.w3c.dom.DOMImplementation;
  44 import org.w3c.dom.Document;
  45 import org.w3c.dom.ls.DOMImplementationLS;
  46 import org.w3c.dom.ls.LSInput;
  47 import org.w3c.dom.ls.LSOutput;
  48 import org.w3c.dom.ls.LSParser;
  49 import org.w3c.dom.ls.LSSerializer;
  50 import org.xml.sax.SAXException;
  51 
  52 /*
  53  * @bug 4973153
  54  * @summary Test LSSerialiser.setEncoding() raises 'unsupported-encoding' error if encoding is invalid.
  55  */
  56 @Listeners({jaxp.library.BasePolicy.class})
  57 public class Bug4973153 {
  58 
  59     DOMImplementationLS implLS = null;
  60     public String xml1 = "<?xml version=\"1.0\"?><ROOT><ELEMENT1></ELEMENT1><ELEMENT2></ELEMENT2></ROOT>";
  61 
  62     @Test
  63     public void testOne() {
  64         LSParser db = createLSParser();
  65         if (db == null) {
  66             System.out.println("Unable to create LSParser !");
  67             return;
  68         }
  69         LSSerializer dw = createLSSerializer();
  70         if (dw == null) {
  71             System.out.println("Unable to create LSSerializer!");
  72             return;
  73         }
  74 
  75         DOMErrorHandlerImpl eh = new DOMErrorHandlerImpl();
  76         dw.getDomConfig().setParameter("error-handler", eh);


< prev index next >