langtools/test/com/sun/javadoc/testPackageDeprecation/TestPackageDeprecation.java
changeset 9606 e5a619cb5dd3
child 19253 b97b3e18547f
equal deleted inserted replaced
9605:c1f91868e24d 9606:e5a619cb5dd3
       
     1 /*
       
     2  * Copyright (c) 2011, 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      6492694
       
    27  * @summary  Test package deprecation.
       
    28  * @author   bpatel
       
    29  * @library  ../lib/
       
    30  * @build    JavadocTester TestPackageDeprecation
       
    31  * @run main TestPackageDeprecation
       
    32  */
       
    33 
       
    34 public class TestPackageDeprecation extends JavadocTester {
       
    35 
       
    36     //Test information.
       
    37     private static final String BUG_ID = "6492694";
       
    38 
       
    39     //Javadoc arguments.
       
    40     private static final String[] ARGS1 = new String[]{
       
    41         "-d", BUG_ID + "-1", "-source", "1.5", "-sourcepath", SRC_DIR, "-use", "pkg", "pkg1",
       
    42         SRC_DIR + FS + "C2.java", SRC_DIR + FS + "FooDepr.java"
       
    43     };
       
    44     private static final String[] ARGS2 = new String[]{
       
    45         "-d", BUG_ID + "-2", "-source", "1.5", "-sourcepath", SRC_DIR, "-use", "-nodeprecated",
       
    46         "pkg", "pkg1", SRC_DIR + FS + "C2.java", SRC_DIR + FS + "FooDepr.java"
       
    47     };
       
    48 
       
    49     //Input for string search tests.
       
    50     private static final String[][] TEST1 = {
       
    51         {BUG_ID + "-1" + FS + "pkg1" + FS + "package-summary.html",
       
    52             "<div class=\"deprecatedContent\"><span class=\"strong\">Deprecated.</span>" + NL +
       
    53             "<div class=\"block\"><i>This package is Deprecated.</i></div>"
       
    54         },
       
    55         {BUG_ID + "-1" + FS + "deprecated-list.html",
       
    56             "<li><a href=\"#package\">Deprecated Packages</a></li>"
       
    57         }
       
    58     };
       
    59     private static final String[][] TEST2 = NO_TEST;
       
    60     private static final String[][] NEGATED_TEST1 = NO_TEST;
       
    61     private static final String[][] NEGATED_TEST2 = {
       
    62         {BUG_ID + "-2" + FS + "overview-summary.html", "pkg1"},
       
    63         {BUG_ID + "-2" + FS + "allclasses-frame.html", "FooDepr"}
       
    64     };
       
    65 
       
    66     /**
       
    67      * The entry point of the test.
       
    68      * @param args the array of command line arguments.
       
    69      */
       
    70     public static void main(String[] args) {
       
    71         TestPackageDeprecation tester = new TestPackageDeprecation();
       
    72         run(tester, ARGS1, TEST1, NEGATED_TEST1);
       
    73         run(tester, ARGS2, TEST2, NEGATED_TEST2);
       
    74         if ((new java.io.File(BUG_ID + "-2" + FS + "pkg1" + FS +
       
    75                 "package-summary.html")).exists()) {
       
    76             throw new Error("Test Fails: packages summary should not be" +
       
    77                     "generated for deprecated package.");
       
    78         } else {
       
    79             System.out.println("Test passes:  package-summary.html not found.");
       
    80         }
       
    81         if ((new java.io.File(BUG_ID + "-2" + FS + "FooDepr.html")).exists()) {
       
    82             throw new Error("Test Fails: FooDepr should not be" +
       
    83                     "generated as it is deprecated.");
       
    84         } else {
       
    85             System.out.println("Test passes:  FooDepr.html not found.");
       
    86         }
       
    87         tester.printSummary();
       
    88     }
       
    89 
       
    90     /**
       
    91      * {@inheritDoc}
       
    92      */
       
    93     public String getBugId() {
       
    94         return BUG_ID;
       
    95     }
       
    96 
       
    97     /**
       
    98      * {@inheritDoc}
       
    99      */
       
   100     public String getBugName() {
       
   101         return getClass().getName();
       
   102     }
       
   103 }