Search in sources :

Example 6 with ParserDelegator

use of javax.swing.text.html.parser.ParserDelegator in project jdk8u_jdk by JetBrains.

the class bug6938813 method validate.

private static void validate() throws Exception {
    AppContext appContext = AppContext.getAppContext();
    assertTrue(DTD.getDTD(DTD_KEY).getName().equals(DTD_KEY), "DTD.getDTD() mixed AppContexts");
    // Spoil hash value
    DTD invalidDtd = DTD.getDTD("invalid DTD");
    DTD.putDTDHash(DTD_KEY, invalidDtd);
    assertTrue(DTD.getDTD(DTD_KEY) == invalidDtd, "Something wrong with DTD.getDTD()");
    Object dtdKey = getParserDelegator_DTD_KEY();
    assertTrue(appContext.get(dtdKey) == null, "ParserDelegator mixed AppContexts");
    // Init default DTD
    new ParserDelegator();
    Object dtdValue = appContext.get(dtdKey);
    assertTrue(dtdValue != null, "ParserDelegator.defaultDTD isn't initialized");
    // Try reinit default DTD
    new ParserDelegator();
    assertTrue(dtdValue == appContext.get(dtdKey), "ParserDelegator.defaultDTD created a duplicate");
    HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
    if (styleSheet == null) {
        // First AppContext
        styleSheet = htmlEditorKit.getStyleSheet();
        assertTrue(styleSheet != null, "htmlEditorKit.getStyleSheet() returns null");
        assertTrue(htmlEditorKit.getStyleSheet() == styleSheet, "Something wrong with htmlEditorKit.getStyleSheet()");
    } else {
        assertTrue(htmlEditorKit.getStyleSheet() != styleSheet, "HtmlEditorKit.getStyleSheet() mixed AppContexts");
    }
}
Also used : ParserDelegator(javax.swing.text.html.parser.ParserDelegator) DTD(javax.swing.text.html.parser.DTD) AppContext(sun.awt.AppContext) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit)

Aggregations

ParserDelegator (javax.swing.text.html.parser.ParserDelegator)6 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)5 MutableAttributeSet (javax.swing.text.MutableAttributeSet)4 FileReader (java.io.FileReader)3 HTML (javax.swing.text.html.HTML)3 IOException (java.io.IOException)2 Reader (java.io.Reader)2 NotNull (org.jetbrains.annotations.NotNull)2 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 File (java.io.File)1 StringReader (java.io.StringReader)1 DTD (javax.swing.text.html.parser.DTD)1 AppContext (sun.awt.AppContext)1