Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java
38828 views
1
/*
2
* Copyright (c) 2012, 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 6493690
27
* @summary javadoc should have a javax.tools.Tool service provider
28
* @build APITest
29
* @run main GetTask_OptionsTest
30
*/
31
32
import java.io.File;
33
import java.util.Arrays;
34
import java.util.Set;
35
import java.util.TreeSet;
36
import javax.tools.DocumentationTool;
37
import javax.tools.DocumentationTool.DocumentationTask;
38
import javax.tools.JavaFileObject;
39
import javax.tools.StandardJavaFileManager;
40
import javax.tools.ToolProvider;
41
42
/**
43
* Tests for DocumentationTool.getTask options parameter.
44
*/
45
public class GetTask_OptionsTest extends APITest {
46
public static void main(String... args) throws Exception {
47
new GetTask_OptionsTest().run();
48
}
49
50
/**
51
* Verify that expected output files are written for given options.
52
*/
53
@Test
54
public void testNoIndex() throws Exception {
55
JavaFileObject srcFile = createSimpleJavaFileObject();
56
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
57
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
58
File outDir = getOutDir();
59
fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
60
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
61
Iterable<String> options = Arrays.asList("-noindex");
62
DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
63
if (t.call()) {
64
System.err.println("task succeeded");
65
Set<String> expectFiles = new TreeSet<String>(standardExpectFiles);
66
expectFiles.remove("index-all.html");
67
checkFiles(outDir, expectFiles);
68
} else {
69
error("task failed");
70
}
71
}
72
73
/**
74
* Verify null is handled correctly.
75
*/
76
@Test
77
public void testNull() throws Exception {
78
JavaFileObject srcFile = createSimpleJavaFileObject();
79
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
80
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
81
File outDir = getOutDir();
82
fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
83
Iterable<String> options = Arrays.asList((String) null);
84
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
85
try {
86
DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
87
error("getTask succeeded, no exception thrown");
88
} catch (NullPointerException e) {
89
System.err.println("exception caught as expected: " + e);
90
}
91
}
92
93
}
94
95
96