author | martin |
Wed, 02 Sep 2015 14:11:50 -0700 | |
changeset 32427 | c22b7e41adf3 |
parent 21258 | 317e884625eb |
permissions | -rw-r--r-- |
21258 | 1 |
/* |
2 |
* Copyright (c) 2013, 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 |
import java.io.CharArrayReader; |
|
25 |
import java.io.CharArrayWriter; |
|
26 |
import javax.swing.text.html.HTMLDocument; |
|
27 |
import javax.swing.text.html.HTMLEditorKit; |
|
28 |
||
29 |
/** |
|
30 |
* @test |
|
31 |
* @bug 8005391 |
|
32 |
* @author Alexander Shusherov |
|
33 |
* @summary Floating behavior of HTMLEditorKit parser |
|
34 |
* @run main bug8005391 |
|
35 |
*/ |
|
36 |
public class bug8005391 { |
|
37 |
||
38 |
private static final String htmlDoc = "<html><body><tt><a href='one'>1</a>2</tt></body></html>"; |
|
39 |
||
40 |
public static void main(String[] args) throws Exception { |
|
41 |
int N = 10; |
|
42 |
||
43 |
for (int i = 0; i < N; i++) { |
|
44 |
HTMLEditorKit kit = new HTMLEditorKit(); |
|
45 |
Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator"); |
|
46 |
HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance(); |
|
47 |
HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument(); |
|
48 |
HTMLEditorKit.ParserCallback htmlReader = doc.getReader(0); |
|
49 |
parser.parse(new CharArrayReader(htmlDoc.toCharArray()), htmlReader, true); |
|
50 |
htmlReader.flush(); |
|
51 |
CharArrayWriter writer = new CharArrayWriter(1000); |
|
52 |
kit.write(writer, doc, 0, doc.getLength()); |
|
53 |
writer.flush(); |
|
54 |
||
55 |
String result = writer.toString(); |
|
56 |
if (!result.contains("<tt><a")) { |
|
57 |
throw new RuntimeException("The <a> and <tt> tags are swapped"); |
|
58 |
} |
|
59 |
} |
|
60 |
} |
|
32427
c22b7e41adf3
8134984: Text files should end in exactly one newline
martin
parents:
21258
diff
changeset
|
61 |
} |