test/tools/doclint/OptionTest.java

Wed, 13 Aug 2014 14:50:00 -0700

author
katleman
date
Wed, 13 Aug 2014 14:50:00 -0700
changeset 2549
0b6cc4ea670f
parent 1465
a22f23fb7abf
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8u40-b01 for changeset bf89a471779d

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

mercurial