Sat, 17 Nov 2012 19:01:03 +0000
8003280: Add lambda tests
Summary: Turn on lambda expression, method reference and default method support
Reviewed-by: jjg
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 RunTest |
jjg@1413 | 30 | */ |
jjg@1413 | 31 | |
jjg@1413 | 32 | import java.io.ByteArrayOutputStream; |
jjg@1413 | 33 | import java.io.File; |
jjg@1413 | 34 | import javax.tools.DocumentationTool; |
jjg@1413 | 35 | import javax.tools.ToolProvider; |
jjg@1413 | 36 | |
jjg@1413 | 37 | /** |
jjg@1413 | 38 | * Tests for DocumentationTool.run method. |
jjg@1413 | 39 | */ |
jjg@1413 | 40 | public class RunTest extends APITest { |
jjg@1413 | 41 | public static void main(String... args) throws Exception { |
jjg@1413 | 42 | new RunTest().run(); |
jjg@1413 | 43 | } |
jjg@1413 | 44 | |
jjg@1413 | 45 | /** |
jjg@1413 | 46 | * Verify that run method can be invoked. |
jjg@1413 | 47 | */ |
jjg@1413 | 48 | @Test |
jjg@1413 | 49 | public void testRun() throws Exception { |
jjg@1413 | 50 | File testSrc = new File(System.getProperty("test.src")); |
jjg@1413 | 51 | File srcFile = new File(testSrc, "pkg/C.java"); |
jjg@1413 | 52 | File outDir = getOutDir(); |
jjg@1413 | 53 | String[] args = { "-d", outDir.getPath(), srcFile.getPath() }; |
jjg@1413 | 54 | |
jjg@1413 | 55 | ByteArrayOutputStream stdout = new ByteArrayOutputStream(); |
jjg@1413 | 56 | ByteArrayOutputStream stderr = new ByteArrayOutputStream(); |
jjg@1413 | 57 | DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); |
jjg@1413 | 58 | int rc = tool.run(null, stdout, stderr, args); |
jjg@1413 | 59 | System.err.println("stdout >>" + stdout.toString() + "<<"); |
jjg@1413 | 60 | System.err.println("stderr >>" + stderr.toString() + "<<"); |
jjg@1413 | 61 | |
jjg@1413 | 62 | if (rc == 0) { |
jjg@1413 | 63 | System.err.println("call succeeded"); |
jjg@1413 | 64 | checkFiles(outDir, standardExpectFiles); |
jjg@1413 | 65 | String out = stdout.toString(); |
jjg@1413 | 66 | for (String f: standardExpectFiles) { |
jjg@1413 | 67 | if (f.endsWith(".html") && !out.contains(f)) |
jjg@1413 | 68 | error("expected string not found: " + f); |
jjg@1413 | 69 | } |
jjg@1413 | 70 | } else { |
jjg@1413 | 71 | error("call failed"); |
jjg@1413 | 72 | } |
jjg@1413 | 73 | } |
jjg@1413 | 74 | |
jjg@1413 | 75 | /** |
jjg@1413 | 76 | * Verify that run method can be invoked. |
jjg@1413 | 77 | */ |
jjg@1413 | 78 | @Test |
jjg@1413 | 79 | public void testRun2() throws Exception { |
jjg@1413 | 80 | File outDir = getOutDir(); |
jjg@1413 | 81 | String badfile = "badfile.java"; |
jjg@1413 | 82 | String[] args = { "-d", outDir.getPath(), badfile }; |
jjg@1413 | 83 | |
jjg@1413 | 84 | ByteArrayOutputStream stdout = new ByteArrayOutputStream(); |
jjg@1413 | 85 | ByteArrayOutputStream stderr = new ByteArrayOutputStream(); |
jjg@1413 | 86 | DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); |
jjg@1413 | 87 | int rc = tool.run(null, stdout, stderr, args); |
jjg@1413 | 88 | System.err.println("stdout >>" + stdout.toString() + "<<"); |
jjg@1413 | 89 | System.err.println("stderr >>" + stderr.toString() + "<<"); |
jjg@1413 | 90 | |
jjg@1413 | 91 | if (rc == 0) { |
jjg@1413 | 92 | error("call succeeded unexpectedly"); |
jjg@1413 | 93 | } else { |
jjg@1413 | 94 | String err = stderr.toString(); |
jjg@1413 | 95 | if (err.contains(badfile)) |
jjg@1413 | 96 | System.err.println("call failed as expected"); |
jjg@1413 | 97 | else |
jjg@1413 | 98 | error("expected diagnostic not found"); |
jjg@1413 | 99 | } |
jjg@1413 | 100 | } |
jjg@1413 | 101 | |
jjg@1413 | 102 | } |
jjg@1413 | 103 |