1 /*
   2  * Copyright (c) 2012, 2013, 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      8004893 8022738
  27  * @summary  Make sure that the lambda feature changes work fine in
  28  *           javadoc.
  29  * @author   bpatel
  30  * @library  ../lib/
  31  * @build    JavadocTester TestLambdaFeature
  32  * @run main TestLambdaFeature
  33  */
  34 
  35 public class TestLambdaFeature extends JavadocTester {
  36 
  37     //Test information.
  38     private static final String BUG_ID = "8004893-8022738";
  39 
  40     //Javadoc arguments.
  41     private static final String[] ARGS = new String[] {
  42         "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "pkg1"
  43     };
  44 
  45     private static final String[] ARGS_1 = new String[] {
  46         "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg1"
  47     };
  48 
  49     //Input for string search tests.
  50     private static final String[][] TEST = {
  51         {BUG_ID + FS + "pkg" + FS + "A.html",
  52             "<td class=\"colFirst\"><code>default void</code></td>"},
  53         {BUG_ID + FS + "pkg" + FS + "A.html",
  54             "<pre>default&nbsp;void&nbsp;defaultMethod()</pre>"},
  55         {BUG_ID + FS + "pkg" + FS + "A.html",
  56             "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
  57             "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
  58             "<span id=\"t2\" class=\"tableTab\"><span>" +
  59             "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
  60             "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
  61             "class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
  62             "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span>" +
  63             "</span><span id=\"t5\" class=\"tableTab\"><span>" +
  64             "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
  65             "<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
  66         {BUG_ID + FS + "pkg" + FS + "A.html",
  67             "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
  68             "<dd>This is a functional interface and can therefore be used as " +
  69             "the assignment target for a lambda expression or method " +
  70             "reference.</dd>" + NL + "</dl>"},
  71         {BUG_ID + FS + "pkg1" + FS + "FuncInf.html",
  72             "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
  73             "<dd>This is a functional interface and can therefore be used as " +
  74             "the assignment target for a lambda expression or method " +
  75             "reference.</dd>" + NL + "</dl>"}
  76     };
  77     private static final String[][] NEGATED_TEST = {
  78         {BUG_ID + FS + "pkg" + FS + "A.html",
  79             "<td class=\"colFirst\"><code>default default void</code></td>"},
  80         {BUG_ID + FS + "pkg" + FS + "A.html",
  81             "<pre>default&nbsp;default&nbsp;void&nbsp;defaultMethod()</pre>"},
  82         {BUG_ID + FS + "pkg" + FS + "B.html",
  83             "<td class=\"colFirst\"><code>default void</code></td>"},
  84         {BUG_ID + FS + "pkg" + FS + "B.html",
  85             "<dl>" + NL + "<dt>Functional Interface:</dt>"}
  86     };
  87     private static final String[][] NEGATED_TEST_1 = {
  88         {BUG_ID + "-2" + FS + "pkg1" + FS + "FuncInf.html",
  89             "<dl>" + NL + "<dt>Functional Interface:</dt>"}
  90     };
  91 
  92     /**
  93      * The entry point of the test.
  94      * @param args the array of command line arguments.
  95      */
  96     public static void main(String[] args) {
  97         TestLambdaFeature tester = new TestLambdaFeature();
  98         run(tester, ARGS, TEST, NEGATED_TEST);
  99         run(tester, ARGS_1, NO_TEST, NEGATED_TEST_1);
 100         tester.printSummary();
 101     }
 102 
 103     /**
 104      * {@inheritDoc}
 105      */
 106     public String getBugId() {
 107         return BUG_ID;
 108     }
 109 
 110     /**
 111      * {@inheritDoc}
 112      */
 113     public String getBugName() {
 114         return getClass().getName();
 115     }
 116 }