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_WriterTest.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_WriterTest
30
*/
31
32
import java.io.File;
33
import java.io.PrintWriter;
34
import java.io.StringWriter;
35
import java.util.Arrays;
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 writer parameter.
44
*/
45
public class GetTask_WriterTest extends APITest {
46
public static void main(String... args) throws Exception {
47
new GetTask_WriterTest().run();
48
}
49
50
/**
51
* Verify that a writer can be provided.
52
*/
53
@Test
54
public void testWriter() 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
StringWriter sw = new StringWriter();
62
PrintWriter pw = new PrintWriter(sw);
63
DocumentationTask t = tool.getTask(pw, fm, null, null, null, files);
64
if (t.call()) {
65
System.err.println("task succeeded");
66
checkFiles(outDir, standardExpectFiles);
67
String out = sw.toString();
68
System.err.println(">>" + out + "<<");
69
for (String f: standardExpectFiles) {
70
String f1 = f.replace('/', File.separatorChar);
71
if (f1.endsWith(".html") && !out.contains(f1))
72
throw new Exception("expected string not found: " + f1);
73
}
74
} else {
75
throw new Exception("task failed");
76
}
77
}
78
}
79
80
81