/hg/rhino-tests: Added two new tests getGenericSuperclass() and ...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Jun 27 06:58:18 PDT 2013
changeset a859b2ca8a2a in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=a859b2ca8a2a
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jun 27 16:01:50 2013 +0200
Added two new tests getGenericSuperclass() and getGenericInterfaces()
into AbstractScriptEngineClassTest.
diffstat:
ChangeLog | 6 +
src/org/RhinoTests/AbstractScriptEngineClassTest.java | 64 +++++++++++++++++++
2 files changed, 70 insertions(+), 0 deletions(-)
diffs (121 lines):
diff -r 75e3e48ef286 -r a859b2ca8a2a ChangeLog
--- a/ChangeLog Wed Jun 26 10:59:13 2013 +0200
+++ b/ChangeLog Thu Jun 27 16:01:50 2013 +0200
@@ -1,3 +1,9 @@
+2013-06-27 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/AbstractScriptEngineClassTest.java:
+ Added two new tests getGenericSuperclass() and getGenericInterfaces()
+ into AbstractScriptEngineClassTest.
+
2013-06-26 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/ScriptExceptionClassTest.java:
diff -r 75e3e48ef286 -r a859b2ca8a2a src/org/RhinoTests/AbstractScriptEngineClassTest.java
--- a/src/org/RhinoTests/AbstractScriptEngineClassTest.java Wed Jun 26 10:59:13 2013 +0200
+++ b/src/org/RhinoTests/AbstractScriptEngineClassTest.java Thu Jun 27 16:01:50 2013 +0200
@@ -52,6 +52,8 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
import javax.script.AbstractScriptEngine;
import javax.script.ScriptEngineManager;import javax.script.ScriptEngine;
@@ -285,6 +287,7 @@
*/
protected void testGetConstructors() {
// map of constructors which should exists
+ @SuppressWarnings("unused")
Map<String, String> testedConstructors = null;
Map<String, String> testedConstructors_jdk6 = new HashMap<String, String>();
Map<String, String> testedConstructors_jdk7 = new HashMap<String, String>();
@@ -332,6 +335,7 @@
*/
protected void testGetDeclaredConstructors() {
// map of constructors which should exists
+ @SuppressWarnings("unused")
Map<String, String> testedConstructors = null;
Map<String, String> testedConstructors_jdk6 = new HashMap<String, String>();
Map<String, String> testedConstructors_jdk7 = new HashMap<String, String>();
@@ -1063,12 +1067,15 @@
protected void testGetAnnotations() {
// following annotations should be provided
final String[] annotationsThatShouldExists_jdk6 = {
+ // this should be really empty
};
final String[] annotationsThatShouldExists_jdk7 = {
+ // this should be really empty
};
final String[] annotationsThatShouldExists_jdk8 = {
+ // this should be really empty
};
// get all annotations
@@ -1223,6 +1230,63 @@
}
/**
+ * Test for method javax.script.AbstractScriptEngine.getClass().getGenericSuperclass()
+ */
+ protected void testGetGenericSuperclass() {
+ Type genericSuperclass = this.abstractScriptEngineClass.getGenericSuperclass();
+ assertNotNull(genericSuperclass, "getGenericSuperclass() does not return null");
+ }
+
+ /**
+ * Test for method javax.script.AbstractScriptEngine.getClass().getGenericInterfaces()
+ */
+ protected void testGetGenericInterfaces() {
+ // array of interface names that should exists
+ final String[] genericInterfaceNames_jdk6 = {
+ "interface javax.script.ScriptEngine",
+ };
+
+ final String[] genericInterfaceNames_jdk7 = {
+ "interface javax.script.ScriptEngine",
+ };
+
+ final String[] genericInterfaceNames_jdk8 = {
+ "interface javax.script.ScriptEngine",
+ };
+
+ // get the right array of field signatures
+ String[] genericInterfaceNames = null;
+ switch (getJavaVersion()) {
+ case 6:
+ genericInterfaceNames = genericInterfaceNames_jdk6;
+ break;
+ case 7:
+ genericInterfaceNames = genericInterfaceNames_jdk7;
+ break;
+ case 8:
+ genericInterfaceNames = genericInterfaceNames_jdk8;
+ break;
+ }
+
+ // get all generic interfaces
+ Type[] genericInterfaces = this.abstractScriptEngineClass.getGenericInterfaces();
+ assertNotNull(genericInterfaces, "getGenericInterfaces() returns null");
+ assertEquals(1, genericInterfaces.length, "array of wrong size returned by getGenericInterfaces " + genericInterfaces.length);
+
+ // and transform the array into a list of field names
+ List<String> interfacesAsString = new ArrayList<String>();
+ for (Type genericInterface : genericInterfaces) {
+ interfacesAsString.add(genericInterface.toString());
+ }
+
+ // check if all required interfaces really exists
+ for (String interfaceThatShouldExists : genericInterfaceNames) {
+ assertTrue(interfacesAsString.contains(interfaceThatShouldExists),
+ "interface " + interfaceThatShouldExists + " not found");
+ }
+ }
+
+ /**
* Test for instanceof operator applied to a class javax.script.AbstractScriptEngine
*/
@SuppressWarnings("cast")
More information about the distro-pkg-dev
mailing list