test/langtools/tools/javadoc/InlineTagsWithBraces.java
branchniosocketimpl-branch
changeset 57208 7a45c67e73d0
parent 57207 30695f27d7ea
parent 53902 7a6fd71449e7
child 57210 a67ea4f53e56
equal deleted inserted replaced
57207:30695f27d7ea 57208:7a45c67e73d0
     1 /*
       
     2  * Copyright (c) 2003, 2015, 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 4965490
       
    27  * @summary Verify that matching braces can appear within inline tags.
       
    28  * @modules jdk.javadoc
       
    29  */
       
    30 
       
    31 import com.sun.javadoc.*;
       
    32 
       
    33 /**
       
    34  * This is a {@code test} comment.
       
    35  * It is {@bold {@underline only} a test}.
       
    36  * We would like some code
       
    37  * {@code for (int i : nums) { doit(i); } return; }
       
    38  * to be embedded {@maybe {even {a couple {of levels}}} deep}.
       
    39  */
       
    40 public class InlineTagsWithBraces extends Doclet {
       
    41 
       
    42     private static String[] expectedTags = {
       
    43         "Text", "@code", "Text",
       
    44         "@bold", "Text", "@code", "Text",
       
    45         "@maybe", "Text"
       
    46     };
       
    47     private static String[] expectedText = {
       
    48         "This is a ", "test", " comment.\n" +
       
    49         " It is ", "{@underline only} a test", ".\n" +
       
    50         " We would like some code\n" +
       
    51         " ", "for (int i : nums) { doit(i); } return; ", "\n" +
       
    52         " to be embedded ", "{even {a couple {of levels}}} deep", "."
       
    53     };
       
    54 
       
    55 
       
    56     public static void main(String[] args) {
       
    57         String thisFile = "" +
       
    58             new java.io.File(System.getProperty("test.src", "."),
       
    59                              "InlineTagsWithBraces.java");
       
    60 
       
    61         if (com.sun.tools.javadoc.Main.execute(
       
    62                 "javadoc",
       
    63                 "InlineTagsWithBraces",
       
    64                 InlineTagsWithBraces.class.getClassLoader(),
       
    65                 new String[] {"-Xwerror", thisFile}) != 0)
       
    66             throw new Error("Javadoc encountered warnings or errors.");
       
    67     }
       
    68 
       
    69     public static boolean start(RootDoc root) {
       
    70         ClassDoc cd = root.classes()[0];
       
    71         Tag[] tags = cd.inlineTags();
       
    72 
       
    73         for (int i = 0; i < tags.length; i++) {
       
    74             if (!tags[i].name().equals(expectedTags[i]) ||
       
    75                         !tags[i].text().equals(expectedText[i])) {
       
    76                 throw new Error("Tag \"" + tags[i] + "\" not as expected");
       
    77             }
       
    78         }
       
    79 
       
    80         return true;
       
    81     }
       
    82 }