8139872: JShell tests: EditorPadTest failing on headless
authorrfield
Fri, 27 May 2016 14:45:20 -0700
changeset 38618 f14423456446
parent 38617 d93a7f64e231
child 38619 27c0007bb28d
8139872: JShell tests: EditorPadTest failing on headless Reviewed-by: vromero
langtools/test/jdk/jshell/EditorPadTest.java
langtools/test/jdk/jshell/EditorTestBase.java
--- a/langtools/test/jdk/jshell/EditorPadTest.java	Fri May 27 13:06:58 2016 -0700
+++ b/langtools/test/jdk/jshell/EditorPadTest.java	Fri May 27 14:45:20 2016 -0700
@@ -23,9 +23,10 @@
 
 /*
  * @test
+ * @bug 8139872
  * @summary Testing built-in editor.
- * @ignore 8139872
- * @modules jdk.jshell/jdk.internal.jshell.tool
+ * @modules java.desktop/java.awt
+ *          jdk.jshell/jdk.internal.jshell.tool
  * @build ReplToolTesting EditorTestBase
  * @run testng EditorPadTest
  */
@@ -35,6 +36,7 @@
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
 import java.awt.Point;
 import java.awt.Robot;
 import java.awt.event.InputEvent;
@@ -67,14 +69,24 @@
     private static JButton accept = null;
     private static JButton exit = null;
 
+    // Do not actually run if we are headless
+    @Override
+    public void testEditor(boolean defaultStartup, String[] args, ReplTest... tests) {
+        if (!GraphicsEnvironment.isHeadless()) {
+            test(defaultStartup, args, tests);
+        }
+    }
+
     @BeforeClass
     public static void setUpEditorPadTest() {
-        try {
-            robot = new Robot();
-            robot.setAutoWaitForIdle(true);
-            robot.setAutoDelay(DELAY);
-        } catch (AWTException e) {
-            throw new ExceptionInInitializerError(e);
+        if (!GraphicsEnvironment.isHeadless()) {
+            try {
+                robot = new Robot();
+                robot.setAutoWaitForIdle(true);
+                robot.setAutoDelay(DELAY);
+            } catch (AWTException e) {
+                throw new ExceptionInInitializerError(e);
+            }
         }
     }
 
@@ -123,7 +135,7 @@
     @Test
     public void testShuttingDown() {
         testEditor(
-                (a) -> assertEditOutput(a, "/e", "", this::shutdownEditor)
+                (a) -> assertEditOutput(a, "/ed", "", this::shutdownEditor)
         );
     }
 
--- a/langtools/test/jdk/jshell/EditorTestBase.java	Fri May 27 13:06:58 2016 -0700
+++ b/langtools/test/jdk/jshell/EditorTestBase.java	Fri May 27 14:45:20 2016 -0700
@@ -73,11 +73,9 @@
         for (String edit : new String[] {"/ed", "/edit"}) {
             test(new String[]{"-nostartup"},
                     a -> assertCommandOutputStartsWith(a, edit + " 1",
-                            "|  No definition or id found named: 1"),
-                    a -> assertCommandOutputStartsWith(a, edit + " -1",
-                            "|  No definition or id found named: -1"),
+                            "|  No such snippet: 1"),
                     a -> assertCommandOutputStartsWith(a, edit + " unknown",
-                            "|  No definition or id found named: unknown")
+                            "|  No such snippet: unknown")
             );
         }
     }