Path: blob/master/test/jdk/javax/swing/JEditorPane/8080972/TestJEditor.java
58328 views
/*1* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22import java.io.IOException;23import java.io.InputStream;24import java.io.OutputStream;25import java.io.Reader;26import java.io.Writer;27import javax.swing.Action;28import javax.swing.JEditorPane;29import javax.swing.SwingUtilities;30import javax.swing.text.BadLocationException;31import javax.swing.text.Caret;32import javax.swing.text.Document;33import javax.swing.text.EditorKit;34import javax.swing.text.ViewFactory;3536/*37* @test38* @bug 8080972 816988739* @summary Audit Core Reflection in module java.desktop for places that will40* require changes to work with modules41* @author Alexander Scherbatiy42* @run main/othervm -Djava.security.manager=allow TestJEditor43*/44public class TestJEditor {4546public static void main(String[] args) throws Exception {4748SwingUtilities.invokeAndWait(TestJEditor::testJEditorPane);49System.setSecurityManager(new SecurityManager());50SwingUtilities.invokeAndWait(TestJEditor::testJEditorPane);51}5253private static void testJEditorPane() {5455try {5657JEditorPane.registerEditorKitForContentType("text/html", UserEditorKit.class.getName());58EditorKit editorKit = JEditorPane.createEditorKitForContentType("text/html");5960if (!(editorKit instanceof UserEditorKit)) {61throw new RuntimeException("Editor kit is not UserEditorKit!");62}63} catch (Exception e) {64throw new RuntimeException(e);65}66}6768public static class UserEditorKit extends EditorKit {6970@Override71public String getContentType() {72throw new UnsupportedOperationException("Not supported yet.");73}7475@Override76public ViewFactory getViewFactory() {77throw new UnsupportedOperationException("Not supported yet.");78}7980@Override81public Action[] getActions() {82throw new UnsupportedOperationException("Not supported yet.");83}8485@Override86public Caret createCaret() {87throw new UnsupportedOperationException("Not supported yet.");88}8990@Override91public Document createDefaultDocument() {92throw new UnsupportedOperationException("Not supported yet.");93}9495@Override96public void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException {97throw new UnsupportedOperationException("Not supported yet.");98}99100@Override101public void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException {102throw new UnsupportedOperationException("Not supported yet.");103}104105@Override106public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException {107throw new UnsupportedOperationException("Not supported yet.");108}109110@Override111public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException {112throw new UnsupportedOperationException("Not supported yet.");113}114}115}116117118