31936
|
1 |
/*
|
|
2 |
* Copyright (c) 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 |
import com.sun.tools.javadoc.Main;
|
|
25 |
import java.io.PrintWriter;
|
|
26 |
import java.io.StringWriter;
|
|
27 |
import java.util.ArrayList;
|
|
28 |
import java.util.Arrays;
|
|
29 |
import java.util.List;
|
|
30 |
import java.util.function.Predicate;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* @test
|
|
34 |
* @bug 8086737
|
|
35 |
* @summary Test -release option in javadoc
|
|
36 |
* @run main ReleaseOption
|
|
37 |
*/
|
|
38 |
public class ReleaseOption {
|
|
39 |
public static void main(String... args) {
|
|
40 |
new ReleaseOption().run();
|
|
41 |
}
|
|
42 |
|
|
43 |
void run() {
|
|
44 |
doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "7");
|
|
45 |
doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "8");
|
|
46 |
doRunTest(1, out -> true, "-release", "7", "-source", "7");
|
|
47 |
doRunTest(1, out -> true, "-release", "7", "-bootclasspath", "any");
|
|
48 |
}
|
|
49 |
|
|
50 |
void doRunTest(int expectedResult, Predicate<String> validate, String... args) {
|
|
51 |
System.err.println("running with args: " + Arrays.asList(args));
|
|
52 |
List<String> options = new ArrayList<>();
|
|
53 |
options.addAll(Arrays.asList(args));
|
|
54 |
options.add("-XDrawDiagnostics");
|
|
55 |
options.add(System.getProperty("test.src", ".") + java.io.File.separatorChar + "ReleaseOptionSource.java");
|
|
56 |
StringWriter out = new StringWriter();
|
|
57 |
PrintWriter pw = new PrintWriter(out);
|
|
58 |
int actualResult = Main.execute("javadoc", pw, pw, pw, "com.sun.tools.doclets.formats.html.HtmlDoclet", options.toArray(new String[0]));
|
|
59 |
System.err.println("actual result=" + actualResult);
|
|
60 |
System.err.println("actual output=" + out.toString());
|
|
61 |
if (actualResult != expectedResult)
|
|
62 |
throw new Error();
|
|
63 |
if (!validate.test(out.toString())) {
|
|
64 |
throw new Error("Not an expected error output: " + out.toString());
|
|
65 |
}
|
|
66 |
}
|
|
67 |
}
|