test/langtools/jdk/javadoc/tool/EnsureNewOldDoclet.java
author bobv
Tue, 07 Nov 2017 10:30:53 -0500
changeset 47801 c7b50c23ea71
parent 47216 71c04702a3d5
child 53885 e03bbe023e50
permissions -rw-r--r--
8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases Reviewed-by: tschatzl, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     1
/*
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 39179
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
35426
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
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 44388
diff changeset
    26
 * @bug 8035473 8154482 8154399 8159096 8176131 8176331 8177511
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 44388
diff changeset
    27
 * @summary make sure the javadoc tool responds correctly,
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 44388
diff changeset
    28
 *          to old and new doclet implementations.
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    29
 * @library /tools/lib
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    30
 * @build toolbox.ToolBox toolbox.TestRunner
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    31
 * @run main EnsureNewOldDoclet
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    32
 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    33
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    34
import java.io.*;
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    35
import java.nio.file.Path;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    36
import java.util.Arrays;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    37
import java.util.Collections;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    38
import java.util.List;
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    39
import java.util.Map;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    40
import java.util.Set;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    41
import java.util.regex.Pattern;
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    42
import java.util.stream.Collectors;
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    43
import javax.lang.model.element.Element;
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    44
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    45
import com.sun.javadoc.Tag;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    46
import com.sun.source.doctree.DocTree;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    47
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    48
import toolbox.*;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    49
35426
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
/**
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    52
 * This test ensures the doclet responds correctly when given
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    53
 * various conditions that force a fall back to the old javadoc
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 44388
diff changeset
    54
 * tool.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    55
 */
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    56
public class EnsureNewOldDoclet extends TestRunner {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    57
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    58
    final ToolBox tb;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    59
    final File testSrc;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    60
    final Path javadocPath;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    61
    final ExecTask task;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    62
    final String testClasses;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    63
    final PrintStream ostream;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    64
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    65
    final static String CLASS_NAME = "EnsureNewOldDoclet";
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    66
    final static String OLD_DOCLET_CLASS_NAME = CLASS_NAME + "$OldDoclet";
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    67
    final static String NEW_DOCLET_CLASS_NAME = CLASS_NAME + "$NewDoclet"; //unused
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    68
    final static String NEW_TAGLET_CLASS_NAME = CLASS_NAME + "$NewTaglet";
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    69
45742
36bf0f2436ad 8177511: Remove the old standard doclet
ksrini
parents: 44388
diff changeset
    70
    final static Pattern OLD_HEADER = Pattern.compile(".*This is not the Standard Doclet.*");
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    71
    final static Pattern NEW_HEADER = Pattern.compile("^Standard Doclet version.*");
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    72
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    73
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    74
    final static String OLD_DOCLET_MARKER = "OLD_DOCLET_MARKER";
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    75
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    76
    final static String NEW_DOCLET_MARKER = "NEW_DOCLET_MARKER";
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    77
    final static String NEW_TAGLET_MARKER = "Registered Taglet " + CLASS_NAME + "\\$NewTaglet";
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    78
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    79
    final static Pattern WARN_TEXT = Pattern.compile("Users are strongly recommended to migrate" +
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    80
                                                    " to the new APIs.");
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    81
44189
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 44180
diff changeset
    82
    final static String NEW_STDDOCLET = "jdk.javadoc.doclet.StandardDoclet";
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    83
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    84
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    85
    public EnsureNewOldDoclet() throws Exception {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    86
        super(System.err);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    87
        ostream = System.err;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    88
        testClasses = System.getProperty("test.classes");
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    89
        tb = new ToolBox();
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    90
        javadocPath = tb.getJDKTool("javadoc");
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    91
        task = new ExecTask(tb, javadocPath);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    92
        testSrc = new File("Foo.java");
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    93
        generateSample(testSrc);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    94
    }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    95
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    96
    void generateSample(File testSrc) throws Exception {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    97
        String nl = System.getProperty("line.separator");
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    98
        String src = Arrays.asList(
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
    99
            "/**",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   100
            " * A test class to test javadoc. Nothing more nothing less.",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   101
            " */",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   102
            " public class Foo{}").stream().collect(Collectors.joining(nl));
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   103
        tb.writeFile(testSrc.getPath(), src);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   104
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   105
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   106
    public static void main(String... args) throws Exception {
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   107
        new EnsureNewOldDoclet().runTests();
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   108
    }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   109
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   110
    // input: nothing, default mode
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   111
    // outcome: new tool and new doclet
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   112
    @Test
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   113
    public void testDefault() throws Exception {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   114
        setArgs("-classpath", ".", // insulates us from ambient classpath
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   115
                  testSrc.toString());
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   116
        Task.Result tr = task.run(Task.Expect.SUCCESS);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   117
        List<String> out = tr.getOutputLines(Task.OutputKind.STDOUT);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   118
        checkOutput(testName, out, NEW_HEADER);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   119
    }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   120
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   121
    // input: old doclet
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   122
    // outcome: old tool
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   123
    @Test
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   124
    public void testOldDoclet() throws Exception {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   125
        setArgs("-classpath", ".", // ambient classpath insulation
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   126
                "-doclet",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   127
                OLD_DOCLET_CLASS_NAME,
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   128
                "-docletpath",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   129
                testClasses,
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   130
                testSrc.toString());
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   131
        Task.Result tr = task.run(Task.Expect.SUCCESS);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   132
        List<String> out = tr.getOutputLines(Task.OutputKind.STDOUT);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   133
        List<String> err = tr.getOutputLines(Task.OutputKind.STDERR);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   134
        checkOutput(testName, out, OLD_DOCLET_MARKER);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   135
        checkOutput(testName, err, WARN_TEXT);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   136
    }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   137
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   138
    // input: new doclet and new taglet
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   139
    // outcome: new doclet and new taglet should register
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   140
    @Test
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   141
    public void testNewDocletNewTaglet() throws Exception {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   142
        setArgs("-classpath", ".", // ambient classpath insulation
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   143
                "-doclet",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   144
                NEW_STDDOCLET,
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   145
                "-taglet",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   146
                NEW_TAGLET_CLASS_NAME,
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   147
                "-tagletpath",
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   148
                testClasses,
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   149
                testSrc.toString());
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   150
        Task.Result tr = task.run(Task.Expect.SUCCESS);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   151
        List<String> out = tr.getOutputLines(Task.OutputKind.STDOUT);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   152
        List<String> err = tr.getOutputLines(Task.OutputKind.STDERR);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   153
        checkOutput(testName, out, NEW_HEADER);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   154
        checkOutput(testName, out, NEW_TAGLET_MARKER);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   155
    }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   156
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   157
    void setArgs(String... args) {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   158
        ostream.println("cmds: " + Arrays.asList(args));
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   159
        task.args(args);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   160
    }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   161
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   162
    void checkOutput(String testCase, List<String> content, String toFind) throws Exception {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   163
        checkOutput(testCase, content, Pattern.compile(".*" + toFind + ".*"));
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   164
    }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   165
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   166
    void checkOutput(String testCase, List<String> content, Pattern toFind) throws Exception {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   167
        ostream.println("---" + testCase + "---");
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   168
        content.stream().forEach(x -> System.out.println(x));
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   169
        for (String x : content) {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   170
            ostream.println(x);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   171
            if (toFind.matcher(x).matches()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   172
                return;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   173
            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   174
        }
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   175
        throw new Exception(testCase + ": Expected string not found: " +  toFind);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   176
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   177
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   178
    public static class OldDoclet extends com.sun.javadoc.Doclet {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   179
        public static boolean start(com.sun.javadoc.RootDoc root) {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   180
            System.out.println(OLD_DOCLET_MARKER);
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   181
            return true;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   182
        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   183
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   184
44189
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 44180
diff changeset
   185
    public static class NewTaglet implements jdk.javadoc.doclet.Taglet {
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   186
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   187
        @Override
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   188
        public Set<Location> getAllowedLocations() {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   189
            return Collections.emptySet();
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   190
        }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   191
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   192
        @Override
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   193
        public boolean isInlineTag() {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   194
            return true;
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   195
        }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   196
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   197
        @Override
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   198
        public String getName() {
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   199
            return "NewTaglet";
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   200
        }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   201
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   202
        @Override
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   203
        public String toString(List<? extends DocTree> tags, Element element) {
37750
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   204
            return tags.toString();
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   205
        }
d213951c811b 8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents: 36526
diff changeset
   206
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   207
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
   208
}