test/tools/javadoc/api/basic/RunTest.java

Sat, 17 Nov 2012 19:01:03 +0000

author
mcimadamore
date
Sat, 17 Nov 2012 19:01:03 +0000
changeset 1415
01c9d4161882
parent 1413
bdcef2ef52d2
child 1420
fb97eaf93d61
permissions
-rw-r--r--

8003280: Add lambda tests
Summary: Turn on lambda expression, method reference and default method support
Reviewed-by: jjg

     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  */
    24 /*
    25  * @test
    26  * @bug 6493690
    27  * @summary javadoc should have a javax.tools.Tool service provider
    28  * @build APITest
    29  * @run main RunTest
    30  */
    32 import java.io.ByteArrayOutputStream;
    33 import java.io.File;
    34 import javax.tools.DocumentationTool;
    35 import javax.tools.ToolProvider;
    37 /**
    38  * Tests for DocumentationTool.run method.
    39  */
    40 public class RunTest extends APITest {
    41     public static void main(String... args) throws Exception {
    42         new RunTest().run();
    43     }
    45     /**
    46      * Verify that run method can be invoked.
    47      */
    48     @Test
    49     public void testRun() throws Exception {
    50         File testSrc = new File(System.getProperty("test.src"));
    51         File srcFile = new File(testSrc, "pkg/C.java");
    52         File outDir = getOutDir();
    53         String[] args = { "-d", outDir.getPath(), srcFile.getPath() };
    55         ByteArrayOutputStream stdout = new ByteArrayOutputStream();
    56         ByteArrayOutputStream stderr = new ByteArrayOutputStream();
    57         DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    58         int rc = tool.run(null, stdout, stderr, args);
    59         System.err.println("stdout >>" + stdout.toString() + "<<");
    60         System.err.println("stderr >>" + stderr.toString() + "<<");
    62         if (rc == 0) {
    63             System.err.println("call succeeded");
    64             checkFiles(outDir, standardExpectFiles);
    65             String out = stdout.toString();
    66             for (String f: standardExpectFiles) {
    67                 if (f.endsWith(".html") && !out.contains(f))
    68                     error("expected string not found: " + f);
    69             }
    70         } else {
    71             error("call failed");
    72         }
    73     }
    75     /**
    76      * Verify that run method can be invoked.
    77      */
    78     @Test
    79     public void testRun2() throws Exception {
    80         File outDir = getOutDir();
    81         String badfile = "badfile.java";
    82         String[] args = { "-d", outDir.getPath(), badfile };
    84         ByteArrayOutputStream stdout = new ByteArrayOutputStream();
    85         ByteArrayOutputStream stderr = new ByteArrayOutputStream();
    86         DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    87         int rc = tool.run(null, stdout, stderr, args);
    88         System.err.println("stdout >>" + stdout.toString() + "<<");
    89         System.err.println("stderr >>" + stderr.toString() + "<<");
    91         if (rc == 0) {
    92             error("call succeeded unexpectedly");
    93         } else {
    94             String err = stderr.toString();
    95             if (err.contains(badfile))
    96                 System.err.println("call failed as expected");
    97             else
    98                 error("expected diagnostic not found");
    99         }
   100     }
   102 }

mercurial