8056094: [nashorn] tests fail when running via jtreg
Reviewed-by: jlaskey, hannesw
--- 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);