TestSerializedFormDeprecationInfo.java revision 3233:b5d08bc0d224
1/* 2 * Copyright (c) 2009, 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 6802694 8025633 8026567 27 * @summary This test verifies deprecation info in serialized-form.html. 28 * @author Bhavesh Patel 29 * @library ../lib 30 * @modules jdk.javadoc 31 * @build JavadocTester 32 * @run main TestSerializedFormDeprecationInfo 33 */ 34 35public class TestSerializedFormDeprecationInfo extends JavadocTester { 36 37 public static void main(String... args) throws Exception { 38 TestSerializedFormDeprecationInfo tester = new TestSerializedFormDeprecationInfo(); 39 tester.runTests(); 40 } 41 42 @Test 43 void testDefault() { 44 javadoc("-d", "out-default", 45 "-sourcepath", testSrc, 46 "pkg1"); 47 checkExit(Exit.FAILED); // TODO: should be OK 48 49 checkCommentDeprecated(true); 50 checkNoComment(false); 51 } 52 53 @Test 54 void testNoComment() { 55 javadoc("-d", "out-nocmnt", 56 "-nocomment", 57 "-sourcepath", testSrc, 58 "pkg1"); 59 checkExit(Exit.FAILED); // TODO: should be OK 60 61 checkNoComment(true); 62 checkCommentDeprecated(false); 63 } 64 65 @Test 66 void testNoDeprecated() { 67 javadoc("-d", "out-nodepr", 68 "-nodeprecated", 69 "-sourcepath", testSrc, 70 "pkg1"); 71 checkExit(Exit.FAILED); // TODO: should be OK 72 73 checkNoDeprecated(true); 74 checkNoCommentNoDeprecated(false); 75 } 76 77 @Test 78 void testNoCommentNoDeprecated() { 79 javadoc("-d", "out-nocmnt-nodepr", 80 "-nocomment", 81 "-nodeprecated", 82 "-sourcepath", testSrc, 83 "pkg1"); 84 checkExit(Exit.FAILED); // TODO: should be OK 85 checkNoCommentNoDeprecated(true); 86 checkNoDeprecated(false); 87 } 88 89 // Test for normal run of javadoc. The serialized-form.html should 90 // display the inline comments, tags and deprecation information if any. 91 void checkCommentDeprecated(boolean expectFound) { 92 checkOutput("serialized-form.html", expectFound, 93 "<dl>\n" 94 + "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n" 95 + "<dd><code>" 96 + "java.io.IOException</code></dd>\n" 97 + "<dt><span class=\"seeLabel\">See Also:</span>" 98 + "</dt>\n" 99 + "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">" 100 + "<code>C1.setUndecorated(boolean)</code></a></dd>\n" 101 + "</dl>", 102 "<span class=\"deprecatedLabel\">Deprecated.</span>" 103 + " <span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" 104 + " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" 105 + "<code>setUndecorated(boolean)</code></a>.</span></div>\n" 106 + "<div class=\"block\">This field indicates whether the C1 " 107 + "is undecorated.</div>\n" 108 + " \n" 109 + "<dl>\n" 110 + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" 111 + "<dd>1.4</dd>\n" 112 + "<dt><span class=\"seeLabel\">See Also:</span>" 113 + "</dt>\n" 114 + "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">" 115 + "<code>C1.setUndecorated(boolean)</code></a></dd>\n" 116 + "</dl>", 117 "<span class=\"deprecatedLabel\">Deprecated.</span>" 118 + " <span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" 119 + " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" 120 + "<code>setUndecorated(boolean)</code></a>.</span></div>\n" 121 + "<div class=\"block\">Reads the object stream.</div>\n" 122 + "<dl>\n" 123 + "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n" 124 + "<dd><code>java.io.IOException</code></dd>\n" 125 + "</dl>", 126 "<span class=\"deprecatedLabel\">Deprecated.</span>" 127 + " </div>\n" 128 + "<div class=\"block\">" 129 + "The name for this class.</div>"); 130 } 131 132 // Test with -nocomment option. The serialized-form.html should 133 // not display the inline comments and tags but should display deprecation 134 // information if any. 135 void checkNoComment(boolean expectFound) { 136 checkOutput("serialized-form.html", expectFound, 137 "<pre>boolean undecorated</pre>\n" 138 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span> <span class=\"deprecationComment\">" 139 + "As of JDK version 1.5, replaced by\n" 140 + " <a href=\"pkg1/C1.html#setUndecorated-boolean-\"><code>" 141 + "setUndecorated(boolean)</code></a>.</span></div>\n" 142 + "</li>", 143 "<span class=\"deprecatedLabel\">" 144 + "Deprecated.</span> <span class=\"deprecationComment\">As of JDK version" 145 + " 1.5, replaced by\n" 146 + " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" 147 + "<code>setUndecorated(boolean)</code></a>.</span></div>\n" 148 + "</li>"); 149 } 150 151 // Test with -nodeprecated option. The serialized-form.html should 152 // ignore the -nodeprecated tag and display the deprecation info. This 153 // test is similar to the normal run of javadoc in which inline comment, tags 154 // and deprecation information will be displayed. 155 void checkNoDeprecated(boolean expectFound) { 156 checkCommentDeprecated(expectFound); 157 } 158 159 // Test with -nodeprecated and -nocomment options. The serialized-form.html should 160 // ignore the -nodeprecated tag and display the deprecation info but should not 161 // display the inline comments and tags. This test is similar to the test with 162 // -nocomment option. 163 void checkNoCommentNoDeprecated(boolean expectFound) { 164 checkNoComment(expectFound); 165 } 166} 167