/hg/rhino-tests: Added new functionality and made this test comp...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Mon Oct 8 02:17:01 PDT 2012
changeset 4f44305e5010 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=4f44305e5010
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Oct 08 11:19:45 2012 +0200
Added new functionality and made this test compatible with JDK 7:
src/org/RhinoTests/CompilableClassTest.java.
diffstat:
ChangeLog | 5 ++
src/org/RhinoTests/CompilableClassTest.java | 54 ++++++++++++++++++++++++++--
2 files changed, 54 insertions(+), 5 deletions(-)
diffs (140 lines):
diff -r f7012c8427c1 -r 4f44305e5010 ChangeLog
--- a/ChangeLog Fri Oct 05 11:49:48 2012 +0200
+++ b/ChangeLog Mon Oct 08 11:19:45 2012 +0200
@@ -1,3 +1,8 @@
+2012-10-08 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/CompilableClassTest.java:
+ Added new functionality, made this test compatible with JDK 7.
+
2012-10-05 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/ScriptExceptionClassTest.java:
diff -r f7012c8427c1 -r 4f44305e5010 src/org/RhinoTests/CompilableClassTest.java
--- a/src/org/RhinoTests/CompilableClassTest.java Fri Oct 05 11:49:48 2012 +0200
+++ b/src/org/RhinoTests/CompilableClassTest.java Mon Oct 08 11:19:45 2012 +0200
@@ -43,6 +43,8 @@
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -50,7 +52,9 @@
import java.lang.reflect.Modifier;
import javax.script.Compilable;
+import javax.script.Invocable;
import javax.script.ScriptEngineManager;
+import javax.script.ScriptEngine;
@@ -91,7 +95,7 @@
* Test for method javax.script.Compilable.getClass().isInstance()
*/
protected void testIsInstance() {
- assertTrue(this.compilableClass.isInstance((new ScriptEngineManager().getEngineByName(Constants.EngineNames.ENGINE_NAME_JavaScript))),
+ assertTrue(this.compilableClass.isInstance((Compilable)(new ScriptEngineManager().getEngineByName(Constants.EngineNames.ENGINE_NAME_JavaScript))),
"Method Compilable.getClass().isInstance() returns wrong value");
}
@@ -270,16 +274,42 @@
* Test for method javax.script.Compilable.getClass().getConstructors()
*/
protected void testGetConstructors() {
+ // map of constructors which should exists
+ Map<String, String> testedConstructors = null;
+ Map<String, String> testedConstructors_jdk6 = new HashMap<String, String>();
+ Map<String, String> testedConstructors_jdk7 = new HashMap<String, String>();
+
+
+ // get the right map containing constructor signatures
+ testedConstructors = getJavaVersion() < 7 ? testedConstructors_jdk6 : testedConstructors_jdk7;
+
+ // get all constructors for this class
Constructor<?>[] constructors = this.compilableClass.getConstructors();
+
+ // basic check for a number of constructors
assertEquals(constructors.length, 0, "no constructors should be set");
+
}
/**
* Test for method javax.script.Compilable.getClass().getDeclaredConstructors()
*/
protected void testGetDeclaredConstructors() {
- Constructor<?>[] constructors = this.compilableClass.getDeclaredConstructors();
- assertEquals(constructors.length, 0, "no constructors should be set");
+ // map of constructors which should exists
+ Map<String, String> testedConstructors = null;
+ Map<String, String> testedConstructors_jdk6 = new HashMap<String, String>();
+ Map<String, String> testedConstructors_jdk7 = new HashMap<String, String>();
+
+
+ // get the right map containing constructor signatures
+ testedConstructors = getJavaVersion() < 7 ? testedConstructors_jdk6 : testedConstructors_jdk7;
+
+ // get all declared constructors for this class
+ Constructor<?>[] declaredConstructors = this.compilableClass.getDeclaredConstructors();
+
+ // basic check for a number of declared constructors
+ assertEquals(declaredConstructors.length, 0, "no constructors should be set");
+
}
/**
@@ -329,10 +359,16 @@
*/
protected void testGetMethods() {
// following methods should be inherited
- final String[] methodsThatShouldExists = {
+ final String[] methodsThatShouldExists_jdk6 = {
"public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.io.Reader) throws javax.script.ScriptException",
"public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.lang.String) throws javax.script.ScriptException",
};
+
+ final String[] methodsThatShouldExists_jdk7 = {
+ "public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.io.Reader) throws javax.script.ScriptException",
+ "public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.lang.String) throws javax.script.ScriptException",
+ };
+
// get all inherited methods
Method[] methods = this.compilableClass.getMethods();
// and transform the array into a list of method names
@@ -340,6 +376,7 @@
for (Method method : methods) {
methodsAsString.add(method.toString());
}
+ String[] methodsThatShouldExists = getJavaVersion() < 7 ? methodsThatShouldExists_jdk6 : methodsThatShouldExists_jdk7;
// check if all required methods really exists
for (String methodThatShouldExists : methodsThatShouldExists) {
assertTrue(methodsAsString.contains(methodThatShouldExists),
@@ -352,10 +389,16 @@
*/
protected void testGetDeclaredMethods() {
// following methods should be declared
- final String[] declaredMethodsThatShouldExists = {
+ final String[] declaredMethodsThatShouldExists_jdk6 = {
"public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.io.Reader) throws javax.script.ScriptException",
"public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.lang.String) throws javax.script.ScriptException",
};
+
+ final String[] declaredMethodsThatShouldExists_jdk7 = {
+ "public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.io.Reader) throws javax.script.ScriptException",
+ "public abstract javax.script.CompiledScript javax.script.Compilable.compile(java.lang.String) throws javax.script.ScriptException",
+ };
+
// get all declared methods
Method[] declaredMethods = this.compilableClass.getDeclaredMethods();
// and transform the array into a list of method names
@@ -363,6 +406,7 @@
for (Method method : declaredMethods) {
methodsAsString.add(method.toString());
}
+ String[] declaredMethodsThatShouldExists = getJavaVersion() < 7 ? declaredMethodsThatShouldExists_jdk6 : declaredMethodsThatShouldExists_jdk7;
// check if all required methods really exists
for (String methodThatShouldExists : declaredMethodsThatShouldExists) {
assertTrue(methodsAsString.contains(methodThatShouldExists),
More information about the distro-pkg-dev
mailing list