langtools/test/jdk/javadoc/tool/VerifyLocale.java
author ksrini
Mon, 14 Mar 2016 15:04:57 -0700
changeset 36705 890c250d8da8
parent 35426 374342e56a56
child 36709 f9f252088afa
permissions -rw-r--r--
8071982: Update tests for revamped Doclet API 8071984: Update test cases for repeating and type annotations output in javadoc Reviewed-by: ksrini, bpatel Contributed-by: oleg.barbashov@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     1
/*
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     2
 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     4
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     8
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    13
 * accompanied this code).
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    14
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    18
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    21
 * questions.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    22
 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    23
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    24
/*
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    25
 * @test
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    26
 * @bug 8035473
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    27
 * @summary Verify that init method works correctly.
36705
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    28
 * @ignore 8149565
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    29
 * @modules jdk.javadoc
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    30
 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    31
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    32
import java.util.Collections;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    33
import java.util.Locale;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    34
import java.util.Set;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    35
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    36
import javax.lang.model.SourceVersion;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    37
import javax.tools.Diagnostic.Kind;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    38
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    39
import jdk.javadoc.doclet.Doclet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    40
import jdk.javadoc.doclet.Reporter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    41
import jdk.javadoc.doclet.DocletEnvironment;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    42
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    43
public class VerifyLocale implements Doclet {
36705
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    44
    static String language;
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    45
    static String country;
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    46
    static String variant;
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    47
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    48
    Locale locale;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    49
    Reporter reporter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    50
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    51
    public static void main(String[] args) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    52
        String thisFile = "" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    53
            new java.io.File(System.getProperty("test.src", "."),
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    54
                             "VerifyLocale.java");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    55
36705
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    56
        for (Locale loc : Locale.getAvailableLocales()) {
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    57
            language = loc.getLanguage();
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    58
            country = loc.getCountry();
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    59
            variant = loc.getVariant();
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    60
            if (!language.equals("")) {
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    61
                String[] command_line = {
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    62
                    // jumble the options in some weird order
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    63
                    "-doclet", "VerifyLocale",
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    64
                    "-locale", language + (country.equals("") ? "" : ("_" + country + (variant.equals("") ? "" : "_" + variant))),
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    65
                    "-docletpath", System.getProperty("test.classes", "."),
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    66
                    thisFile
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    67
                };
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    68
                if (jdk.javadoc.internal.tool.Main.execute(command_line) != 0)
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    69
                    throw new Error("Javadoc encountered warnings or errors.");
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    70
            }
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    71
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    72
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    73
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    74
    public boolean run(DocletEnvironment root) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    75
        reporter.print(Kind.NOTE, "just a test: Locale is: " + locale.getDisplayName());
36705
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    76
        return language.equals(locale.getLanguage())
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    77
               && country.equals(locale.getCountry())
890c250d8da8 8071982: Update tests for revamped Doclet API
ksrini
parents: 35426
diff changeset
    78
               && variant.equals(locale.getVariant());
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    79
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    80
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    81
    @Override
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    82
    public String getName() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    83
        return "Test";
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    84
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    85
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    86
    @Override
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    87
    public Set<Option> getSupportedOptions() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    88
        return Collections.emptySet();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    89
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    90
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    91
    @Override
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    92
    public SourceVersion getSupportedSourceVersion() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    93
        return SourceVersion.latest();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    94
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    95
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    96
    public void init(Locale locale, Reporter reporter) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    97
        this.locale = locale;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    98
        this.reporter = reporter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    99
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   100
}