/hg/rhino-tests: Added two new tests getGenericSuperclass() and ...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Jun 28 01:50:01 PDT 2013


changeset 0ab476c8dfd1 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=0ab476c8dfd1
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Jun 28 10:53:30 2013 +0200

	Added two new tests getGenericSuperclass() and getGenericInterfaces()
	into SimpleScriptContextClassTest.


diffstat:

 ChangeLog                                            |   6 +
 src/org/RhinoTests/SimpleScriptContextClassTest.java |  64 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)

diffs (121 lines):

diff -r a859b2ca8a2a -r 0ab476c8dfd1 ChangeLog
--- a/ChangeLog	Thu Jun 27 16:01:50 2013 +0200
+++ b/ChangeLog	Fri Jun 28 10:53:30 2013 +0200
@@ -1,3 +1,9 @@
+2013-06-28  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/SimpleScriptContextClassTest.java:
+	Added two new tests getGenericSuperclass() and getGenericInterfaces()
+	into SimpleScriptContextClassTest.
+
 2013-06-27  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/AbstractScriptEngineClassTest.java:
diff -r a859b2ca8a2a -r 0ab476c8dfd1 src/org/RhinoTests/SimpleScriptContextClassTest.java
--- a/src/org/RhinoTests/SimpleScriptContextClassTest.java	Thu Jun 27 16:01:50 2013 +0200
+++ b/src/org/RhinoTests/SimpleScriptContextClassTest.java	Fri Jun 28 10:53:30 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.SimpleScriptContext;
 import javax.script.ScriptContext;
@@ -291,6 +293,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>();
@@ -333,6 +336,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>();
@@ -1071,12 +1075,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
@@ -1231,6 +1238,63 @@
     }
 
     /**
+     * Test for method javax.script.SimpleScriptContext.getClass().getGenericSuperclass()
+     */
+    protected void testGetGenericSuperclass() {
+        Type genericSuperclass = this.simpleScriptContextClass.getGenericSuperclass();
+        assertNotNull(genericSuperclass, "getGenericSuperclass() does not return null");
+    }
+
+    /**
+     * Test for method javax.script.SimpleScriptContext.getClass().getGenericInterfaces()
+     */
+    protected void testGetGenericInterfaces() {
+        // array of interface names that should exists
+        final String[] genericInterfaceNames_jdk6 = {
+            "interface javax.script.ScriptContext",
+        };
+
+        final String[] genericInterfaceNames_jdk7 = {
+            "interface javax.script.ScriptContext",
+        };
+
+        final String[] genericInterfaceNames_jdk8 = {
+            "interface javax.script.ScriptContext",
+        };
+
+        // 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.simpleScriptContextClass.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.SimpleScriptContext
      */
     @SuppressWarnings("cast")



More information about the distro-pkg-dev mailing list