/hg/rhino-tests: Added three new tests into the CompiledScriptCl...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Wed Feb 20 00:36:37 PST 2013
changeset cd9b21a17f40 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=cd9b21a17f40
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Wed Feb 20 09:39:41 2013 +0100
Added three new tests into the CompiledScriptClassTest:
testGetCanonicalName(), testGetConstructor() and testGetDeclaredConstructor().
diffstat:
ChangeLog | 6 +
src/org/RhinoTests/CompiledScriptClassTest.java | 77 ++++++++++++++++++++++++-
2 files changed, 82 insertions(+), 1 deletions(-)
diffs (122 lines):
diff -r c93404c83a48 -r cd9b21a17f40 ChangeLog
--- a/ChangeLog Tue Feb 19 09:32:33 2013 +0100
+++ b/ChangeLog Wed Feb 20 09:39:41 2013 +0100
@@ -1,3 +1,9 @@
+2013-02-20 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/CompiledScriptClassTest.java:
+ Added three new tests into the CompiledScriptClassTest:
+ testGetCanonicalName(), testGetConstructor() and testGetDeclaredConstructor().
+
2013-02-19 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/CompilableClassTest.java:
diff -r c93404c83a48 -r cd9b21a17f40 src/org/RhinoTests/CompiledScriptClassTest.java
--- a/src/org/RhinoTests/CompiledScriptClassTest.java Tue Feb 19 09:32:33 2013 +0100
+++ b/src/org/RhinoTests/CompiledScriptClassTest.java Wed Feb 20 09:39:41 2013 +0100
@@ -1,7 +1,7 @@
/*
Rhino test framework
- Copyright (C) 2011, 2012 Red Hat
+ Copyright (C) 2011, 2012, 2013 Red Hat
This file is part of IcedTea.
@@ -45,7 +45,9 @@
import java.util.List;
import java.util.Map;
import java.util.HashMap;
+import java.util.TreeMap;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -314,6 +316,15 @@
}
/**
+ * Test for method javax.script.CompiledScript.getClass().getCanonicalName()
+ */
+ protected void testGetCanonicalName() {
+ String canonicalName = this.compiledScriptClass.getCanonicalName();
+ assertEquals(canonicalName, "javax.script.CompiledScript",
+ "Method javax.script.CompiledScript.getClass().getCanonicalName() returns wrong value " + canonicalName);
+ }
+
+ /**
* Test for method javax.script.CompiledScript.getClass().getSuperclass()
*/
protected void testGetSuperclass() {
@@ -386,6 +397,70 @@
}
/**
+ * Test for method javax.script.CompiledScript.getClass().getConstructor()
+ */
+ protected void testGetConstructor() {
+ // following constructors should exist
+ Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+ constructorsThatShouldExist_jdk6.put("javax.script.CompiledScript", new Class[] {});
+
+ Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+ constructorsThatShouldExist_jdk7.put("javax.script.CompiledScript", new Class[] {});
+
+ Map<String, Class[]> constructorsThatShouldExist = getJavaVersion() < 7 ? constructorsThatShouldExist_jdk6 : constructorsThatShouldExist_jdk7;
+
+ // check if all required constructors really exist
+ for (Map.Entry<String, Class[]> constructorThatShouldExists : constructorsThatShouldExist.entrySet()) {
+ try {
+ Constructor constructor = this.compiledScriptClass.getConstructor(constructorThatShouldExists.getValue());
+ assertNotNull(constructor,
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ String constructorName = constructor.getName();
+ assertNotNull(constructorName,
+ "constructor " + constructorThatShouldExists.getKey() + " does not have name assigned");
+ assertTrue(constructorName.equals(constructorThatShouldExists.getKey()),
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new AssertionError(e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Test for method javax.script.CompiledScript.getClass().getDeclaredConstructor()
+ */
+ protected void testGetDeclaredConstructor() {
+ // following constructors should exist
+ Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+ constructorsThatShouldExist_jdk6.put("javax.script.CompiledScript", new Class[] {});
+
+ Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+ constructorsThatShouldExist_jdk7.put("javax.script.CompiledScript", new Class[] {});
+
+ Map<String, Class[]> constructorsThatShouldExist = getJavaVersion() < 7 ? constructorsThatShouldExist_jdk6 : constructorsThatShouldExist_jdk7;
+
+ // check if all required constructors really exist
+ for (Map.Entry<String, Class[]> constructorThatShouldExists : constructorsThatShouldExist.entrySet()) {
+ try {
+ Constructor constructor = this.compiledScriptClass.getDeclaredConstructor(constructorThatShouldExists.getValue());
+ assertNotNull(constructor,
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ String constructorName = constructor.getName();
+ assertNotNull(constructorName,
+ "constructor " + constructorThatShouldExists.getKey() + " does not have name assigned");
+ assertTrue(constructorName.equals(constructorThatShouldExists.getKey()),
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new AssertionError(e.getMessage());
+ }
+ }
+ }
+
+ /**
* Test for method javax.script.CompiledScript.getClass().getFields()
*/
protected void testGetFields() {
More information about the distro-pkg-dev
mailing list