mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 03:54:33 +02:00
6705893: javax.script tests should not require a js engine on OpenJDK
Fixed the tests to pass with open JDK. Reviewed-by: darcy
This commit is contained in:
parent
36a04a49a7
commit
f1f86e9fa2
24 changed files with 207 additions and 41 deletions
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6346734
|
* @bug 6346734 6705893
|
||||||
* @summary We do *not* support E4X (ECMAScript for XML) in our
|
* @summary We do *not* support E4X (ECMAScript for XML) in our
|
||||||
* implementation. We want to throw error on XML literals
|
* implementation. We want to throw error on XML literals
|
||||||
* as early as possible rather than at "runtime" - i.e., when
|
* as early as possible rather than at "runtime" - i.e., when
|
||||||
|
@ -37,9 +37,10 @@ public class E4XErrorTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
ScriptEngine jsengine = manager.getEngineByName("js");
|
ScriptEngine jsengine = Helper.getJsEngine(manager);
|
||||||
if (jsengine == null) {
|
if (jsengine == null) {
|
||||||
throw new RuntimeException("no js engine found");
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The test below depends on the error message content
|
// The test below depends on the error message content
|
||||||
|
|
41
jdk/test/javax/script/Helper.java
Normal file
41
jdk/test/javax/script/Helper.java
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
import javax.script.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to consolidate testing requirements for a js engine.
|
||||||
|
* A js engine is required as part of Sun's product JDK.
|
||||||
|
*/
|
||||||
|
public class Helper {
|
||||||
|
private Helper() {}; // Don't instantiate
|
||||||
|
|
||||||
|
public static ScriptEngine getJsEngine(ScriptEngineManager m) {
|
||||||
|
ScriptEngine e = m.getEngineByName("js");
|
||||||
|
if (e == null &&
|
||||||
|
System.getProperty("java.runtime.name").startsWith("Java(TM)")) {
|
||||||
|
// A js engine is requied for Sun's product JDK
|
||||||
|
throw new RuntimeException("no js engine found");
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6346733
|
* @bug 6346733 6705893
|
||||||
* @summary Verify that independent Bindings instances don't
|
* @summary Verify that independent Bindings instances don't
|
||||||
* get affected by default scope assignments. Also, verify
|
* get affected by default scope assignments. Also, verify
|
||||||
* that script globals can be created and accessed from Java
|
* that script globals can be created and accessed from Java
|
||||||
|
@ -36,9 +36,10 @@ public class JavaScriptScopeTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
ScriptEngine jsengine = manager.getEngineByName("js");
|
ScriptEngine jsengine = Helper.getJsEngine(manager);
|
||||||
if (jsengine == null) {
|
if (jsengine == null) {
|
||||||
throw new RuntimeException("no js engine found");
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
jsengine.eval("var v = 'hello';");
|
jsengine.eval("var v = 'hello';");
|
||||||
// Create a new scope
|
// Create a new scope
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6346732
|
* @bug 6346732 6705893
|
||||||
* @summary should be able to assign null and undefined
|
* @summary should be able to assign null and undefined
|
||||||
* value to JavaScript global variables.
|
* value to JavaScript global variables.
|
||||||
*/
|
*/
|
||||||
|
@ -34,9 +34,10 @@ public class NullUndefinedVarTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
ScriptEngine jsengine = manager.getEngineByName("js");
|
ScriptEngine jsengine = Helper.getJsEngine(manager);
|
||||||
if (jsengine == null) {
|
if (jsengine == null) {
|
||||||
throw new RuntimeException("no js engine found");
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
jsengine.eval("var n = null; " +
|
jsengine.eval("var n = null; " +
|
||||||
"if (n !== null) throw 'expecting null';" +
|
"if (n !== null) throw 'expecting null';" +
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6398614
|
* @bug 6398614 6705893
|
||||||
* @summary Create a user defined ScriptContext and check
|
* @summary Create a user defined ScriptContext and check
|
||||||
* that script can access variables from non-standard scopes
|
* that script can access variables from non-standard scopes
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +35,11 @@ public class PluggableContextTest {
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptContext ctx = new MyContext();
|
ScriptContext ctx = new MyContext();
|
||||||
ctx.setAttribute("x", "hello", MyContext.APP_SCOPE);
|
ctx.setAttribute("x", "hello", MyContext.APP_SCOPE);
|
||||||
ScriptEngine e = m.getEngineByName("js");
|
ScriptEngine e = Helper.getJsEngine(m);
|
||||||
|
if (e == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// the following reference to 'x' throws exception
|
// the following reference to 'x' throws exception
|
||||||
// if APP_SCOPE is not searched.
|
// if APP_SCOPE is not searched.
|
||||||
e.eval("x", ctx);
|
e.eval("x", ctx);
|
||||||
|
|
|
@ -35,9 +35,10 @@ public class ProviderTest {
|
||||||
if (se == null) {
|
if (se == null) {
|
||||||
throw new RuntimeException("can't locate dummy engine");
|
throw new RuntimeException("can't locate dummy engine");
|
||||||
}
|
}
|
||||||
se = manager.getEngineByName("js");
|
se = Helper.getJsEngine(manager);
|
||||||
if (se == null) {
|
if (se == null) {
|
||||||
throw new RuntimeException("can't locate JavaScript engine");
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6474943
|
* @bug 6474943 6705893
|
||||||
* @summary Test that Rhion exception messages are
|
* @summary Test that Rhino exception messages are
|
||||||
* available from ScriptException.
|
* available from ScriptException.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -36,7 +36,11 @@ public class RhinoExceptionTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptEngine engine = m.getEngineByName("js");
|
ScriptEngine engine = Helper.getJsEngine(m);
|
||||||
|
if (engine == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
engine.put("msg", ERROR_MSG);
|
engine.put("msg", ERROR_MSG);
|
||||||
try {
|
try {
|
||||||
engine.eval("throw new Error(msg);");
|
engine.eval("throw new Error(msg);");
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6249843
|
* @bug 6249843 6705893
|
||||||
* @summary Create JavaScript engine and execute a simple script.
|
* @summary Create JavaScript engine and execute a simple script.
|
||||||
* Tests script engine discovery mechanism.
|
* Tests script engine discovery mechanism.
|
||||||
*/
|
*/
|
||||||
|
@ -35,9 +35,10 @@ public class Test1 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("\nTest1\n");
|
System.out.println("\nTest1\n");
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
ScriptEngine jsengine = manager.getEngineByName("js");
|
ScriptEngine jsengine = Helper.getJsEngine(manager);
|
||||||
if (jsengine == null) {
|
if (jsengine == null) {
|
||||||
throw new RuntimeException("no js engine found");
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
jsengine.eval(new FileReader(
|
jsengine.eval(new FileReader(
|
||||||
new File(System.getProperty("test.src", "."), "Test1.js")));
|
new File(System.getProperty("test.src", "."), "Test1.js")));
|
||||||
|
|
|
@ -50,7 +50,11 @@ public class Test2 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("\nTest2\n");
|
System.out.println("\nTest2\n");
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptEngine eng = m.getEngineByName("js");
|
ScriptEngine eng = Helper.getJsEngine(m);
|
||||||
|
if (eng == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
eng.put("Testobj", new Testobj("Hello World"));
|
eng.put("Testobj", new Testobj("Hello World"));
|
||||||
eng.eval(new FileReader(
|
eng.eval(new FileReader(
|
||||||
new File(System.getProperty("test.src", "."), "Test2.js")));
|
new File(System.getProperty("test.src", "."), "Test2.js")));
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6249843
|
* @bug 6249843 6705893
|
||||||
* @summary Test engine and global scopes
|
* @summary Test engine and global scopes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,7 +38,11 @@ public class Test3 {
|
||||||
final Reader reader = new FileReader(
|
final Reader reader = new FileReader(
|
||||||
new File(System.getProperty("test.src", "."), "Test3.js"));
|
new File(System.getProperty("test.src", "."), "Test3.js"));
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
final ScriptEngine engine = m.getEngineByName("js");
|
final ScriptEngine engine = Helper.getJsEngine(m);
|
||||||
|
if (engine == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Bindings en = new SimpleBindings();
|
Bindings en = new SimpleBindings();
|
||||||
engine.setBindings(en, ScriptContext.ENGINE_SCOPE);
|
engine.setBindings(en, ScriptContext.ENGINE_SCOPE);
|
||||||
en.put("key", "engine value");
|
en.put("key", "engine value");
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6249843
|
* @bug 6249843 6705893
|
||||||
* @summary Test script functions implementing Java interface
|
* @summary Test script functions implementing Java interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -34,7 +34,11 @@ public class Test4 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("\nTest4\n");
|
System.out.println("\nTest4\n");
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptEngine e = m.getEngineByName("js");
|
ScriptEngine e = Helper.getJsEngine(m);
|
||||||
|
if (e == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
e.eval(new FileReader(
|
e.eval(new FileReader(
|
||||||
new File(System.getProperty("test.src", "."), "Test4.js")));
|
new File(System.getProperty("test.src", "."), "Test4.js")));
|
||||||
Invocable inv = (Invocable)e;
|
Invocable inv = (Invocable)e;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6249843
|
* @bug 6249843 6705893
|
||||||
* @summary Tests engine, global scopes and scope hiding.
|
* @summary Tests engine, global scopes and scope hiding.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -34,7 +34,11 @@ public class Test5 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("\nTest5\n");
|
System.out.println("\nTest5\n");
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptEngine engine = m.getEngineByName("js");
|
ScriptEngine engine = Helper.getJsEngine(m);
|
||||||
|
if (engine == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Bindings g = new SimpleBindings();
|
Bindings g = new SimpleBindings();
|
||||||
Bindings e = new SimpleBindings();
|
Bindings e = new SimpleBindings();
|
||||||
g.put("key", "value in global");
|
g.put("key", "value in global");
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6249843
|
* @bug 6249843 6705893
|
||||||
* @summary Test basic script compilation. Value eval'ed from
|
* @summary Test basic script compilation. Value eval'ed from
|
||||||
* compiled and interpreted scripts should be same.
|
* compiled and interpreted scripts should be same.
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +35,11 @@ public class Test6 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("\nTest6\n");
|
System.out.println("\nTest6\n");
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptEngine engine = m.getEngineByName("js");
|
ScriptEngine engine = Helper.getJsEngine(m);
|
||||||
|
if (engine == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Reader reader = new FileReader(
|
Reader reader = new FileReader(
|
||||||
new File(System.getProperty("test.src", "."), "Test6.js"));
|
new File(System.getProperty("test.src", "."), "Test6.js"));
|
||||||
engine.eval(reader);
|
engine.eval(reader);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6249843
|
* @bug 6249843 6705893
|
||||||
* @summary Tests importPackage and java access in script
|
* @summary Tests importPackage and java access in script
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,7 +37,11 @@ public class Test7 {
|
||||||
new File(System.getProperty("test.src", "."), "Test7.js");
|
new File(System.getProperty("test.src", "."), "Test7.js");
|
||||||
Reader r = new FileReader(file);
|
Reader r = new FileReader(file);
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptEngine eng = m.getEngineByName("js");
|
ScriptEngine eng = Helper.getJsEngine(m);
|
||||||
|
if (eng == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
eng.put("filename", file.getAbsolutePath());
|
eng.put("filename", file.getAbsolutePath());
|
||||||
eng.eval(r);
|
eng.eval(r);
|
||||||
String str = (String)eng.get("firstLine");
|
String str = (String)eng.get("firstLine");
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6249843
|
* @bug 6249843 6705893
|
||||||
* @summary Test invoking script function or method from Java
|
* @summary Test invoking script function or method from Java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -34,7 +34,11 @@ public class Test8 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("\nTest8\n");
|
System.out.println("\nTest8\n");
|
||||||
ScriptEngineManager m = new ScriptEngineManager();
|
ScriptEngineManager m = new ScriptEngineManager();
|
||||||
ScriptEngine e = m.getEngineByName("js");
|
ScriptEngine e = Helper.getJsEngine(m);
|
||||||
|
if (e == null) {
|
||||||
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
e.eval(new FileReader(
|
e.eval(new FileReader(
|
||||||
new File(System.getProperty("test.src", "."), "Test8.js")));
|
new File(System.getProperty("test.src", "."), "Test8.js")));
|
||||||
Invocable inv = (Invocable)e;
|
Invocable inv = (Invocable)e;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6346729
|
* @bug 6346729 6705893
|
||||||
* @summary Create JavaScript engine and check language and engine version
|
* @summary Create JavaScript engine and check language and engine version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,9 +37,10 @@ public class VersionTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
ScriptEngine jsengine = manager.getEngineByName("js");
|
ScriptEngine jsengine = Helper.getJsEngine(manager);
|
||||||
if (jsengine == null) {
|
if (jsengine == null) {
|
||||||
throw new RuntimeException("no js engine found");
|
System.out.println("Warning: No js engine found; test vacuously passes.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
String langVersion = jsengine.getFactory().getLanguageVersion();
|
String langVersion = jsengine.getFactory().getLanguageVersion();
|
||||||
if (! langVersion.equals(JS_LANG_VERSION)) {
|
if (! langVersion.equals(JS_LANG_VERSION)) {
|
||||||
|
|
45
jdk/test/sun/tools/jrunscript/CheckEngine.java
Normal file
45
jdk/test/sun/tools/jrunscript/CheckEngine.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.script.*;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the JDK being tested is <b>not</b> a Sun product JDK and a js
|
||||||
|
* engine is not present, return an exit code of 2 to indicate that
|
||||||
|
* the jrunscript tests which assume a js engine can be vacuously
|
||||||
|
* passed.
|
||||||
|
*/
|
||||||
|
public class CheckEngine {
|
||||||
|
public static void main(String... args) {
|
||||||
|
int exitCode = 0;
|
||||||
|
ScriptEngine engine =
|
||||||
|
(new ScriptEngineManager()).getEngineByName("js");
|
||||||
|
|
||||||
|
if (engine == null &&
|
||||||
|
!(System.getProperty("java.runtime.name").startsWith("Java(TM)"))) {
|
||||||
|
exitCode = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.exit(exitCode);
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,4 +52,5 @@ setup() {
|
||||||
|
|
||||||
JRUNSCRIPT="${TESTJAVA}/bin/jrunscript"
|
JRUNSCRIPT="${TESTJAVA}/bin/jrunscript"
|
||||||
JAVAC="${TESTJAVA}/bin/javac"
|
JAVAC="${TESTJAVA}/bin/javac"
|
||||||
|
JAVA="${TESTJAVA}/bin/java"
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,19 @@
|
||||||
|
|
||||||
|
|
||||||
# @test
|
# @test
|
||||||
# @bug 6265810
|
# @bug 6265810 6705893
|
||||||
|
# @build CheckEngine
|
||||||
# @run shell jrunscript-DTest.sh
|
# @run shell jrunscript-DTest.sh
|
||||||
# @summary Test that output of 'jrunscript -D'
|
# @summary Test that output of 'jrunscript -D'
|
||||||
|
|
||||||
. ${TESTSRC-.}/common.sh
|
. ${TESTSRC-.}/common.sh
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||||
|
if [ $? -eq 2 ]; then
|
||||||
|
echo "No js engine found and engine not required; test vacuously passes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# test whether value specifieD by -D option is passed
|
# test whether value specifieD by -D option is passed
|
||||||
# to script as java.lang.System property. sysProps is
|
# to script as java.lang.System property. sysProps is
|
||||||
|
|
|
@ -25,13 +25,19 @@
|
||||||
|
|
||||||
|
|
||||||
# @test
|
# @test
|
||||||
# @bug 6265810
|
# @bug 6265810 6705893
|
||||||
|
# @build CheckEngine
|
||||||
# @run shell jrunscript-argsTest.sh
|
# @run shell jrunscript-argsTest.sh
|
||||||
# @summary Test passing of script arguments from command line
|
# @summary Test passing of script arguments from command line
|
||||||
|
|
||||||
. ${TESTSRC-.}/common.sh
|
. ${TESTSRC-.}/common.sh
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||||
|
if [ $? -eq 2 ]; then
|
||||||
|
echo "No js engine found and engine not required; test vacuously passes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# we check whether "excess" args are passed as script arguments
|
# we check whether "excess" args are passed as script arguments
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,19 @@
|
||||||
|
|
||||||
|
|
||||||
# @test
|
# @test
|
||||||
# @bug 6265810
|
# @bug 6265810 6705893
|
||||||
|
# @build CheckEngine
|
||||||
# @run shell jrunscript-cpTest.sh
|
# @run shell jrunscript-cpTest.sh
|
||||||
# @summary Test -cp option to set classpath
|
# @summary Test -cp option to set classpath
|
||||||
|
|
||||||
. ${TESTSRC-.}/common.sh
|
. ${TESTSRC-.}/common.sh
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||||
|
if [ $? -eq 2 ]; then
|
||||||
|
echo "No js engine found and engine not required; test vacuously passes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f Hello.class
|
rm -f Hello.class
|
||||||
${JAVAC} ${TESTSRC}/Hello.java -d .
|
${JAVAC} ${TESTSRC}/Hello.java -d .
|
||||||
|
|
|
@ -25,13 +25,19 @@
|
||||||
|
|
||||||
|
|
||||||
# @test
|
# @test
|
||||||
# @bug 6265810
|
# @bug 6265810 6705893
|
||||||
|
# @build CheckEngine
|
||||||
# @run shell jrunscript-eTest.sh
|
# @run shell jrunscript-eTest.sh
|
||||||
# @summary Test that output of 'jrunscript -e' matches the dash-e.out file
|
# @summary Test that output of 'jrunscript -e' matches the dash-e.out file
|
||||||
|
|
||||||
. ${TESTSRC-.}/common.sh
|
. ${TESTSRC-.}/common.sh
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||||
|
if [ $? -eq 2 ]; then
|
||||||
|
echo "No js engine found and engine not required; test vacuously passes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f jrunscript-eTest.out 2>/dev/null
|
rm -f jrunscript-eTest.out 2>/dev/null
|
||||||
${JRUNSCRIPT} -e "println('hello')" > jrunscript-eTest.out 2>&1
|
${JRUNSCRIPT} -e "println('hello')" > jrunscript-eTest.out 2>&1
|
||||||
|
|
|
@ -25,13 +25,19 @@
|
||||||
|
|
||||||
|
|
||||||
# @test
|
# @test
|
||||||
# @bug 6265810
|
# @bug 6265810 6705893
|
||||||
|
# @build CheckEngine
|
||||||
# @run shell jrunscript-fTest.sh
|
# @run shell jrunscript-fTest.sh
|
||||||
# @summary Test that output of 'jrunscript -f' matches the dash-f.out file
|
# @summary Test that output of 'jrunscript -f' matches the dash-f.out file
|
||||||
|
|
||||||
. ${TESTSRC-.}/common.sh
|
. ${TESTSRC-.}/common.sh
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||||
|
if [ $? -eq 2 ]; then
|
||||||
|
echo "No js engine found and engine not required; test vacuously passes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f jrunscript-fTest.out 2>/dev/null
|
rm -f jrunscript-fTest.out 2>/dev/null
|
||||||
${JRUNSCRIPT} -f ${TESTSRC}/hello.js > jrunscript-fTest.out 2>&1
|
${JRUNSCRIPT} -f ${TESTSRC}/hello.js > jrunscript-fTest.out 2>&1
|
||||||
|
|
|
@ -25,13 +25,19 @@
|
||||||
|
|
||||||
|
|
||||||
# @test
|
# @test
|
||||||
# @bug 6265810
|
# @bug 6265810 6705893
|
||||||
|
# @build CheckEngine
|
||||||
# @run shell jrunscriptTest.sh
|
# @run shell jrunscriptTest.sh
|
||||||
# @summary Test that output of 'jrunscript' interactive matches the repl.out file
|
# @summary Test that output of 'jrunscript' interactive matches the repl.out file
|
||||||
|
|
||||||
. ${TESTSRC-.}/common.sh
|
. ${TESTSRC-.}/common.sh
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||||
|
if [ $? -eq 2 ]; then
|
||||||
|
echo "No js engine found and engine not required; test vacuously passes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f jrunscriptTest.out 2>/dev/null
|
rm -f jrunscriptTest.out 2>/dev/null
|
||||||
${JRUNSCRIPT} > jrunscriptTest.out 2>&1 <<EOF
|
${JRUNSCRIPT} > jrunscriptTest.out 2>&1 <<EOF
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue