Search in sources :

Example 1 with JavadocTool

use of com.sun.tools.javadoc.JavadocTool in project checkstyle by checkstyle.

the class TokenTypesDocletTest method testNotConstants.

@Test
public void testNotConstants() throws Exception {
    // Token types must be public int constants, which means that they must have
    // modifiers public, static, final and type int, because they are referenced statically in
    // a lot of different places, must not be changed and an int value is used to encrypt
    // a token type.
    final ListBuffer<String[]> options = new ListBuffer<>();
    options.add(new String[] { "-doclet", "TokenTypesDoclet" });
    options.add(new String[] { "-destfile", "target/tokentypes.properties" });
    final ListBuffer<String> names = new ListBuffer<>();
    names.add(getPath("InputTokenTypesDocletNotConstants.java"));
    final Context context = new Context();
    new TestMessager(context);
    final JavadocTool javadocTool = JavadocTool.make0(context);
    final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
    assertTrue(TokenTypesDoclet.start(rootDoc));
}
Also used : Context(com.sun.tools.javac.util.Context) ListBuffer(com.sun.tools.javac.util.ListBuffer) RootDoc(com.sun.javadoc.RootDoc) JavadocTool(com.sun.tools.javadoc.JavadocTool) Test(org.junit.Test)

Example 2 with JavadocTool

use of com.sun.tools.javadoc.JavadocTool in project checkstyle by checkstyle.

the class TokenTypesDocletTest method testCorrect.

@Test
public void testCorrect() throws Exception {
    final ListBuffer<String[]> options = new ListBuffer<>();
    options.add(new String[] { "-destfile", "target/tokentypes.properties" });
    final ListBuffer<String> names = new ListBuffer<>();
    names.add(getPath("InputTokenTypesDocletCorrect.java"));
    final Context context = new Context();
    new TestMessager(context);
    final JavadocTool javadocTool = JavadocTool.make0(context);
    final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
    assertTrue(TokenTypesDoclet.start(rootDoc));
}
Also used : Context(com.sun.tools.javac.util.Context) ListBuffer(com.sun.tools.javac.util.ListBuffer) RootDoc(com.sun.javadoc.RootDoc) JavadocTool(com.sun.tools.javadoc.JavadocTool) Test(org.junit.Test)

Example 3 with JavadocTool

use of com.sun.tools.javadoc.JavadocTool in project checkstyle by checkstyle.

the class TokenTypesDocletTest method testEmptyJavadoc.

@Test
public void testEmptyJavadoc() throws Exception {
    final ListBuffer<String[]> options = new ListBuffer<>();
    options.add(new String[] { "-destfile", "target/tokentypes.properties" });
    final ListBuffer<String> names = new ListBuffer<>();
    names.add(getPath("InputTokenTypesDocletEmptyJavadoc.java"));
    final Context context = new Context();
    new TestMessager(context);
    final JavadocTool javadocTool = JavadocTool.make0(context);
    final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
    try {
        TokenTypesDoclet.start(rootDoc);
        fail("IllegalArgumentException is expected");
    } catch (IllegalArgumentException expected) {
    // Token types must have first sentence of Javadoc summary
    // so that a brief description could be provided. Otherwise,
    // an IllegalArgumentException is thrown.
    }
}
Also used : Context(com.sun.tools.javac.util.Context) ListBuffer(com.sun.tools.javac.util.ListBuffer) RootDoc(com.sun.javadoc.RootDoc) JavadocTool(com.sun.tools.javadoc.JavadocTool) Test(org.junit.Test)

Aggregations

RootDoc (com.sun.javadoc.RootDoc)3 Context (com.sun.tools.javac.util.Context)3 ListBuffer (com.sun.tools.javac.util.ListBuffer)3 JavadocTool (com.sun.tools.javadoc.JavadocTool)3 Test (org.junit.Test)3