< prev index next >

test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.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.IOException;
  27 import java.io.OutputStream;
  28 import java.io.StringReader;
  29 import java.io.Writer;
  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.Test;
  37 import org.w3c.dom.DOMConfiguration;
  38 import org.w3c.dom.DOMError;
  39 import org.w3c.dom.DOMErrorHandler;
  40 import org.w3c.dom.DOMImplementation;
  41 import org.w3c.dom.Document;
  42 import org.w3c.dom.ls.DOMImplementationLS;
  43 import org.w3c.dom.ls.LSException;
  44 import org.w3c.dom.ls.LSOutput;
  45 import org.w3c.dom.ls.LSSerializer;
  46 import org.xml.sax.InputSource;
  47 import org.xml.sax.SAXException;
  48 
  49 
  50 /*
  51  * @bug 6439439 8080906
  52  * @summary Test LSSerializer.
  53  */

  54 public class LSSerializerTest {
  55     private static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
  56 
  57     class DOMErrorHandlerImpl implements DOMErrorHandler {
  58 
  59         boolean NoOutputSpecifiedErrorReceived = false;
  60 
  61         public boolean handleError(final DOMError error) {
  62             // consume "no-output-specified" errors
  63             if ("no-output-specified".equalsIgnoreCase(error.getType())) {
  64                 NoOutputSpecifiedErrorReceived = true;
  65                 return true;
  66             }
  67 
  68             // unexpected error
  69             Assert.fail("Unexpected Error Type: " + error.getType() + " @ (" + error.getLocation().getLineNumber() + ", "
  70                     + error.getLocation().getColumnNumber() + ")" + ", " + error.getMessage());
  71 
  72             return false;
  73         }


   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.IOException;
  27 import java.io.OutputStream;
  28 import java.io.StringReader;
  29 import java.io.Writer;
  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.Listeners;
  37 import org.testng.annotations.Test;
  38 import org.w3c.dom.DOMConfiguration;
  39 import org.w3c.dom.DOMError;
  40 import org.w3c.dom.DOMErrorHandler;
  41 import org.w3c.dom.DOMImplementation;
  42 import org.w3c.dom.Document;
  43 import org.w3c.dom.ls.DOMImplementationLS;
  44 import org.w3c.dom.ls.LSException;
  45 import org.w3c.dom.ls.LSOutput;
  46 import org.w3c.dom.ls.LSSerializer;
  47 import org.xml.sax.InputSource;
  48 import org.xml.sax.SAXException;
  49 
  50 
  51 /*
  52  * @bug 6439439 8080906
  53  * @summary Test LSSerializer.
  54  */
  55 @Listeners({jaxp.library.BasePolicy.class})
  56 public class LSSerializerTest {
  57     private static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
  58 
  59     class DOMErrorHandlerImpl implements DOMErrorHandler {
  60 
  61         boolean NoOutputSpecifiedErrorReceived = false;
  62 
  63         public boolean handleError(final DOMError error) {
  64             // consume "no-output-specified" errors
  65             if ("no-output-specified".equalsIgnoreCase(error.getType())) {
  66                 NoOutputSpecifiedErrorReceived = true;
  67                 return true;
  68             }
  69 
  70             // unexpected error
  71             Assert.fail("Unexpected Error Type: " + error.getType() + " @ (" + error.getLocation().getLineNumber() + ", "
  72                     + error.getLocation().getColumnNumber() + ")" + ", " + error.getMessage());
  73 
  74             return false;
  75         }


< prev index next >