/hg/rhino-tests: Make the test src/org/RhinoTests/ScriptExceptio...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Fri Oct 5 02:47:28 PDT 2012
changeset f7012c8427c1 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=f7012c8427c1
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Oct 05 11:49:48 2012 +0200
Make the test src/org/RhinoTests/ScriptExceptionClassTest.java compatible with JDK 7.
diffstat:
ChangeLog | 5 +
src/org/RhinoTests/ScriptExceptionClassTest.java | 85 +++++++++++++++++------
2 files changed, 66 insertions(+), 24 deletions(-)
diffs (163 lines):
diff -r 1469d167df45 -r f7012c8427c1 ChangeLog
--- a/ChangeLog Thu Oct 04 11:12:33 2012 +0200
+++ b/ChangeLog Fri Oct 05 11:49:48 2012 +0200
@@ -1,3 +1,8 @@
+2012-10-05 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/ScriptExceptionClassTest.java:
+ Make this test compatible with JDK 7.
+
2012-10-04 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/BindingsClassTest.java:
diff -r 1469d167df45 -r f7012c8427c1 src/org/RhinoTests/ScriptExceptionClassTest.java
--- a/src/org/RhinoTests/ScriptExceptionClassTest.java Thu Oct 04 11:12:33 2012 +0200
+++ b/src/org/RhinoTests/ScriptExceptionClassTest.java Fri Oct 05 11:49:48 2012 +0200
@@ -263,7 +263,7 @@
* Test for method javax.script.ScriptException.getClass().getSuperclass()
*/
protected void testGetSuperclass() {
- Class superClass = this.scriptExceptionClass.getSuperclass();
+ Class<?> superClass = this.scriptExceptionClass.getSuperclass();
String superClassName = superClass.getName();
assertEquals(superClassName, "java.lang.Exception",
"Method ScriptException.getClass().getSuperclass() returns wrong value " + superClassName);
@@ -274,13 +274,27 @@
*/
protected void testGetConstructors() {
// 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");
+ Map<String, String> testedConstructors = null;
+ Map<String, String> testedConstructors_jdk6 = new HashMap<String, String>();
+ Map<String, String> testedConstructors_jdk7 = new HashMap<String, String>();
- Constructor<?>[] constructors = this.scriptExceptionClass.getDeclaredConstructors();
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.String)", "javax.script.ScriptException");
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.Exception)", "javax.script.ScriptException");
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int)", "javax.script.ScriptException");
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)", "javax.script.ScriptException");
+
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)", "javax.script.ScriptException");
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int)", "javax.script.ScriptException");
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.Exception)", "javax.script.ScriptException");
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.String)", "javax.script.ScriptException");
+
+ // get the right map containing constructor signatures
+ testedConstructors = getJavaVersion() < 7 ? testedConstructors_jdk6 : testedConstructors_jdk7;
+
+ // get all constructors for this class
+ Constructor<?>[] constructors = this.scriptExceptionClass.getConstructors();
+
+ // basic check for a number of constructors
assertEquals(constructors.length, 4, "only 4 constructors should be set");
// check if all constructors exists
@@ -296,20 +310,34 @@
* 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");
+ // 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>();
- Constructor[] constructors = this.scriptExceptionClass.getDeclaredConstructors();
- assertEquals(constructors.length, 4, "only 4 constructors should be set");
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.String)", "javax.script.ScriptException");
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.Exception)", "javax.script.ScriptException");
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int)", "javax.script.ScriptException");
+ testedConstructors_jdk6.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)", "javax.script.ScriptException");
- // check if all constructors exists
- for (Constructor constructor : constructors) {
- String constructorName = constructors[0].getName();
- String constructorString = constructors[0].toString();
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int,int)", "javax.script.ScriptException");
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.String,java.lang.String,int)", "javax.script.ScriptException");
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.Exception)", "javax.script.ScriptException");
+ testedConstructors_jdk7.put("public javax.script.ScriptException(java.lang.String)", "javax.script.ScriptException");
+
+ // get the right map containing constructor signatures
+ testedConstructors = getJavaVersion() < 7 ? testedConstructors_jdk6 : testedConstructors_jdk7;
+
+ // get all declared constructors for this class
+ Constructor<?>[] declaredConstructors = this.scriptExceptionClass.getDeclaredConstructors();
+
+ // basic check for a number of declared constructors
+ assertEquals(declaredConstructors.length, 4, "only 4 constructors should be set");
+
+ // check if all declared constructors exists
+ for (Constructor<?> declaredConstructor : declaredConstructors) {
+ String constructorName = declaredConstructor.getName();
+ String constructorString = declaredConstructor.toString();
assertTrue(testedConstructors.containsKey(constructorString), "wrong constructor.toString() " + constructorName);
assertEquals(testedConstructors.get(constructorString), constructorName, "wrong constructor name " + constructorName);
}
@@ -396,6 +424,8 @@
"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 synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed()",
+ "public final synchronized void java.lang.Throwable.addSuppressed(java.lang.Throwable)",
"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()",
@@ -405,16 +435,14 @@
"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 native int java.lang.Object.hashCode()",
+ "public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace()",
"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
@@ -437,12 +465,20 @@
*/
protected void testGetDeclaredMethods() {
// following methods should be declared
- final String[] declaredMethodsThatShouldExists = {
+ final String[] declaredMethodsThatShouldExists_jdk6 = {
"public int javax.script.ScriptException.getColumnNumber()",
"public int javax.script.ScriptException.getLineNumber()",
"public java.lang.String javax.script.ScriptException.getFileName()",
"public java.lang.String javax.script.ScriptException.getMessage()",
};
+
+ final String[] declaredMethodsThatShouldExists_jdk7 = {
+ "public int javax.script.ScriptException.getColumnNumber()",
+ "public int javax.script.ScriptException.getLineNumber()",
+ "public java.lang.String javax.script.ScriptException.getFileName()",
+ "public java.lang.String javax.script.ScriptException.getMessage()",
+ };
+
// get all declared methods
Method[] declaredMethods = this.scriptExceptionClass.getDeclaredMethods();
// and transform the array into a list of method names
@@ -450,6 +486,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