langtools/test/tools/doclint/OptionTest.java
author katleman
Tue, 21 Jan 2014 18:17:23 -0800
changeset 22365 895bfde469d4
parent 14962 19ffdfafbcd2
child 30730 d3ce7619db2c
permissions -rw-r--r--
Added tag jdk9-b01 for changeset ae2d94255f32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14952
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     1
/*
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     4
 *
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     8
 *
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    13
 * accompanied this code).
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    14
 *
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    18
 *
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    21
 * questions.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    22
 */
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    23
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    24
/*
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    25
 * @test
14962
19ffdfafbcd2 8005307: fix missing @bug tags
jjg
parents: 14952
diff changeset
    26
 * @bug 8004832
19ffdfafbcd2 8005307: fix missing @bug tags
jjg
parents: 14952
diff changeset
    27
 * @summary Add new doclint package
14952
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    28
 */
14962
19ffdfafbcd2 8005307: fix missing @bug tags
jjg
parents: 14952
diff changeset
    29
19ffdfafbcd2 8005307: fix missing @bug tags
jjg
parents: 14952
diff changeset
    30
import com.sun.tools.doclint.DocLint;
19ffdfafbcd2 8005307: fix missing @bug tags
jjg
parents: 14952
diff changeset
    31
14952
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    32
public class OptionTest {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    33
    public static void main(String... args) throws Exception {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    34
        new OptionTest().run();
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    35
    }
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    36
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    37
    String[] positiveTests = {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    38
        "-Xmsgs",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    39
        "-Xmsgs:all",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    40
        "-Xmsgs:none",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    41
        "-Xmsgs:accessibility",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    42
        "-Xmsgs:html",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    43
        "-Xmsgs:missing",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    44
        "-Xmsgs:reference",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    45
        "-Xmsgs:syntax",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    46
        "-Xmsgs:html/public",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    47
        "-Xmsgs:html/protected",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    48
        "-Xmsgs:html/package",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    49
        "-Xmsgs:html/private",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    50
        "-Xmsgs:-html/public",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    51
        "-Xmsgs:-html/protected",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    52
        "-Xmsgs:-html/package",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    53
        "-Xmsgs:-html/private",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    54
        "-Xmsgs:html,syntax",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    55
        "-Xmsgs:html,-syntax",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    56
        "-Xmsgs:-html,syntax",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    57
        "-Xmsgs:-html,-syntax",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    58
        "-Xmsgs:html/public,syntax",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    59
        "-Xmsgs:html,syntax/public",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    60
        "-Xmsgs:-html/public,syntax/public"
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    61
    };
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    62
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    63
    String[] negativeTests = {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    64
        "-typo",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    65
        "-Xmsgs:-all",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    66
        "-Xmsgs:-none",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    67
        "-Xmsgs:typo",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    68
        "-Xmsgs:html/typo",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    69
        "-Xmsgs:html/public,typo",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    70
        "-Xmsgs:html/public,syntax/typo",
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    71
    };
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    72
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    73
    void run() throws Exception {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    74
        test(positiveTests, true);
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    75
        test(negativeTests, false);
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    76
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    77
        if (errors > 0)
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    78
            throw new Exception(errors + " errors occurred");
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    79
    }
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    80
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    81
    void test(String[] tests, boolean expect) {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    82
        for (String test: tests) {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    83
            System.err.println("test: " + test);
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    84
            boolean found = DocLint.isValidOption(test);
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    85
            if (found != expect)
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    86
                error("Unexpected result: " + found + ",expected: " + expect);
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    87
        }
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    88
    }
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    89
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    90
    void error(String msg) {
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    91
        System.err.println("Error: " + msg);
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    92
        errors++;
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    93
    }
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    94
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    95
    int errors;
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    96
}