TestCharset.java revision 3294:9adfb22ff08f
1218822Sdim/*
2218822Sdim * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
338889Sjdp * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4218822Sdim *
5218822Sdim * This code is free software; you can redistribute it and/or modify it
638889Sjdp * under the terms of the GNU General Public License version 2 only, as
738889Sjdp * published by the Free Software Foundation.
838889Sjdp *
938889Sjdp * This code is distributed in the hope that it will be useful, but WITHOUT
1033965Sjdp * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1138889Sjdp * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1238889Sjdp * version 2 for more details (a copy is included in the LICENSE file that
1338889Sjdp * accompanied this code).
1433965Sjdp *
15218822Sdim * You should have received a copy of the GNU General Public License version
1638889Sjdp * 2 along with this work; if not, write to the Free Software Foundation,
1738889Sjdp * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1838889Sjdp *
1938889Sjdp * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2033965Sjdp * or visit www.oracle.com if you need additional information or have any
2138889Sjdp * questions.
2238889Sjdp */
2338889Sjdp
2438889Sjdp/*
25218822Sdim * @test
2633965Sjdp * @bug      7052170 8047745
27218822Sdim * @summary  Run a test on -charset to make sure the charset gets generated as a
28218822Sdim *           part of the meta tag.
29218822Sdim * @author   Bhavesh Patel
30218822Sdim * @library  ../lib
31218822Sdim * @modules jdk.javadoc/jdk.javadoc.internal.tool
3238889Sjdp * @build    JavadocTester
3338889Sjdp * @run main TestCharset
3438889Sjdp */
3538889Sjdp
3638889Sjdppublic class TestCharset extends JavadocTester {
3738889Sjdp
3838889Sjdp    public static void main(String... args) throws Exception {
3938889Sjdp        TestCharset tester = new TestCharset();
4038889Sjdp        tester.runTests();
41218822Sdim    }
42218822Sdim
43218822Sdim    @Test
44218822Sdim    void test() {
45218822Sdim        javadoc("-d", "out",
46218822Sdim                "-charset", "ISO-8859-1",
47218822Sdim                "-sourcepath", testSrc,
48218822Sdim                "pkg");
49218822Sdim        checkExit(Exit.OK);
50218822Sdim
51218822Sdim        checkOutput("index.html", true,
52218822Sdim            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
53218822Sdim        checkOutput("pkg/Foo.html", true,
54218822Sdim            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
55218822Sdim
56218822Sdim        checkOutput("index.html", false,
57218822Sdim            "<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"ISO-8859-1\">");
58218822Sdim        checkOutput("pkg/Foo.html", false,
59218822Sdim            "<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"ISO-8859-1\">");
60218822Sdim    }
61218822Sdim
62218822Sdim    @Test
63218822Sdim    void test1() {
64218822Sdim        javadoc("-d", "out-1",
65218822Sdim                "-sourcepath", testSrc,
66218822Sdim                "pkg");
67218822Sdim        checkExit(Exit.OK);
68218822Sdim
69218822Sdim        checkOutput("index.html", true,
70218822Sdim            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
71218822Sdim        checkOutput("pkg/Foo.html", true,
72218822Sdim            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
73218822Sdim    }
74218822Sdim}
75218822Sdim