1 /* 2 * Copyright (c) 2009, 2019, 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 6786682 4649116 8182765 27 * @summary This test verifies the use of lang attribute by <HTML>. 28 * @library ../../lib 29 * @modules jdk.javadoc/jdk.javadoc.internal.tool 30 * @build javadoc.tester.* 31 * @run main TestHtmlTag 32 */ 33 34 import java.util.Locale; 35 36 import javadoc.tester.JavadocTester; 37 38 public class TestHtmlTag extends JavadocTester { 39 private static final String defaultLanguage = Locale.getDefault().getLanguage(); 40 public static void main(String... args) throws Exception { 41 TestHtmlTag tester = new TestHtmlTag(); 42 tester.runTests(); 43 } 44 @Test 45 public void test_default() { 46 javadoc("-locale", defaultLanguage, 47 "-d", "out-default", 48 "-sourcepath", testSrc, 49 "pkg1"); 50 51 checkExit(Exit.OK); 52 53 checkOutput("pkg1/C1.html", true, 54 "<html lang=\"" + defaultLanguage + "\">"); 55 56 checkOutput("pkg1/package-summary.html", true, 57 "<html lang=\"" + defaultLanguage + "\">"); 58 59 checkOutput("pkg1/C1.html", false, 60 "<html>"); 61 } 62 63 @Test 64 public void test_ja() { 65 // TODO: why does this test need/use pkg2; why can't it use pkg1 66 // like the other two tests, so that we can share the check methods? 67 javadoc("-locale", "ja", 68 "-d", "out-ja", 69 "-sourcepath", testSrc, 70 "pkg2"); 71 checkExit(Exit.OK); 72 73 checkOutput("pkg2/C2.html", true, 74 "<html lang=\"ja\">"); 75 76 checkOutput("pkg2/package-summary.html", true, 77 "<html lang=\"ja\">"); 78 79 checkOutput("pkg2/C2.html", false, 80 "<html>"); 81 } 82 83 @Test 84 public void test_en_US() { 85 javadoc("-locale", "en_US", 86 "-d", "out-en_US", 87 "-sourcepath", testSrc, 88 "pkg1"); 89 checkExit(Exit.OK); 90 91 checkOutput("pkg1/C1.html", true, 92 "<html lang=\"en\">"); 93 94 checkOutput("pkg1/package-summary.html", true, 95 "<html lang=\"en\">"); 96 97 checkOutput("pkg1/C1.html", false, 98 "<html>"); 99 } 100 101 @Test 102 public void test_other() { 103 javadoc("-locale", "en_US", 104 "-d", "out-other", 105 "-sourcepath", testSrc, 106 "pkg3"); 107 checkExit(Exit.OK); 108 109 checkOutput("pkg3/package-summary.html", true, 110 "<div class=\"contentContainer\">\n" 111 + "<section class=\"packageDescription\" id=\"package.description\">\n" 112 + "<div class=\"block\"><p>This is the first line. Note the newlines before the <p> is relevant.</div>\n" 113 + "</section>"); 114 115 checkOutput("pkg3/A.DatatypeFactory.html", true, 116 "<div class=\"block\"><p>\n" 117 + " Factory that creates new <code>javax.xml.datatype</code>\n" 118 + " <code>Object</code>s that map XML to/from Java <code>Object</code>s.</p>\n" 119 + "\n" 120 + " <p id=\"DatatypeFactory.newInstance\">\n" 121 + " A new instance of the <code>DatatypeFactory</code> is created through the\n" 122 + " <a href=\"#newInstance()\"><code>newInstance()</code></a> method that uses the following implementation\n" 123 + " resolution mechanisms to determine an implementation:</p>\n" 124 + " <ol>\n" 125 + " <li>\n" 126 + " If the system property specified by <a href=\"#DATATYPEFACTORY_PROPERTY\"><code>DATATYPEFACTORY_PROPERTY</code></a>,\n" 127 + " \"<code>javax.xml.datatype.DatatypeFactory</code>\", exists, a class with\n" 128 + " the name of the property value is instantiated. Any Exception thrown\n" 129 + " during the instantiation process is wrapped as a\n" 130 + " <code>IllegalStateException</code>.\n" 131 + " </li>\n" 132 + " <li>\n" 133 + " If the file ${JAVA_HOME}/lib/jaxp.properties exists, it is loaded in a\n" 134 + " <code>Properties</code> <code>Object</code>. The\n" 135 + " <code>Properties</code> <code>Object </code> is then queried for the\n" 136 + " property as documented in the prior step and processed as documented in\n" 137 + " the prior step.\n" 138 + " </li>\n" 139 + " <li>\n" 140 + " Uses the service-provider loading facilities, defined by the\n" 141 + " <code>ServiceLoader</code> class, to attempt to locate and load an\n" 142 + " implementation of the service using the default loading mechanism:\n" 143 + " the service-provider loading facility will use the current thread's context class loader\n" 144 + " to attempt to load the service. If the context class loader is null, the system class loader will be used.\n" 145 + " <br>\n" 146 + " In case of <code>service configuration error</code> a\n" 147 + " <code>DatatypeConfigurationException</code> will be thrown.\n" 148 + " </li>\n" 149 + " <li>\n" 150 + " The final mechanism is to attempt to instantiate the <code>Class</code>\n" 151 + " specified by <a href=\"#DATATYPEFACTORY_IMPLEMENTATION_CLASS\"><code>DATATYPEFACTORY_IMPLEMENTATION_CLASS</code></a>. Any Exception\n" 152 + " thrown during the instantiation process is wrapped as a\n" 153 + " <code>IllegalStateException</code>.\n" 154 + " </li>\n" 155 + " </ol></div>"); 156 157 checkOutput("pkg3/A.ActivationDesc.html", true, 158 "<pre>public class <span class=\"typeNameLabel\">A.ActivationDesc</span>\n" 159 + "extends java.lang.Object\n" 160 + "implements java.io.Serializable</pre>\n" 161 + "<div class=\"block\">An activation descriptor contains the information necessary to activate\n" 162 + " an object: <ul>\n" 163 + " <li> the object's group identifier,\n" 164 + " <li> the object's fully-qualified class name,\n" 165 + " <li> the object's code location (the location of the class), a codebase\n" 166 + " URL path,\n" 167 + " <li> the object's restart \"mode\", and,\n" 168 + " <li> a \"marshalled\" object that can contain object specific\n" 169 + " initialization data. </ul>\n" 170 + "\n" 171 + " <p>\n" 172 + " A descriptor registered with the activation system can be used to\n" 173 + " recreate/activate the object specified by the descriptor. The\n" 174 + " <code>MarshalledObject</code> in the object's descriptor is passed as the\n" 175 + " second argument to the remote object's constructor for object to use\n" 176 + " during reinitialization/activation.</div>"); 177 178 checkOutput("pkg3/A.ActivationGroupID.html", true, 179 "<pre>public class <span class=\"typeNameLabel\">A.ActivationGroupID</span>\n" 180 + "extends java.lang.Object\n" 181 + "implements java.io.Serializable</pre>\n" 182 + "<div class=\"block\">The identifier for a registered activation group serves several purposes:\n" 183 + " <ul>\n" 184 + " <li>identifies the group uniquely within the activation system, and\n" 185 + " <li>contains a reference to the group's activation system so that the\n" 186 + " group can contact its activation system when necessary.</ul><p>\n" 187 + "\n" 188 + " The <code>ActivationGroupID</code> is returned from the call to\n" 189 + " <code>ActivationSystem.registerGroup</code> and is used to identify the\n" 190 + " group within the activation system. This group id is passed as one of the\n" 191 + " arguments to the activation group's special constructor when an\n" 192 + " activation group is created/recreated.</div>\n" 193 + "<dl>"); 194 } 195 }