changeset 209:eabf4dfba019 draft

Added two new tests getGenericSuperclass() and getGenericInterfaces() into CompiledScriptClassTest.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Mon, 12 Aug 2013 10:55:08 +0200
parents ea551c7459e6
children d525cd24b29c
files ChangeLog src/org/RhinoTests/CompiledScriptClassTest.java
diffstat 2 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Aug 02 12:14:48 2013 +0200
+++ b/ChangeLog	Mon Aug 12 10:55:08 2013 +0200
@@ -1,3 +1,9 @@
+2013-08-12  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/CompiledScriptClassTest.java:
+	Added two new tests getGenericSuperclass() and getGenericInterfaces()
+	into CompiledScriptClassTest.
+
 2013-08-02  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/CompiledScriptClassTest.java:
--- a/src/org/RhinoTests/CompiledScriptClassTest.java	Fri Aug 02 12:14:48 2013 +0200
+++ b/src/org/RhinoTests/CompiledScriptClassTest.java	Mon Aug 12 10:55:08 2013 +0200
@@ -1122,6 +1122,60 @@
     }
 
     /**
+     * Test for method javax.script.CompiledScript.getClass().getGenericSuperclass()
+     */
+    protected void testGetGenericSuperclass() {
+        Type genericSuperclass = this.compiledScriptClass.getGenericSuperclass();
+        assertNotNull(genericSuperclass, "getGenericSuperclass() does not return null");
+    }
+
+    /**
+     * Test for method javax.script.CompiledScript.getClass().getGenericInterfaces()
+     */
+    protected void testGetGenericInterfaces() {
+        // array of interface names that should exists
+        final String[] genericInterfaceNames_jdk6 = {
+        };
+
+        final String[] genericInterfaceNames_jdk7 = {
+        };
+
+        final String[] genericInterfaceNames_jdk8 = {
+        };
+
+        // 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.compiledScriptClass.getGenericInterfaces();
+        assertNotNull(genericInterfaces, "getGenericInterfaces() returns null");
+        assertEquals(0, 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 method javax.script.CompiledScript.getClass().getEnumConstants()
      */
     protected void testGetEnumConstants() {