langtools/test/jdk/jshell/ToolReloadTest.java
changeset 44683 610dc2b48954
parent 43759 61535ac55add
--- a/langtools/test/jdk/jshell/ToolReloadTest.java	Tue Apr 11 14:03:16 2017 +0100
+++ b/langtools/test/jdk/jshell/ToolReloadTest.java	Tue Apr 11 17:26:52 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /*
  * @test
  * @key intermittent
- * @bug 8081845 8147898 8143955  8165405
+ * @bug 8081845 8147898 8143955  8165405 8178023
  * @summary Tests for /reload in JShell tool
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -40,6 +40,7 @@
 import java.util.function.Function;
 
 import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
 
 
 @Test
@@ -199,6 +200,27 @@
         );
     }
 
+    public void testEnvBadModule() {
+        test(
+                (a) -> assertVariable(a, "int", "x", "5", "5"),
+                (a) -> assertMethod(a, "int m(int z) { return z * z; }",
+                        "(int)int", "m"),
+                (a) -> assertCommandCheckOutput(a, "/env --add-module unKnown",
+                        s -> {
+                            assertTrue(s.startsWith(
+                                "|  Setting new options and restoring state.\n" +
+                                "|  Restart failed:"));
+                            assertTrue(s.contains("unKnown"),
+                                    "\"unKnown\" missing from: " + s);
+                            assertTrue(s.contains("previous settings"),
+                                    "\"previous settings\" missing from: " + s);
+                                      }),
+                (a) -> evaluateExpression(a, "int", "m(x)", "25"),
+                (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+                (a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
+        );
+    }
+
     public void testReloadExitRestore() {
         test(false, new String[]{"--no-startup"},
                 (a) -> assertVariable(a, "int", "x", "5", "5"),