langtools/test/jdk/javadoc/tool/ReleaseOption.java
changeset 40308 274367a99f98
parent 36526 3b41f1c69604
child 40763 209113892b0d
equal deleted inserted replaced
40306:1a0fcaf3f2ed 40308:274367a99f98
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
       
    24 import java.io.File;
    24 import java.io.PrintWriter;
    25 import java.io.PrintWriter;
    25 import java.io.StringWriter;
    26 import java.io.StringWriter;
    26 import java.util.ArrayList;
    27 import java.util.ArrayList;
    27 import java.util.Arrays;
    28 import java.util.Arrays;
    28 import java.util.List;
    29 import java.util.List;
    51     void doRunTest(int expectedResult, Predicate<String> validate, String... args) {
    52     void doRunTest(int expectedResult, Predicate<String> validate, String... args) {
    52         System.err.println("running with args: " + Arrays.asList(args));
    53         System.err.println("running with args: " + Arrays.asList(args));
    53         List<String> options = new ArrayList<>();
    54         List<String> options = new ArrayList<>();
    54         options.addAll(Arrays.asList(args));
    55         options.addAll(Arrays.asList(args));
    55         options.add("-XDrawDiagnostics");
    56         options.add("-XDrawDiagnostics");
    56         options.add(System.getProperty("test.src", ".") + java.io.File.separatorChar + "ReleaseOptionSource.java");
    57         options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath());
    57         StringWriter out = new StringWriter();
    58         StringWriter out = new StringWriter();
    58         PrintWriter pw = new PrintWriter(out);
    59         PrintWriter pw = new PrintWriter(out);
    59         int actualResult = Main.execute(options.toArray(new String[0]), pw);
    60         int actualResult = Main.execute(options.toArray(new String[0]), pw);
    60         System.err.println("actual result=" + actualResult);
    61         System.err.println("actual result=" + actualResult);
    61         System.err.println("actual output=" + out.toString());
    62         System.err.println("actual output=" + out.toString());
    62         if (actualResult != expectedResult)
    63         if (actualResult != expectedResult)
    63             throw new Error();
    64             throw new Error("Exit code not as expected");
    64         if (!validate.test(out.toString())) {
    65         if (!validate.test(out.toString())) {
    65             throw new Error("Not an expected error output: " + out.toString());
    66             throw new Error("Output not as expected");
    66         }
    67         }
    67     }
    68     }
    68 }
    69 }