changeset 26251:b93e4bd0c5de

8056094: [nashorn] tests fail when running via jtreg Reviewed-by: jlaskey, hannesw
author sundar
date Tue, 26 Aug 2014 22:57:24 +0530
parents 84bbd0e8b2b2
children 5a4c8ce0358f
files nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
diffstat 2 files changed, 44 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java	Tue Aug 26 15:52:55 2014 +0200
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java	Tue Aug 26 22:57:24 2014 +0530
@@ -271,6 +271,11 @@
 
     @Test
     public static void proxyStaticAccessCheckTest() throws ScriptException {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
         final ScriptEngineManager m = new ScriptEngineManager();
         final ScriptEngine e = m.getEngineByName("nashorn");
         final Runnable r = (Runnable)Proxy.newProxyInstance(
@@ -297,4 +302,43 @@
             }
         }
     }
+
+
+    @Test
+    public void nashornConfigSecurityTest() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine(new ClassFilter() {
+               @Override
+               public boolean exposeToScripts(final String name) {
+                   return true;
+               }
+            });
+            fail("SecurityException should have been thrown");
+        } catch (final SecurityException exp) {}
+    }
+
+    @Test
+    public void nashornConfigSecurityTest2() {
+        if (System.getSecurityManager() == null) {
+            // pass vacuously
+            return;
+        }
+
+        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+        try {
+            fac.getScriptEngine(new String[0], null, new ClassFilter() {
+               @Override
+               public boolean exposeToScripts(final String name) {
+                   return true;
+               }
+            });
+            fail("SecurityException should have been thrown");
+        } catch (final SecurityException exp) {}
+    }
 }
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Tue Aug 26 15:52:55 2014 +0200
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Tue Aug 26 22:57:24 2014 +0530
@@ -629,34 +629,6 @@
         assertEquals(enumerable, Boolean.FALSE);
     }
 
-    @Test
-    public void nashornConfigSecurityTest() {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine(new ClassFilter() {
-               @Override
-               public boolean exposeToScripts(final String name) {
-                   return true;
-               }
-            });
-            fail("SecurityException should have been thrown");
-        } catch (final SecurityException exp) {}
-    }
-
-    @Test
-    public void nashornConfigSecurityTest2() {
-        final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-        try {
-            fac.getScriptEngine(new String[0], null, new ClassFilter() {
-               @Override
-               public boolean exposeToScripts(final String name) {
-                   return true;
-               }
-            });
-            fail("SecurityException should have been thrown");
-        } catch (final SecurityException exp) {}
-    }
-
     private static void checkProperty(final ScriptEngine e, final String name)
         throws ScriptException {
         final String value = System.getProperty(name);