Mon, 17 Nov 2014 12:40:43 -0800
Added tag jdk8u31-b09 for changeset 26c46688ce4a
jjg@1413 | 1 | /* |
jjg@1413 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
jjg@1413 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@1413 | 4 | * |
jjg@1413 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@1413 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@1413 | 7 | * published by the Free Software Foundation. |
jjg@1413 | 8 | * |
jjg@1413 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@1413 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@1413 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@1413 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@1413 | 13 | * accompanied this code). |
jjg@1413 | 14 | * |
jjg@1413 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@1413 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@1413 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@1413 | 18 | * |
jjg@1413 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jjg@1413 | 20 | * or visit www.oracle.com if you need additional information or have any |
jjg@1413 | 21 | * questions. |
jjg@1413 | 22 | */ |
jjg@1413 | 23 | |
jjg@1413 | 24 | /* |
jjg@1413 | 25 | * @test |
jjg@1413 | 26 | * @bug 6493690 |
jjg@1413 | 27 | * @summary javadoc should have a javax.tools.Tool service provider |
jjg@1413 | 28 | * @build APITest |
jjg@1413 | 29 | * @run main GetTask_WriterTest |
jjg@1413 | 30 | */ |
jjg@1413 | 31 | |
jjg@1413 | 32 | import java.io.File; |
jjg@1413 | 33 | import java.io.PrintWriter; |
jjg@1413 | 34 | import java.io.StringWriter; |
jjg@1413 | 35 | import java.util.Arrays; |
jjg@1413 | 36 | import javax.tools.DocumentationTool; |
jjg@1413 | 37 | import javax.tools.DocumentationTool.DocumentationTask; |
jjg@1413 | 38 | import javax.tools.JavaFileObject; |
jjg@1413 | 39 | import javax.tools.StandardJavaFileManager; |
jjg@1413 | 40 | import javax.tools.ToolProvider; |
jjg@1413 | 41 | |
jjg@1413 | 42 | /** |
jjg@1413 | 43 | * Tests for DocumentationTool.getTask writer parameter. |
jjg@1413 | 44 | */ |
jjg@1413 | 45 | public class GetTask_WriterTest extends APITest { |
jjg@1413 | 46 | public static void main(String... args) throws Exception { |
jjg@1413 | 47 | new GetTask_WriterTest().run(); |
jjg@1413 | 48 | } |
jjg@1413 | 49 | |
jjg@1413 | 50 | /** |
jjg@1413 | 51 | * Verify that a writer can be provided. |
jjg@1413 | 52 | */ |
jjg@1413 | 53 | @Test |
jjg@1413 | 54 | public void testWriter() throws Exception { |
jjg@1413 | 55 | JavaFileObject srcFile = createSimpleJavaFileObject(); |
jjg@1413 | 56 | DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); |
jjg@1413 | 57 | StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); |
jjg@1413 | 58 | File outDir = getOutDir(); |
jjg@1413 | 59 | fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); |
jjg@1413 | 60 | Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile); |
jjg@1413 | 61 | StringWriter sw = new StringWriter(); |
jjg@1413 | 62 | PrintWriter pw = new PrintWriter(sw); |
jjg@1413 | 63 | DocumentationTask t = tool.getTask(pw, fm, null, null, null, files); |
jjg@1413 | 64 | if (t.call()) { |
jjg@1413 | 65 | System.err.println("task succeeded"); |
jjg@1413 | 66 | checkFiles(outDir, standardExpectFiles); |
jjg@1413 | 67 | String out = sw.toString(); |
jjg@1413 | 68 | System.err.println(">>" + out + "<<"); |
jjg@1413 | 69 | for (String f: standardExpectFiles) { |
jjg@1420 | 70 | String f1 = f.replace('/', File.separatorChar); |
jjg@1420 | 71 | if (f1.endsWith(".html") && !out.contains(f1)) |
jjg@1420 | 72 | throw new Exception("expected string not found: " + f1); |
jjg@1413 | 73 | } |
jjg@1413 | 74 | } else { |
jjg@1413 | 75 | throw new Exception("task failed"); |
jjg@1413 | 76 | } |
jjg@1413 | 77 | } |
jjg@1413 | 78 | } |
jjg@1413 | 79 |