Search in sources :

Example 1 with LocalizedMessages

use of com.puppycrawl.tools.checkstyle.api.LocalizedMessages in project checkstyle by checkstyle.

the class IllegalInstantiationCheckTest method testNullClassLoader.

@Test
public void testNullClassLoader() throws Exception {
    final DetailAST exprAst = new DetailAST();
    exprAst.setType(TokenTypes.EXPR);
    final DetailAST newAst = new DetailAST();
    newAst.setType(TokenTypes.LITERAL_NEW);
    newAst.setLineNo(1);
    newAst.setColumnNo(1);
    final DetailAST identAst = new DetailAST();
    identAst.setType(TokenTypes.IDENT);
    identAst.setText("Boolean");
    final DetailAST lparenAst = new DetailAST();
    lparenAst.setType(TokenTypes.LPAREN);
    final DetailAST elistAst = new DetailAST();
    elistAst.setType(TokenTypes.ELIST);
    final DetailAST rparenAst = new DetailAST();
    rparenAst.setType(TokenTypes.RPAREN);
    exprAst.addChild(newAst);
    newAst.addChild(identAst);
    identAst.setNextSibling(lparenAst);
    lparenAst.setNextSibling(elistAst);
    elistAst.setNextSibling(rparenAst);
    final IllegalInstantiationCheck check = new IllegalInstantiationCheck();
    final File inputFile = new File(getNonCompilablePath("InputIllegalInstantiationLang.java"));
    check.setFileContents(new FileContents(new FileText(inputFile, "UTF-8")));
    check.configure(createCheckConfig(IllegalInstantiationCheck.class));
    check.setMessages(new LocalizedMessages());
    check.setClasses("java.lang.Boolean");
    check.visitToken(newAst);
    check.finishTree(newAst);
}
Also used : LocalizedMessages(com.puppycrawl.tools.checkstyle.api.LocalizedMessages) FileContents(com.puppycrawl.tools.checkstyle.api.FileContents) DetailAST(com.puppycrawl.tools.checkstyle.api.DetailAST) FileText(com.puppycrawl.tools.checkstyle.api.FileText) File(java.io.File) Test(org.junit.Test)

Aggregations

DetailAST (com.puppycrawl.tools.checkstyle.api.DetailAST)1 FileContents (com.puppycrawl.tools.checkstyle.api.FileContents)1 FileText (com.puppycrawl.tools.checkstyle.api.FileText)1 LocalizedMessages (com.puppycrawl.tools.checkstyle.api.LocalizedMessages)1 File (java.io.File)1 Test (org.junit.Test)1