jjg@1413: /* jjg@1413: * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. jjg@1413: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@1413: * jjg@1413: * This code is free software; you can redistribute it and/or modify it jjg@1413: * under the terms of the GNU General Public License version 2 only, as jjg@1413: * published by the Free Software Foundation. jjg@1413: * jjg@1413: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@1413: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@1413: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@1413: * version 2 for more details (a copy is included in the LICENSE file that jjg@1413: * accompanied this code). jjg@1413: * jjg@1413: * You should have received a copy of the GNU General Public License version jjg@1413: * 2 along with this work; if not, write to the Free Software Foundation, jjg@1413: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@1413: * jjg@1413: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jjg@1413: * or visit www.oracle.com if you need additional information or have any jjg@1413: * questions. jjg@1413: */ jjg@1413: jjg@1413: /* jjg@1413: * @test jjg@1413: * @bug 6493690 jjg@1413: * @summary javadoc should have a javax.tools.Tool service provider jjg@1413: * @build APITest jjg@1413: * @run main GetTask_WriterTest jjg@1413: */ jjg@1413: jjg@1413: import java.io.File; jjg@1413: import java.io.PrintWriter; jjg@1413: import java.io.StringWriter; jjg@1413: import java.util.Arrays; jjg@1413: import javax.tools.DocumentationTool; jjg@1413: import javax.tools.DocumentationTool.DocumentationTask; jjg@1413: import javax.tools.JavaFileObject; jjg@1413: import javax.tools.StandardJavaFileManager; jjg@1413: import javax.tools.ToolProvider; jjg@1413: jjg@1413: /** jjg@1413: * Tests for DocumentationTool.getTask writer parameter. jjg@1413: */ jjg@1413: public class GetTask_WriterTest extends APITest { jjg@1413: public static void main(String... args) throws Exception { jjg@1413: new GetTask_WriterTest().run(); jjg@1413: } jjg@1413: jjg@1413: /** jjg@1413: * Verify that a writer can be provided. jjg@1413: */ jjg@1413: @Test jjg@1413: public void testWriter() throws Exception { jjg@1413: JavaFileObject srcFile = createSimpleJavaFileObject(); jjg@1413: DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); jjg@1413: StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); jjg@1413: File outDir = getOutDir(); jjg@1413: fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); jjg@1413: Iterable files = Arrays.asList(srcFile); jjg@1413: StringWriter sw = new StringWriter(); jjg@1413: PrintWriter pw = new PrintWriter(sw); jjg@1413: DocumentationTask t = tool.getTask(pw, fm, null, null, null, files); jjg@1413: if (t.call()) { jjg@1413: System.err.println("task succeeded"); jjg@1413: checkFiles(outDir, standardExpectFiles); jjg@1413: String out = sw.toString(); jjg@1413: System.err.println(">>" + out + "<<"); jjg@1413: for (String f: standardExpectFiles) { jjg@1413: if (f.endsWith(".html") && !out.contains(f)) jjg@1413: throw new Exception("expected string not found: " + f); jjg@1413: } jjg@1413: } else { jjg@1413: throw new Exception("task failed"); jjg@1413: } jjg@1413: } jjg@1413: } jjg@1413: