jaxp/test/javax/xml/jaxp/unittest/org/w3c/dom/ls/Bug4973153.java
author joehw
Mon, 08 Jun 2015 21:59:07 -0700
changeset 31104 79a0696bbd7c
parent 27830 85b0d46b0104
permissions -rw-r--r--
8080906: Develop test for Xerces Update: DOM L3 Serializer Reviewed-by: lancea, joehw Contributed-by: frank.yuan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27830
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     1
/*
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     4
 *
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     8
 *
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    13
 * accompanied this code).
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    14
 *
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    18
 *
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    21
 * questions.
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    22
 */
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    23
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    24
package org.w3c.dom.ls;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    25
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    26
import java.io.ByteArrayOutputStream;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    27
import java.io.IOException;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    28
import java.io.OutputStream;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    29
import java.io.StringBufferInputStream;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    30
import java.io.Writer;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    31
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    32
import javax.xml.parsers.DocumentBuilder;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    33
import javax.xml.parsers.DocumentBuilderFactory;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    34
import javax.xml.parsers.ParserConfigurationException;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    35
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    36
import org.testng.Assert;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    37
import org.testng.annotations.AfterMethod;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    38
import org.testng.annotations.BeforeMethod;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    39
import org.testng.annotations.Test;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    40
import org.w3c.dom.DOMError;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    41
import org.w3c.dom.DOMErrorHandler;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    42
import org.w3c.dom.DOMImplementation;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    43
import org.w3c.dom.Document;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    44
import org.w3c.dom.ls.DOMImplementationLS;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    45
import org.w3c.dom.ls.LSInput;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    46
import org.w3c.dom.ls.LSOutput;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    47
import org.w3c.dom.ls.LSParser;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    48
import org.w3c.dom.ls.LSSerializer;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    49
import org.xml.sax.SAXException;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    50
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    51
/*
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    52
 * @bug 4973153
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    53
 * @summary Test LSSerialiser.setEncoding() raises 'unsupported-encoding' error if encoding is invalid.
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    54
 */
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    55
public class Bug4973153 {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    56
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    57
    DOMImplementationLS implLS = null;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    58
    public String xml1 = "<?xml version=\"1.0\"?><ROOT><ELEMENT1></ELEMENT1><ELEMENT2></ELEMENT2></ROOT>";
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    59
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    60
    @Test
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    61
    public void testOne() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    62
        LSParser db = createLSParser();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    63
        if (db == null) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    64
            System.out.println("Unable to create LSParser !");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    65
            return;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    66
        }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    67
        LSSerializer dw = createLSSerializer();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    68
        if (dw == null) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    69
            System.out.println("Unable to create LSSerializer!");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    70
            return;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    71
        }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    72
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    73
        DOMErrorHandlerImpl eh = new DOMErrorHandlerImpl();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    74
        dw.getDomConfig().setParameter("error-handler", eh);
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    75
        Document doc = db.parse(getXml1Source());
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    76
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    77
        Output out = new Output();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    78
        out.setByteStream(new ByteArrayOutputStream());
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    79
        out.setEncoding("WrOnG_EnCoDiNg");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    80
        try {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    81
            if (dw.write(doc, out)) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    82
                System.out.println("Expected result value - false");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    83
                return;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    84
            }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    85
        } catch (Exception ex) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    86
            // This is bad.
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    87
        }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    88
        if (!eh.WrongEncodingErrorReceived) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    89
            Assert.fail("'unsupported-encoding' error was expected ");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    90
            return;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    91
        }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    92
        System.out.println("OKAY");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    93
        return;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    94
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    95
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    96
    @BeforeMethod
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    97
    protected void setUp() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    98
        Document doc = null;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
    99
        DocumentBuilder parser = null;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   100
        try {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   101
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   102
            parser = factory.newDocumentBuilder();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   103
        } catch (ParserConfigurationException e) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   104
            e.printStackTrace();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   105
        }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   106
        StringBufferInputStream is = new StringBufferInputStream(xml1);
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   107
        try {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   108
            doc = parser.parse(is);
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   109
        } catch (SAXException e) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   110
            e.printStackTrace();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   111
        } catch (IOException e) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   112
            e.printStackTrace();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   113
        }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   114
        DOMImplementation impl = doc.getImplementation();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   115
        implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   116
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   117
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   118
    @AfterMethod
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   119
    protected void tearDown() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   120
        implLS = null;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   121
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   122
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   123
    public LSParser createLSParser() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   124
        return implLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, "http://www.w3.org/2001/XMLSchema");
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   125
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   126
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   127
    public LSSerializer createLSSerializer() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   128
        return implLS.createLSSerializer();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   129
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   130
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   131
    public LSInput createLSInput() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   132
        return implLS.createLSInput();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   133
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   134
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   135
    public LSInput getXml1Source() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   136
        LSInput src = createLSInput();
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   137
        src.setStringData(xml1);
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   138
        return src;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   139
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   140
}
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   141
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   142
class Output implements LSOutput {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   143
    OutputStream bs;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   144
    Writer cs;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   145
    String sId;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   146
    String enc;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   147
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   148
    public Output() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   149
        bs = null;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   150
        cs = null;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   151
        sId = null;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   152
        enc = "UTF-8";
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   153
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   154
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   155
    public OutputStream getByteStream() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   156
        return bs;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   157
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   158
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   159
    public void setByteStream(OutputStream byteStream) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   160
        bs = byteStream;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   161
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   162
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   163
    public Writer getCharacterStream() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   164
        return cs;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   165
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   166
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   167
    public void setCharacterStream(Writer characterStream) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   168
        cs = characterStream;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   169
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   170
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   171
    public String getSystemId() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   172
        return sId;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   173
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   174
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   175
    public void setSystemId(String systemId) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   176
        sId = systemId;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   177
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   178
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   179
    public String getEncoding() {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   180
        return enc;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   181
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   182
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   183
    public void setEncoding(String encoding) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   184
        enc = encoding;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   185
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   186
}
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   187
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   188
class DOMErrorHandlerImpl implements DOMErrorHandler {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   189
    boolean NoOutputSpecifiedErrorReceived = false;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   190
    boolean WrongEncodingErrorReceived = false;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   191
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   192
    public boolean handleError(DOMError error) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   193
        if ("no-output-specified".equalsIgnoreCase(error.getType())) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   194
            NoOutputSpecifiedErrorReceived = true;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   195
        } else if ("unsupported-encoding".equalsIgnoreCase(error.getType())) {
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   196
            WrongEncodingErrorReceived = true;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   197
        }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   198
        return true;
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   199
    }
85b0d46b0104 8043084: XML JAXP unittest co-location
joehw
parents:
diff changeset
   200
}