TestCustomTag.java revision 2416:94aca852a4d0
1/*
2 * Copyright (c) 2013, 2014, 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 */
23
24/*
25 * @test
26 * @bug      8006248
27 * @summary  Test custom tag. Verify that an unknown tag generates appropriate warnings.
28 * @author   Bhavesh Patel
29 * @library  ../lib
30 * @build    JavadocTester taglets.CustomTag
31 * @run main TestCustomTag
32 */
33
34public class TestCustomTag extends JavadocTester {
35
36    public static void main(String... args) throws Exception {
37        TestCustomTag tester = new TestCustomTag();
38        tester.runTests();
39    }
40
41    @Test
42    void test1() {
43        javadoc("-Xdoclint:none",
44                "-d", "out-1",
45                "-tagletpath", testSrc, // TODO: probably useless
46                "-taglet", "taglets.CustomTag",
47                "-sourcepath",  testSrc,
48                testSrc("TagTestClass.java"));
49        checkExit(Exit.OK);
50
51        checkOutput(Output.WARNING, true,
52                "warning - @unknownTag is an unknown tag.");
53    }
54
55    @Test
56    void test2() {
57        javadoc("-d", "out-2",
58                "-tagletpath", testSrc,  // TODO: probably useless
59                "-taglet", "taglets.CustomTag",
60                "-sourcepath", testSrc,
61                testSrc("TagTestClass.java"));
62        checkExit(Exit.FAILED);
63
64        checkOutput(Output.ERROR, true,
65                "error: unknown tag: unknownTag");
66    }
67
68    @Test
69    void test3() {
70        javadoc("-Xdoclint:none",
71                "-d", "out-3",
72                "-sourcepath", testSrc,
73                testSrc("TagTestClass.java"));
74        checkExit(Exit.OK);
75
76        checkOutput(Output.WARNING,  true,
77            "warning - @customTag is an unknown tag.",
78            "warning - @unknownTag is an unknown tag.");
79    }
80
81    @Test
82    void test4() {
83        javadoc("-d", "out-4",
84                "-sourcepath",  testSrc,
85                testSrc("TagTestClass.java"));
86        checkExit(Exit.FAILED);
87
88        checkOutput(Output.ERROR, true,
89            "error: unknown tag: customTag",
90            "error: unknown tag: unknownTag");
91    }
92}
93