changeset 3446:8dcedce2fbf6

8139872: JShell tests: EditorPadTest failing on headless Reviewed-by: vromero
author rfield
date Fri, 27 May 2016 14:45:20 -0700
parents 6feb92d958ee
children 2fa4e0cc6e60
files test/jdk/jshell/EditorPadTest.java test/jdk/jshell/EditorTestBase.java
diffstat 2 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/jshell/EditorPadTest.java	Fri May 27 13:06:58 2016 -0700
+++ b/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/test/jdk/jshell/EditorTestBase.java	Fri May 27 13:06:58 2016 -0700
+++ b/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")
             );
         }
     }