/hg/rhino-tests: Added five new tests to the test suite
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Nov 15 01:19:16 PST 2012
changeset 610558995315 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=610558995315
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Nov 15 10:22:11 2012 +0100
Added five new tests to the test suite
src/org/RhinoTests/ScriptEngineFactoryClassTest.java and
made this test compatible with JDK 7.
diffstat:
ChangeLog | 6 +
src/org/RhinoTests/ScriptEngineFactoryClassTest.java | 169 ++++++++++++++++--
2 files changed, 149 insertions(+), 26 deletions(-)
diffs (266 lines):
diff -r 39454ef51d62 -r 610558995315 ChangeLog
--- a/ChangeLog Wed Nov 14 11:05:35 2012 +0100
+++ b/ChangeLog Thu Nov 15 10:22:11 2012 +0100
@@ -1,3 +1,9 @@
+2012-11-15 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/ScriptEngineFactoryClassTest.java:
+ Added five new tests to this test suite.
+ Make this test compatible with JDK 7.
+
2012-11-14 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/ScriptEngineClassTest.java:
diff -r 39454ef51d62 -r 610558995315 src/org/RhinoTests/ScriptEngineFactoryClassTest.java
--- a/src/org/RhinoTests/ScriptEngineFactoryClassTest.java Wed Nov 14 11:05:35 2012 +0100
+++ b/src/org/RhinoTests/ScriptEngineFactoryClassTest.java Thu Nov 15 10:22:11 2012 +0100
@@ -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;
@@ -65,7 +67,7 @@
/**
* Object that represents the type of ScriptEngineFactory.
*/
- Class scriptEngineFactoryClass = null;
+ Class<?> scriptEngineFactoryClass = null;
@Override
protected void setUp(String[] args) {
@@ -136,10 +138,64 @@
}
/**
+ * Test for method javax.script.ScriptEngineFactory.getClass().isAnnotation()
+ */
+ protected void testIsAnnotation() {
+ assertFalse(this.scriptEngineFactoryClass.isAnnotation(),
+ "Method ScriptEngineFactory.getClass().isAnnotation() returns wrong value");
+ }
+
+ /**
+ * Test for method javax.script.ScriptEngineFactory.getClass().isAnnotationPresent()
+ */
+ protected void testIsAnnotationPresent() {
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.annotation.Annotation.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.annotation.Annotation.class) returns wrong value");
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.annotation.Documented.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.annotation.Documented.class) returns wrong value");
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.annotation.Inherited.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.annotation.Inherited.class) returns wrong value");
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.annotation.Retention.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.annotation.Retention.class) returns wrong value");
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.annotation.Target.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.annotation.Target.class) returns wrong value");
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.Deprecated.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.Deprecated.class) returns wrong value");
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.Override.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.Override.class) returns wrong value");
+ assertFalse(this.scriptEngineFactoryClass.isAnnotationPresent(java.lang.SuppressWarnings.class),
+ "Method ScriptEngineFactory.getClass().isAnnotationPresent(java.lang.SuppressWarnings.class) returns wrong value");
+ }
+
+ /**
+ * Test for method javax.script.ScriptEngineFactory.getClass().isAnonymousClass()
+ */
+ protected void testIsAnonymousClass() {
+ assertFalse(this.scriptEngineFactoryClass.isAnonymousClass(),
+ "Method ScriptEngineFactory.getClass().isAnonymousClass() returns wrong value");
+ }
+
+ /**
+ * Test for method javax.script.ScriptEngineFactory.getClass().isArray()
+ */
+ protected void testIsArray() {
+ assertFalse(this.scriptEngineFactoryClass.isArray(),
+ "Method ScriptEngineFactory.getClass().isArray() returns wrong value");
+ }
+
+ /**
+ * Test for method javax.script.ScriptEngineFactory.getClass().isEnum()
+ */
+ protected void testIsEnum() {
+ assertFalse(this.scriptEngineFactoryClass.isEnum(),
+ "Method ScriptEngineFactory.getClass().isEnum() returns wrong value");
+ }
+
+ /**
* Test for method javax.script.ScriptEngineFactory.getClass().getInterfaces()
*/
protected void testGetInterfaces() {
- List interfaces = Arrays.asList(this.scriptEngineFactoryClass.getInterfaces());
+ List<Class<?>> interfaces = Arrays.asList(this.scriptEngineFactoryClass.getInterfaces());
assertTrue(interfaces.isEmpty(),
"list of implemented interfaces should be empty");
}
@@ -207,7 +263,7 @@
* Test for method javax.script.ScriptEngineFactory.getClass().getSuperclass()
*/
protected void testGetSuperclass() {
- Class superClass = this.scriptEngineFactoryClass.getSuperclass();
+ Class<?> superClass = this.scriptEngineFactoryClass.getSuperclass();
assertNull(superClass,
"Method ScriptEngineFactory.getClass().getSuperclass() does not return null");
}
@@ -216,16 +272,42 @@
* Test for method javax.script.ScriptEngineFactory.getClass().getConstructors()
*/
protected void testGetConstructors() {
- Constructor[] constructors = this.scriptEngineFactoryClass.getConstructors();
+ // 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.scriptEngineFactoryClass.getConstructors();
+
+ // basic check for a number of constructors
assertEquals(constructors.length, 0, "no constructors should be set");
+
}
/**
* Test for method javax.script.ScriptEngineFactory.getClass().getDeclaredConstructors()
*/
protected void testGetDeclaredConstructors() {
- Constructor[] constructors = this.scriptEngineFactoryClass.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.scriptEngineFactoryClass.getDeclaredConstructors();
+
+ // basic check for a number of declared constructors
+ assertEquals(declaredConstructors.length, 0, "no constructors should be set");
+
}
/**
@@ -275,7 +357,7 @@
*/
protected void testGetMethods() {
// following methods should be inherited
- final String[] methodsThatShouldExists = {
+ final String[] methodsThatShouldExists_jdk6 = {
"public abstract java.lang.Object javax.script.ScriptEngineFactory.getParameter(java.lang.String)",
"public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineName()",
"public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineVersion()",
@@ -289,26 +371,8 @@
"public abstract java.util.List javax.script.ScriptEngineFactory.getNames()",
"public abstract javax.script.ScriptEngine javax.script.ScriptEngineFactory.getScriptEngine()",
};
- // get all inherited methods
- Method[] methods = this.scriptEngineFactoryClass.getMethods();
- // and transform the array into a list of method names
- List<String> methodsAsString = new ArrayList<String>();
- for (Method method : methods) {
- methodsAsString.add(method.toString());
- }
- // check if all required methods really exists
- for (String methodThatShouldExists : methodsThatShouldExists) {
- assertTrue(methodsAsString.contains(methodThatShouldExists),
- "method " + methodThatShouldExists + " not found");
- }
- }
- /**
- * Test for method javax.script.ScriptEngineFactory.getClass().getDeclaredMethods()
- */
- protected void testGetDeclaredMethods() {
- // following methods should be declared
- final String[] declaredMethodsThatShouldExists = {
+ final String[] methodsThatShouldExists_jdk7 = {
"public abstract java.lang.Object javax.script.ScriptEngineFactory.getParameter(java.lang.String)",
"public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineName()",
"public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineVersion()",
@@ -322,6 +386,57 @@
"public abstract java.util.List javax.script.ScriptEngineFactory.getNames()",
"public abstract javax.script.ScriptEngine javax.script.ScriptEngineFactory.getScriptEngine()",
};
+
+ // get all inherited methods
+ Method[] methods = this.scriptEngineFactoryClass.getMethods();
+ // and transform the array into a list of method names
+ List<String> methodsAsString = new ArrayList<String>();
+ 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),
+ "method " + methodThatShouldExists + " not found");
+ }
+ }
+
+ /**
+ * Test for method javax.script.ScriptEngineFactory.getClass().getDeclaredMethods()
+ */
+ protected void testGetDeclaredMethods() {
+ // following methods should be declared
+ final String[] declaredMethodsThatShouldExists_jdk6 = {
+ "public abstract java.lang.Object javax.script.ScriptEngineFactory.getParameter(java.lang.String)",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineName()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineVersion()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getLanguageName()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getLanguageVersion()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getMethodCallSyntax(java.lang.String,java.lang.String,java.lang.String[])",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getOutputStatement(java.lang.String)",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getProgram(java.lang.String[])",
+ "public abstract java.util.List javax.script.ScriptEngineFactory.getExtensions()",
+ "public abstract java.util.List javax.script.ScriptEngineFactory.getMimeTypes()",
+ "public abstract java.util.List javax.script.ScriptEngineFactory.getNames()",
+ "public abstract javax.script.ScriptEngine javax.script.ScriptEngineFactory.getScriptEngine()",
+ };
+
+ final String[] declaredMethodsThatShouldExists_jdk7 = {
+ "public abstract java.lang.Object javax.script.ScriptEngineFactory.getParameter(java.lang.String)",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineName()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getEngineVersion()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getLanguageName()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getLanguageVersion()",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getMethodCallSyntax(java.lang.String,java.lang.String,java.lang.String[])",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getOutputStatement(java.lang.String)",
+ "public abstract java.lang.String javax.script.ScriptEngineFactory.getProgram(java.lang.String[])",
+ "public abstract java.util.List javax.script.ScriptEngineFactory.getExtensions()",
+ "public abstract java.util.List javax.script.ScriptEngineFactory.getMimeTypes()",
+ "public abstract java.util.List javax.script.ScriptEngineFactory.getNames()",
+ "public abstract javax.script.ScriptEngine javax.script.ScriptEngineFactory.getScriptEngine()",
+ };
+
// get all declared methods
Method[] declaredMethods = this.scriptEngineFactoryClass.getDeclaredMethods();
// and transform the array into a list of method names
@@ -329,6 +444,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),
@@ -339,6 +455,7 @@
/**
* Test for instanceof operator applied to a class javax.script.ScriptEngineFactory
*/
+ @SuppressWarnings("cast")
protected void testInstanceOf() {
// tested object
Object o = new ScriptEngineManager().getEngineFactories().get(0);
More information about the distro-pkg-dev
mailing list