langtools/test/jdk/jshell/ExternalEditorTest.java
changeset 37389 9c137b83a8b8
parent 36494 4175f47b2a50
child 38828 520da69917b5
equal deleted inserted replaced
37011:c84d0cce090e 37389:9c137b83a8b8
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @summary Testing external editor.
    26  * @summary Testing external editor.
    27  * @bug 8080843
    27  * @bug 8080843 8143955
    28  * @ignore 8080843
    28  * @ignore 8080843
       
    29  * @modules jdk.jshell/jdk.internal.jshell.tool
    29  * @build ReplToolTesting CustomEditor EditorTestBase
    30  * @build ReplToolTesting CustomEditor EditorTestBase
    30  * @run testng ExternalEditorTest
    31  * @run testng ExternalEditorTest
    31  */
    32  */
    32 
    33 
    33 import java.io.BufferedWriter;
    34 import java.io.BufferedWriter;
   122     private static boolean isWindows() {
   123     private static boolean isWindows() {
   123         return System.getProperty("os.name").startsWith("Windows");
   124         return System.getProperty("os.name").startsWith("Windows");
   124     }
   125     }
   125 
   126 
   126     @BeforeClass
   127     @BeforeClass
   127     public static void setUp() throws IOException {
   128     public static void setUpExternalEditorTest() throws IOException {
   128         listener = new ServerSocket(0);
   129         listener = new ServerSocket(0);
   129         listener.setSoTimeout(30000);
   130         listener.setSoTimeout(30000);
   130         int localPort = listener.getLocalPort();
   131         int localPort = listener.getLocalPort();
   131 
   132 
   132         executionScript = Paths.get(isWindows() ? "editor.bat" : "editor.sh").toAbsolutePath();
   133         executionScript = Paths.get(isWindows() ? "editor.bat" : "editor.sh").toAbsolutePath();
   191     }
   192     }
   192 
   193 
   193     @Test
   194     @Test
   194     public void setUnknownEditor() {
   195     public void setUnknownEditor() {
   195         test(
   196         test(
   196                 a -> assertCommand(a, "/set editor", "|  /set editor requires a path argument\n"),
   197                 a -> assertCommand(a, "/set editor", "|  The '/set editor' command requires a path argument"),
   197                 a -> assertCommand(a, "/set editor UNKNOWN", "|  Editor set to: UNKNOWN\n"),
   198                 a -> assertCommand(a, "/set editor UNKNOWN", "|  Editor set to: UNKNOWN"),
   198                 a -> assertCommand(a, "int a;", null),
   199                 a -> assertCommand(a, "int a;", null),
   199                 a -> assertCommand(a, "/e 1",
   200                 a -> assertCommand(a, "/ed 1",
   200                         "|  Edit Error: process IO failure: Cannot run program \"UNKNOWN\": error=2, No such file or directory\n")
   201                         "|  Edit Error: process IO failure: Cannot run program \"UNKNOWN\": error=2, No such file or directory")
   201         );
   202         );
   202     }
   203     }
   203 
   204 
   204     @Test(enabled = false)
   205     @Test(enabled = false)
   205     public void testRemoveTempFile() {
   206     public void testRemoveTempFile() {