Java Code Examples for com.sun.tools.doclint.DocLint

The following examples show how to use com.sun.tools.doclint.DocLint. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: TencentKona-8   Author: Tencent   File: RunTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
void testArgsNoFiles() throws BadArgs, IOException {
    System.err.println("test args, no files");
    DocLint dl = new DocLint();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, "-Xmsgs");
    pw.close();
    String out = sw.toString();

    String expect = "No files given";
    if (!Objects.equals(out.trim(), expect)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + expect + "<<");
        System.err.println("FOUND>>" + out + "<<");
    }

}
 
Example #2
Source Project: jdk8u60   Author: chenghanpeng   File: RunTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
void testArgsNoFiles() throws BadArgs, IOException {
    System.err.println("test args, no files");
    DocLint dl = new DocLint();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, "-Xmsgs");
    pw.close();
    String out = sw.toString();

    String expect = "No files given";
    if (!Objects.equals(out.trim(), expect)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + expect + "<<");
        System.err.println("FOUND>>" + out + "<<");
    }

}
 
Example #3
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
void testArgsNoFiles() throws BadArgs, IOException {
    System.err.println("test args, no files");
    DocLint dl = new DocLint();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, "-Xmsgs");
    pw.close();
    String out = sw.toString();

    String expect = "No files given";
    if (!Objects.equals(out.trim(), expect)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + expect + "<<");
        System.err.println("FOUND>>" + out + "<<");
    }

}
 
Example #4
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
void testArgsNoFiles() throws BadArgs, IOException {
    System.err.println("test args, no files");
    DocLint dl = new DocLint();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, "-Xmsgs");
    pw.close();
    String out = sw.toString();

    String expect = "No files given";
    if (!Objects.equals(out.trim(), expect)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + expect + "<<");
        System.err.println("FOUND>>" + out + "<<");
    }

}
 
Example #5
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
void testArgsNoFiles() throws BadArgs, IOException {
    System.err.println("test args, no files");
    DocLint dl = new DocLint();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, "-Xmsgs");
    pw.close();
    String out = sw.toString();

    String expect = "No files given";
    if (!Objects.equals(out.trim(), expect)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + expect + "<<");
        System.err.println("FOUND>>" + out + "<<");
    }

}
 
Example #6
Source Project: hottub   Author: dsrg-uoft   File: RunTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
void testArgsNoFiles() throws BadArgs, IOException {
    System.err.println("test args, no files");
    DocLint dl = new DocLint();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, "-Xmsgs");
    pw.close();
    String out = sw.toString();

    String expect = "No files given";
    if (!Objects.equals(out.trim(), expect)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + expect + "<<");
        System.err.println("FOUND>>" + out + "<<");
    }

}
 
Example #7
Source Project: openjdk-8-source   Author: keerath   File: RunTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
void testArgsNoFiles() throws BadArgs, IOException {
    System.err.println("test args, no files");
    DocLint dl = new DocLint();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, "-Xmsgs");
    pw.close();
    String out = sw.toString();

    String expect = "No files given";
    if (!Objects.equals(out.trim(), expect)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + expect + "<<");
        System.err.println("FOUND>>" + out + "<<");
    }

}
 
Example #8
Source Project: TencentKona-8   Author: Tencent   File: DocEnv.java    License: GNU General Public License v2.0 5 votes vote down vote up
void initDoclint(Collection<String> opts, Collection<String> customTagNames) {
    ArrayList<String> doclintOpts = new ArrayList<String>();

    for (String opt: opts) {
        doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt);
    }

    if (doclintOpts.isEmpty()) {
        doclintOpts.add(DocLint.XMSGS_OPTION);
    } else if (doclintOpts.size() == 1
            && doclintOpts.get(0).equals(DocLint.XMSGS_CUSTOM_PREFIX + "none")) {
        return;
    }

    String sep = "";
    StringBuilder customTags = new StringBuilder();
    for (String customTag : customTagNames) {
        customTags.append(sep);
        customTags.append(customTag);
        sep = DocLint.TAGS_SEPARATOR;
    }
    doclintOpts.add(DocLint.XCUSTOM_TAGS_PREFIX + customTags.toString());

    JavacTask t = BasicJavacTask.instance(context);
    doclint = new DocLint();
    // standard doclet normally generates H1, H2
    doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
    doclint.init(t, doclintOpts.toArray(new String[doclintOpts.size()]), false);
}
 
Example #9
Source Project: TencentKona-8   Author: Tencent   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testMain(boolean expectOK, String... args) {
    try {
        DocLint.main(args);
        if (!expectOK)
            error("expected SecurityException (from System.exit) not thrown");
    } catch (SecurityException e) {
        System.err.println(e);
        if (expectOK)
            error("unexpected SecurityException caught");
    }
}
 
Example #10
Source Project: TencentKona-8   Author: Tencent   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testRun() throws BadArgs, IOException {
    System.err.println("test run(String[])");
    DocLint dl = new DocLint();
    String[] args = { "-help" };
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    PrintStream prev = System.out;
    try {
        System.setOut(ps);
        dl.run(args);
    } finally {
        System.setOut(prev);
    }
    ps.close();
    String stdout = baos.toString();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, args);
    pw.close();
    String direct = sw.toString();

    if (!stdout.equals(direct)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + direct + "<<");
        System.err.println("FOUND>>" + stdout + "<<");
    }
}
 
Example #11
Source Project: TencentKona-8   Author: Tencent   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testInit() {
    System.err.println("test init");
    DocLint dl = new DocLint();
    String name = dl.getName();
    if (!Objects.equals(name, "doclint"))
        error("unexpected result for DocLint.getName()");

    List<? extends JavaFileObject> files =
            Arrays.asList(createFile("Test.java", "/** &0; */ class Test{ }"));
    String[] goodArgs = { "-Xmsgs" };
    testInit(true, goodArgs, files);

    String[] badArgs = { "-unknown" };
    testInit(false, badArgs, files);
}
 
Example #12
Source Project: TencentKona-8   Author: Tencent   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testInit(boolean expectOK, String[] args, List<? extends JavaFileObject> files) {
    JavacTool javac = JavacTool.create();
    JavacTask task = javac.getTask(null, null, null, null, null, files);
    try {
        DocLint dl = new DocLint();
        dl.init(task, args, true);
        if (!expectOK)
            error("expected IllegalArgumentException not thrown");
        task.call();
    } catch (IllegalArgumentException e) {
        System.err.println(e);
        if (expectOK)
            error("unexpected IllegalArgumentException caught");
    }
}
 
Example #13
Source Project: TencentKona-8   Author: Tencent   File: PathsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
String doclint(String... args) throws BadArgs, IOException {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    DocLint dl = new DocLint();
    dl.run(pw, args);
    pw.close();
    String out = sw.toString();
    if (!out.isEmpty())
        System.err.println(out);
    return out;
}
 
Example #14
Source Project: TencentKona-8   Author: Tencent   File: DocLintTester.java    License: GNU General Public License v2.0 5 votes vote down vote up
void check(List<String> opts, List<File> files, boolean expectBadArgs, File refFile) throws Exception {
    List<String> args = new ArrayList<String>();
    args.addAll(opts);
    for (File file: files)
        args.add(file.getPath());

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    try {
        new DocLint().run(pw, args.toArray(new String[args.size()]));
        if (expectBadArgs)
            error("expected exception not thrown");
    } catch (BadArgs e) {
        if (!expectBadArgs)
            error("unexpected exception caught: " + e);
    }
    pw.flush();
    String out = normalizeNewlines(removeFileNames(sw.toString())).trim();
    if (out != null)
        System.err.println("Output:\n" + out);

    if (refFile == null) {
        if (!out.isEmpty())
            error("unexpected output");
    } else {
        String expect = readFile(refFile);
        if (!expect.equals(out)) {
            error("expected output not found");
            System.err.println("EXPECT>>" + expect + "<<");
            System.err.println(" FOUND>>" + out    + "<<");
        }
    }
}
 
Example #15
Source Project: jdk8u60   Author: chenghanpeng   File: DocEnv.java    License: GNU General Public License v2.0 5 votes vote down vote up
void initDoclint(Collection<String> opts, Collection<String> customTagNames) {
    ArrayList<String> doclintOpts = new ArrayList<String>();

    for (String opt: opts) {
        doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt);
    }

    if (doclintOpts.isEmpty()) {
        doclintOpts.add(DocLint.XMSGS_OPTION);
    } else if (doclintOpts.size() == 1
            && doclintOpts.get(0).equals(DocLint.XMSGS_CUSTOM_PREFIX + "none")) {
        return;
    }

    String sep = "";
    StringBuilder customTags = new StringBuilder();
    for (String customTag : customTagNames) {
        customTags.append(sep);
        customTags.append(customTag);
        sep = DocLint.TAGS_SEPARATOR;
    }
    doclintOpts.add(DocLint.XCUSTOM_TAGS_PREFIX + customTags.toString());

    JavacTask t = BasicJavacTask.instance(context);
    doclint = new DocLint();
    // standard doclet normally generates H1, H2
    doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
    doclint.init(t, doclintOpts.toArray(new String[doclintOpts.size()]), false);
}
 
Example #16
Source Project: jdk8u60   Author: chenghanpeng   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testMain(boolean expectOK, String... args) {
    try {
        DocLint.main(args);
        if (!expectOK)
            error("expected SecurityException (from System.exit) not thrown");
    } catch (SecurityException e) {
        System.err.println(e);
        if (expectOK)
            error("unexpected SecurityException caught");
    }
}
 
Example #17
Source Project: jdk8u60   Author: chenghanpeng   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testRun() throws BadArgs, IOException {
    System.err.println("test run(String[])");
    DocLint dl = new DocLint();
    String[] args = { "-help" };
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    PrintStream prev = System.out;
    try {
        System.setOut(ps);
        dl.run(args);
    } finally {
        System.setOut(prev);
    }
    ps.close();
    String stdout = baos.toString();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, args);
    pw.close();
    String direct = sw.toString();

    if (!stdout.equals(direct)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + direct + "<<");
        System.err.println("FOUND>>" + stdout + "<<");
    }
}
 
Example #18
Source Project: jdk8u60   Author: chenghanpeng   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testInit() {
    System.err.println("test init");
    DocLint dl = new DocLint();
    String name = dl.getName();
    if (!Objects.equals(name, "doclint"))
        error("unexpected result for DocLint.getName()");

    List<? extends JavaFileObject> files =
            Arrays.asList(createFile("Test.java", "/** &0; */ class Test{ }"));
    String[] goodArgs = { "-Xmsgs" };
    testInit(true, goodArgs, files);

    String[] badArgs = { "-unknown" };
    testInit(false, badArgs, files);
}
 
Example #19
Source Project: jdk8u60   Author: chenghanpeng   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testInit(boolean expectOK, String[] args, List<? extends JavaFileObject> files) {
    JavacTool javac = JavacTool.create();
    JavacTask task = javac.getTask(null, null, null, null, null, files);
    try {
        DocLint dl = new DocLint();
        dl.init(task, args, true);
        if (!expectOK)
            error("expected IllegalArgumentException not thrown");
        task.call();
    } catch (IllegalArgumentException e) {
        System.err.println(e);
        if (expectOK)
            error("unexpected IllegalArgumentException caught");
    }
}
 
Example #20
Source Project: jdk8u60   Author: chenghanpeng   File: PathsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
String doclint(String... args) throws BadArgs, IOException {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    DocLint dl = new DocLint();
    dl.run(pw, args);
    pw.close();
    String out = sw.toString();
    if (!out.isEmpty())
        System.err.println(out);
    return out;
}
 
Example #21
Source Project: jdk8u60   Author: chenghanpeng   File: DocLintTester.java    License: GNU General Public License v2.0 5 votes vote down vote up
void check(List<String> opts, List<File> files, boolean expectBadArgs, File refFile) throws Exception {
    List<String> args = new ArrayList<String>();
    args.addAll(opts);
    for (File file: files)
        args.add(file.getPath());

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    try {
        new DocLint().run(pw, args.toArray(new String[args.size()]));
        if (expectBadArgs)
            error("expected exception not thrown");
    } catch (BadArgs e) {
        if (!expectBadArgs)
            error("unexpected exception caught: " + e);
    }
    pw.flush();
    String out = normalizeNewlines(removeFileNames(sw.toString())).trim();
    if (out != null)
        System.err.println("Output:\n" + out);

    if (refFile == null) {
        if (!out.isEmpty())
            error("unexpected output");
    } else {
        String expect = readFile(refFile);
        if (!expect.equals(out)) {
            error("expected output not found");
            System.err.println("EXPECT>>" + expect + "<<");
            System.err.println(" FOUND>>" + out    + "<<");
        }
    }
}
 
Example #22
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: DocEnv.java    License: GNU General Public License v2.0 5 votes vote down vote up
void initDoclint(Collection<String> opts, Collection<String> customTagNames) {
    ArrayList<String> doclintOpts = new ArrayList<String>();

    for (String opt: opts) {
        doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt);
    }

    if (doclintOpts.isEmpty()) {
        doclintOpts.add(DocLint.XMSGS_OPTION);
    } else if (doclintOpts.size() == 1
            && doclintOpts.get(0).equals(DocLint.XMSGS_CUSTOM_PREFIX + "none")) {
        return;
    }

    String sep = "";
    StringBuilder customTags = new StringBuilder();
    for (String customTag : customTagNames) {
        customTags.append(sep);
        customTags.append(customTag);
        sep = DocLint.TAGS_SEPARATOR;
    }
    doclintOpts.add(DocLint.XCUSTOM_TAGS_PREFIX + customTags.toString());

    JavacTask t = BasicJavacTask.instance(context);
    doclint = new DocLint();
    // standard doclet normally generates H1, H2
    doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
    doclint.init(t, doclintOpts.toArray(new String[doclintOpts.size()]), false);
}
 
Example #23
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testMain(boolean expectOK, String... args) {
    try {
        DocLint.main(args);
        if (!expectOK)
            error("expected SecurityException (from System.exit) not thrown");
    } catch (SecurityException e) {
        System.err.println(e);
        if (expectOK)
            error("unexpected SecurityException caught");
    }
}
 
Example #24
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testRun() throws BadArgs, IOException {
    System.err.println("test run(String[])");
    DocLint dl = new DocLint();
    String[] args = { "-help" };
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    PrintStream prev = System.out;
    try {
        System.setOut(ps);
        dl.run(args);
    } finally {
        System.setOut(prev);
    }
    ps.close();
    String stdout = baos.toString();

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    dl.run(pw, args);
    pw.close();
    String direct = sw.toString();

    if (!stdout.equals(direct)) {
        error("unexpected output");
        System.err.println("EXPECT>>" + direct + "<<");
        System.err.println("FOUND>>" + stdout + "<<");
    }
}
 
Example #25
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testInit() {
    System.err.println("test init");
    DocLint dl = new DocLint();
    String name = dl.getName();
    if (!Objects.equals(name, "doclint"))
        error("unexpected result for DocLint.getName()");

    List<? extends JavaFileObject> files =
            Arrays.asList(createFile("Test.java", "/** &0; */ class Test{ }"));
    String[] goodArgs = { "-Xmsgs" };
    testInit(true, goodArgs, files);

    String[] badArgs = { "-unknown" };
    testInit(false, badArgs, files);
}
 
Example #26
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testInit(boolean expectOK, String[] args, List<? extends JavaFileObject> files) {
    JavacTool javac = JavacTool.create();
    JavacTask task = javac.getTask(null, null, null, null, null, files);
    try {
        DocLint dl = new DocLint();
        dl.init(task, args, true);
        if (!expectOK)
            error("expected IllegalArgumentException not thrown");
        task.call();
    } catch (IllegalArgumentException e) {
        System.err.println(e);
        if (expectOK)
            error("unexpected IllegalArgumentException caught");
    }
}
 
Example #27
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: PathsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
String doclint(String... args) throws BadArgs, IOException {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    DocLint dl = new DocLint();
    dl.run(pw, args);
    pw.close();
    String out = sw.toString();
    if (!out.isEmpty())
        System.err.println(out);
    return out;
}
 
Example #28
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: DocLintTester.java    License: GNU General Public License v2.0 5 votes vote down vote up
void check(List<String> opts, List<File> files, boolean expectBadArgs, File refFile) throws Exception {
    List<String> args = new ArrayList<String>();
    args.addAll(opts);
    for (File file: files)
        args.add(file.getPath());

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    try {
        new DocLint().run(pw, args.toArray(new String[args.size()]));
        if (expectBadArgs)
            error("expected exception not thrown");
    } catch (BadArgs e) {
        if (!expectBadArgs)
            error("unexpected exception caught: " + e);
    }
    pw.flush();
    String out = normalizeNewlines(removeFileNames(sw.toString())).trim();
    if (out != null)
        System.err.println("Output:\n" + out);

    if (refFile == null) {
        if (!out.isEmpty())
            error("unexpected output");
    } else {
        String expect = readFile(refFile);
        if (!expect.equals(out)) {
            error("expected output not found");
            System.err.println("EXPECT>>" + expect + "<<");
            System.err.println(" FOUND>>" + out    + "<<");
        }
    }
}
 
Example #29
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: DocEnv.java    License: GNU General Public License v2.0 5 votes vote down vote up
void initDoclint(Collection<String> opts, Collection<String> customTagNames) {
    ArrayList<String> doclintOpts = new ArrayList<String>();

    for (String opt: opts) {
        doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt);
    }

    if (doclintOpts.isEmpty()) {
        doclintOpts.add(DocLint.XMSGS_OPTION);
    } else if (doclintOpts.size() == 1
            && doclintOpts.get(0).equals(DocLint.XMSGS_CUSTOM_PREFIX + "none")) {
        return;
    }

    String sep = "";
    StringBuilder customTags = new StringBuilder();
    for (String customTag : customTagNames) {
        customTags.append(sep);
        customTags.append(customTag);
        sep = DocLint.TAGS_SEPARATOR;
    }
    doclintOpts.add(DocLint.XCUSTOM_TAGS_PREFIX + customTags.toString());

    JavacTask t = BasicJavacTask.instance(context);
    doclint = new DocLint();
    // standard doclet normally generates H1, H2
    doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
    doclint.init(t, doclintOpts.toArray(new String[doclintOpts.size()]), false);
}
 
Example #30
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
void testMain(boolean expectOK, String... args) {
    try {
        DocLint.main(args);
        if (!expectOK)
            error("expected SecurityException (from System.exit) not thrown");
    } catch (SecurityException e) {
        System.err.println(e);
        if (expectOK)
            error("unexpected SecurityException caught");
    }
}