jdk/test/javax/swing/text/html/HTMLEditorKit/7104635/HTMLEditorKitWriterBug.java
author rchamyal
Thu, 21 Jan 2016 13:09:17 +0530
changeset 35689 fc4e2debc320
child 36922 cf668c19e0de
permissions -rw-r--r--
7104635: HTMLEditorKit fails to write down some html files Reviewed-by: serb, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35689
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     1
/*
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     4
 *
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     8
 *
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    13
 * accompanied this code).
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    14
 *
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    18
 *
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    21
 * questions.
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    22
 */
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    23
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    24
/*
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    25
 * @test
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    26
 * @bug 7104635
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    27
 * @summary HTMLEditorKit fails to write down some html files
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    28
 * @run main HTMLEditorKitWriterBug
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    29
 */
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    30
import java.io.CharArrayReader;
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    31
import java.io.CharArrayWriter;
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    32
import javax.swing.text.html.HTMLDocument;
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    33
import javax.swing.text.html.HTMLEditorKit;
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    34
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    35
public class HTMLEditorKitWriterBug {
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    36
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    37
    public static void main(String[] args) {
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    38
        String htmlDoc = "<pre><p> </pre>";
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    39
        try {
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    40
            HTMLEditorKit kit = new HTMLEditorKit();
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    41
            Class c = Class.forName(
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    42
                    "javax.swing.text.html.parser.ParserDelegator");
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    43
            HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance();
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    44
            HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    45
            HTMLEditorKit.ParserCallback htmlReader = doc.getReader(0);
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    46
            parser.parse(new CharArrayReader(htmlDoc.toCharArray()),
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    47
                    htmlReader, true);
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    48
            htmlReader.flush();
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    49
            CharArrayWriter writer = new CharArrayWriter(1000);
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    50
            kit.write(writer, doc, 0, doc.getLength());
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    51
            writer.flush();
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    52
        } catch (Exception ex) {
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    53
            throw new RuntimeException("Test Failed " + ex);
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    54
        }
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    55
    }
fc4e2debc320 7104635: HTMLEditorKit fails to write down some html files
rchamyal
parents:
diff changeset
    56
}