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