TestJEditor.java revision 13901:b2a69d66dc65
1/*
2 * Copyright (c) 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 */
23import java.io.IOException;
24import java.io.InputStream;
25import java.io.OutputStream;
26import java.io.Reader;
27import java.io.Writer;
28import javax.swing.Action;
29import javax.swing.JEditorPane;
30import javax.swing.SwingUtilities;
31import javax.swing.text.BadLocationException;
32import javax.swing.text.Caret;
33import javax.swing.text.Document;
34import javax.swing.text.EditorKit;
35import javax.swing.text.ViewFactory;
36
37/*
38 * @test
39 * @bug 8080972
40 * @summary Audit Core Reflection in module java.desktop for places that will
41 *          require changes to work with modules
42 * @author Alexander Scherbatiy
43 */
44public class TestJEditor {
45
46    public static void main(String[] args) throws Exception {
47
48        SwingUtilities.invokeAndWait(TestJEditor::testJEditorPane);
49        System.setSecurityManager(new SecurityManager());
50        SwingUtilities.invokeAndWait(TestJEditor::testJEditorPane);
51    }
52
53    private static void testJEditorPane() {
54
55        try {
56
57            JEditorPane.registerEditorKitForContentType("text/html", UserEditorKit.class.getName());
58            EditorKit editorKit = JEditorPane.createEditorKitForContentType("text/html");
59
60            if (!(editorKit instanceof UserEditorKit)) {
61                throw new RuntimeException("Editor kit is not UserEditorKit!");
62            }
63        } catch (Exception e) {
64            throw new RuntimeException(e);
65        }
66    }
67
68    public static class UserEditorKit extends EditorKit {
69
70        @Override
71        public String getContentType() {
72            throw new UnsupportedOperationException("Not supported yet.");
73        }
74
75        @Override
76        public ViewFactory getViewFactory() {
77            throw new UnsupportedOperationException("Not supported yet.");
78        }
79
80        @Override
81        public Action[] getActions() {
82            throw new UnsupportedOperationException("Not supported yet.");
83        }
84
85        @Override
86        public Caret createCaret() {
87            throw new UnsupportedOperationException("Not supported yet.");
88        }
89
90        @Override
91        public Document createDefaultDocument() {
92            throw new UnsupportedOperationException("Not supported yet.");
93        }
94
95        @Override
96        public void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException {
97            throw new UnsupportedOperationException("Not supported yet.");
98        }
99
100        @Override
101        public void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException {
102            throw new UnsupportedOperationException("Not supported yet.");
103        }
104
105        @Override
106        public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException {
107            throw new UnsupportedOperationException("Not supported yet.");
108        }
109
110        @Override
111        public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException {
112            throw new UnsupportedOperationException("Not supported yet.");
113        }
114    }
115}
116