/hg/rhino-tests: Made this test compatible with JDK7:
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Mon Sep 3 04:03:12 PDT 2012
changeset 94e0142da92d in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=94e0142da92d
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Sep 03 13:05:48 2012 +0200
Made this test compatible with JDK7:
src/org/RhinoTests/ScriptExceptionClassTest.java.
diffstat:
ChangeLog | 5 +
src/org/RhinoTests/ScriptExceptionClassTest.java | 117 ++++++++++++----------
2 files changed, 68 insertions(+), 54 deletions(-)
diffs (176 lines):
diff -r 9e4f9b602df1 -r 94e0142da92d ChangeLog
--- a/ChangeLog Wed Aug 29 17:32:04 2012 +0200
+++ b/ChangeLog Mon Sep 03 13:05:48 2012 +0200
@@ -1,3 +1,8 @@
+2012-09-03 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/ScriptExceptionClassTest.java:
+ Made this test compatible with JDK7.
+
2012-08-29 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/ScriptEngineClassTest.java:
diff -r 9e4f9b602df1 -r 94e0142da92d src/org/RhinoTests/ScriptExceptionClassTest.java
--- a/src/org/RhinoTests/ScriptExceptionClassTest.java Wed Aug 29 17:32:04 2012 +0200
+++ b/src/org/RhinoTests/ScriptExceptionClassTest.java Mon Sep 03 13:05:48 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;
@@ -217,68 +219,46 @@
* Test for method javax.script.ScriptException.getClass().getConstructors()
*/
protected void testGetConstructors() {
- Constructor[] constructors = this.scriptExceptionClass.getConstructors();
+ // map of constructors which should exists
+ Map<String, String> testedConstructors = new HashMap<String, String>();
+ testedConstructors.put("public javax.script.ScriptException(java.lang.String)", "javax.script.ScriptException");
+ testedConstructors.put("public javax.script.ScriptException(java.lang.Exception)", "javax.script.ScriptException");
+ testedConstructors.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int)", "javax.script.ScriptException");
+ testedConstructors.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)", "javax.script.ScriptException");
+
+ Constructor[] constructors = this.scriptExceptionClass.getDeclaredConstructors();
assertEquals(constructors.length, 4, "only 4 constructors should be set");
- String constructorName;
- String constructorString;
- constructorName = constructors[0].getName();
- constructorString = constructors[0].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.String)",
- "wrong constructor.toString() " + constructorName);
- constructorName = constructors[1].getName();
- constructorString = constructors[1].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.Exception)",
- "wrong constructor.toString() " + constructorName);
- constructorName = constructors[2].getName();
- constructorString = constructors[2].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.String,java.lang.String,int)",
- "wrong constructor.toString() " + constructorName);
- constructorName = constructors[3].getName();
- constructorString = constructors[3].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)",
- "wrong constructor.toString() " + constructorName);
+
+ // check if all constructors exists
+ for (Constructor constructor : constructors) {
+ String constructorName = constructors[0].getName();
+ String constructorString = constructors[0].toString();
+ assertTrue(testedConstructors.containsKey(constructorString), "wrong constructor.toString() " + constructorName);
+ assertEquals(testedConstructors.get(constructorString), constructorName, "wrong constructor name " + constructorName);
+ }
}
/**
* Test for method javax.script.ScriptException.getClass().getDeclaredConstructors()
*/
protected void testGetDeclaredConstructors() {
+ // map of declared constructors which should exists
+ Map<String, String> testedConstructors = new HashMap<String, String>();
+ testedConstructors.put("public javax.script.ScriptException(java.lang.String)", "javax.script.ScriptException");
+ testedConstructors.put("public javax.script.ScriptException(java.lang.Exception)", "javax.script.ScriptException");
+ testedConstructors.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int)", "javax.script.ScriptException");
+ testedConstructors.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)", "javax.script.ScriptException");
+
Constructor[] constructors = this.scriptExceptionClass.getDeclaredConstructors();
assertEquals(constructors.length, 4, "only 4 constructors should be set");
- String constructorName;
- String constructorString;
- constructorName = constructors[0].getName();
- constructorString = constructors[0].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.String)",
- "wrong constructor.toString() " + constructorName);
- constructorName = constructors[1].getName();
- constructorString = constructors[1].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.Exception)",
- "wrong constructor.toString() " + constructorName);
- constructorName = constructors[2].getName();
- constructorString = constructors[2].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.String,java.lang.String,int)",
- "wrong constructor.toString() " + constructorName);
- constructorName = constructors[3].getName();
- constructorString = constructors[3].toString();
- assertEquals(constructorName, "javax.script.ScriptException",
- "wrong constructor name " + constructorName);
- assertEquals(constructorString, "public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)",
- "wrong constructor.toString() " + constructorName);
+
+ // check if all constructors exists
+ for (Constructor constructor : constructors) {
+ String constructorName = constructors[0].getName();
+ String constructorString = constructors[0].toString();
+ assertTrue(testedConstructors.containsKey(constructorString), "wrong constructor.toString() " + constructorName);
+ assertEquals(testedConstructors.get(constructorString), constructorName, "wrong constructor name " + constructorName);
+ }
}
/**
@@ -331,7 +311,7 @@
*/
protected void testGetMethods() {
// following methods should be inherited
- final String[] methodsThatShouldExists = {
+ final String[] methodsThatShouldExists_jdk6 = {
"public boolean java.lang.Object.equals(java.lang.Object)",
"public final native java.lang.Class java.lang.Object.getClass()",
"public final native void java.lang.Object.notify()",
@@ -355,6 +335,34 @@
"public void java.lang.Throwable.printStackTrace(java.io.PrintWriter)",
"public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[])",
};
+
+ final String[] methodsThatShouldExists_jdk7 = {
+ "public boolean java.lang.Object.equals(java.lang.Object)",
+ "public final native java.lang.Class java.lang.Object.getClass()",
+ "public final native void java.lang.Object.notify()",
+ "public final native void java.lang.Object.notifyAll()",
+ "public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException",
+ "public final void java.lang.Object.wait() throws java.lang.InterruptedException",
+ "public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException",
+ "public int javax.script.ScriptException.getColumnNumber()",
+ "public int javax.script.ScriptException.getLineNumber()",
+ "public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()",
+ "public java.lang.String java.lang.Throwable.getLocalizedMessage()",
+ "public java.lang.String java.lang.Throwable.toString()",
+ "public java.lang.String javax.script.ScriptException.getFileName()",
+ "public java.lang.String javax.script.ScriptException.getMessage()",
+ "public synchronized java.lang.Throwable java.lang.Throwable.getCause()",
+ "public native int java.lang.Object.hashCode()",
+ "public synchronized java.lang.Throwable java.lang.Throwable.initCause(java.lang.Throwable)",
+ "public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace()",
+ "public void java.lang.Throwable.printStackTrace()",
+ "public void java.lang.Throwable.printStackTrace(java.io.PrintStream)",
+ "public void java.lang.Throwable.printStackTrace(java.io.PrintWriter)",
+ "public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[])",
+ "public final synchronized void java.lang.Throwable.addSuppressed(java.lang.Throwable)",
+ "public final synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed()",
+ };
+
// get all inherited methods
Method[] methods = this.scriptExceptionClass.getMethods();
// and transform the array into a list of method names
@@ -362,6 +370,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),
More information about the distro-pkg-dev
mailing list