langtools/test/jdk/jshell/StartOptionTest.java
author rfield
Thu, 26 May 2016 07:58:01 -0700
changeset 38608 691b607bbcd6
parent 37745 4b6b59f8e327
child 38613 2a8e50869b08
permissions -rw-r--r--
8157917: JShell: shutdown could cause remote JDWP errors to be visible to users 8157918: JShell tests: StartOptionTest displays insufficient information to diagnose failures Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     1
/*
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35359
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     4
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     8
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    14
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    18
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    21
 * questions.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    22
 */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    23
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    24
/*
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
    25
 * @test 8151754
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    26
 * @summary Testing start-up options.
35359
f04501964016 8148147: Sync up @modules from jigsaw/jake
alanb
parents: 33362
diff changeset
    27
 * @modules jdk.compiler/com.sun.tools.javac.api
f04501964016 8148147: Sync up @modules from jigsaw/jake
alanb
parents: 33362
diff changeset
    28
 *          jdk.compiler/com.sun.tools.javac.main
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35359
diff changeset
    29
 *          jdk.jdeps/com.sun.tools.javap
35359
f04501964016 8148147: Sync up @modules from jigsaw/jake
alanb
parents: 33362
diff changeset
    30
 *          jdk.jshell/jdk.internal.jshell.tool
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    31
 * @library /tools/lib
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36715
diff changeset
    32
 * @build Compiler toolbox.ToolBox
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    33
 * @run testng StartOptionTest
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    34
 */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    35
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    36
import java.io.ByteArrayOutputStream;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    37
import java.io.PrintStream;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    38
import java.nio.charset.StandardCharsets;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    39
import java.nio.file.Path;
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
    40
import java.util.Locale;
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    41
import java.util.function.Consumer;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    42
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    43
import jdk.internal.jshell.tool.JShellTool;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    44
import org.testng.annotations.AfterMethod;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    45
import org.testng.annotations.BeforeMethod;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    46
import org.testng.annotations.Test;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    47
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    48
import static org.testng.Assert.assertEquals;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    49
import static org.testng.Assert.assertTrue;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    50
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    51
@Test
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    52
public class StartOptionTest {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    53
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    54
    private ByteArrayOutputStream cmdout;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    55
    private ByteArrayOutputStream cmderr;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    56
    private ByteArrayOutputStream console;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    57
    private ByteArrayOutputStream userout;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    58
    private ByteArrayOutputStream usererr;
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    59
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    60
    private JShellTool getShellTool() {
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
    61
        return new JShellTool(
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
    62
                new TestingInputStream(),
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    63
                new PrintStream(cmdout),
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    64
                new PrintStream(cmderr),
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    65
                new PrintStream(console),
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
    66
                new TestingInputStream(),
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    67
                new PrintStream(userout),
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    68
                new PrintStream(usererr),
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
    69
                new ReplToolTesting.MemoryPreferences(),
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
    70
                Locale.ROOT);
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    71
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    72
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    73
    private void check(ByteArrayOutputStream str, Consumer<String> checkOut, String label) {
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    74
        byte[] bytes = str.toByteArray();
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    75
        str.reset();
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    76
        String out =  new String(bytes, StandardCharsets.UTF_8);
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    77
        if (checkOut != null) {
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    78
            checkOut.accept(out);
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    79
        } else {
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    80
            assertEquals("", out, label + ": Expected empty -- ");
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    81
        }
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    82
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    83
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    84
    private void start(Consumer<String> checkOutput, Consumer<String> checkError, String... args) throws Exception {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    85
        JShellTool tool = getShellTool();
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    86
        tool.start(args);
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    87
        check(cmdout, checkOutput, "cmdout");
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    88
        check(cmderr, checkError, "cmderr");
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    89
        check(console, null, "console");
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    90
        check(userout, null, "userout");
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    91
        check(usererr, null, "usererr");
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    92
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    93
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    94
    private void start(String expectedOutput, String expectedError, String... args) throws Exception {
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
    95
        start(s -> assertEquals(s.trim(), expectedOutput, "cmdout: "), s -> assertEquals(s.trim(), expectedError, "cmderr: "), args);
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    96
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    97
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    98
    @BeforeMethod
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    99
    public void setUp() {
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   100
        cmdout  = new ByteArrayOutputStream();
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   101
        cmderr  = new ByteArrayOutputStream();
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   102
        console = new ByteArrayOutputStream();
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   103
        userout = new ByteArrayOutputStream();
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   104
        usererr = new ByteArrayOutputStream();
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   105
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   106
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   107
    @Test
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   108
    public void testUsage() throws Exception {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   109
        start(s -> {
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   110
            assertTrue(s.split("\n").length >= 7, "Not enough usage lines: " + s);
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   111
            assertTrue(s.startsWith("Usage:   jshell <options>"), "Unexpect usage start: " + s);
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   112
        },  null, "-help");
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   113
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   114
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   115
    @Test
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   116
    public void testUnknown() throws Exception {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   117
        start(s -> {
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   118
            assertTrue(s.split("\n").length >= 7, "Not enough usage lines (unknown): " + s);
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   119
            assertTrue(s.startsWith("Usage:   jshell <options>"), "Unexpect usage start (unknown): " + s);
36993
e00f4be3a47d 8153482: jdk/jshell/StartOptionTest.java fails on Windows after JDK-8147515
rfield
parents: 36990
diff changeset
   120
        }, s -> assertEquals(s.trim(), "Unknown option: -unknown"), "-unknown");
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   121
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   122
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   123
    @Test(enabled = false) // TODO 8080883
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   124
    public void testStartup() throws Exception {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   125
        Compiler compiler = new Compiler();
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   126
        Path p = compiler.getPath("file.txt");
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   127
        compiler.writeToFile(p);
36993
e00f4be3a47d 8153482: jdk/jshell/StartOptionTest.java fails on Windows after JDK-8147515
rfield
parents: 36990
diff changeset
   128
        start("", "'-startup' requires a filename argument.", "-startup");
e00f4be3a47d 8153482: jdk/jshell/StartOptionTest.java fails on Windows after JDK-8147515
rfield
parents: 36990
diff changeset
   129
        start("", "Conflicting -startup or -nostartup option.", "-startup", p.toString(), "-startup", p.toString());
e00f4be3a47d 8153482: jdk/jshell/StartOptionTest.java fails on Windows after JDK-8147515
rfield
parents: 36990
diff changeset
   130
        start("", "Conflicting -startup or -nostartup option.", "-nostartup", "-startup", p.toString());
e00f4be3a47d 8153482: jdk/jshell/StartOptionTest.java fails on Windows after JDK-8147515
rfield
parents: 36990
diff changeset
   131
        start("", "Conflicting -startup or -nostartup option.", "-startup", p.toString(), "-nostartup");
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   132
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   133
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   134
    @Test
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   135
    public void testClasspath() throws Exception {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   136
        for (String cp : new String[] {"-cp", "-classpath"}) {
36993
e00f4be3a47d 8153482: jdk/jshell/StartOptionTest.java fails on Windows after JDK-8147515
rfield
parents: 36990
diff changeset
   137
            start("", "Conflicting -classpath option.", cp, ".", "-classpath", ".");
e00f4be3a47d 8153482: jdk/jshell/StartOptionTest.java fails on Windows after JDK-8147515
rfield
parents: 36990
diff changeset
   138
            start("", "Argument to -classpath missing.", cp);
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   139
        }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   140
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   141
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   142
    @Test
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
   143
    public void testNegFeedbackOption() throws Exception {
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
   144
        start("", "Argument to -feedback missing. Mode required.", "-feedback");
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
   145
        start("", "Does not match any current feedback mode: blorp -- -feedback blorp", "-feedback", "blorp");
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
   146
    }
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
   147
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36993
diff changeset
   148
    @Test
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   149
    public void testVersion() throws Exception {
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   150
        start(s -> assertTrue(s.startsWith("jshell"), "unexpected version: " + s), null, "-version");
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   151
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   152
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   153
    @AfterMethod
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   154
    public void tearDown() {
38608
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   155
        cmdout  = null;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   156
        cmderr  = null;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   157
        console = null;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   158
        userout = null;
691b607bbcd6 8157917: JShell: shutdown could cause remote JDWP errors to be visible to users
rfield
parents: 37745
diff changeset
   159
        usererr = null;
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   160
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   161
}