/hg/rhino-tests: New tests added methods getConstructor(), getDe...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Jan 11 02:23:02 PST 2013


changeset eb0943f105e6 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=eb0943f105e6
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Jan 11 11:26:11 2013 +0100

	New tests added methods getConstructor(), getDeclaredConstructor()
	and getDeclaredFields into src/org/RhinoTests/AbstractScriptEngineClassTest.java.


diffstat:

 ChangeLog                                             |  14 +-
 src/org/RhinoTests/AbstractScriptEngineClassTest.java |  97 +++++++++++++++++++
 2 files changed, 107 insertions(+), 4 deletions(-)

diffs (153 lines):

diff -r 7df6314535c9 -r eb0943f105e6 ChangeLog
--- a/ChangeLog	Thu Jan 10 09:32:48 2013 +0100
+++ b/ChangeLog	Fri Jan 11 11:26:11 2013 +0100
@@ -1,25 +1,31 @@
+2013-01-11  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/AbstractScriptEngineClassTest.java:
+	New tests added methods getConstructor(), getDeclaredConstructor()
+	and getDeclaredFields.
+
 2013-01-10  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/BindingsClassTest.java:
-	Added three new tests for methods GetCanonicalName(), getConstructor() and
+	Added three new tests for methods getCanonicalName(), getConstructor() and
 	getDeclaredConstructor().
 
 2013-01-09  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/SimpleBindingsClassTest.java:
-	Added three new tests for methods GetCanonicalName(), getAnnotation() and
+	Added three new tests for methods getCanonicalName(), getAnnotation() and
 	getComponentType().
 
 2013-01-08  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/SimpleScriptContextClassTest.java:
-	Added new test for a method GetCanonicalName() getAnnotation().
+	Added new test for a method getCanonicalName() getAnnotation().
 	Fixed spelling.
 
 2013-01-07  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/AbstractScriptEngineClassTest.java:
-	Added new test for a method GetCanonicalName().
+	Added new test for a method getCanonicalName().
 	Updated tests GetFields(), GetDeclaredFields() and GetField().
 
 2012-12-21  Pavel Tisnovsky  <ptisnovs at redhat.com>
diff -r 7df6314535c9 -r eb0943f105e6 src/org/RhinoTests/AbstractScriptEngineClassTest.java
--- a/src/org/RhinoTests/AbstractScriptEngineClassTest.java	Thu Jan 10 09:32:48 2013 +0100
+++ b/src/org/RhinoTests/AbstractScriptEngineClassTest.java	Fri Jan 11 11:26:11 2013 +0100
@@ -347,6 +347,74 @@
     }
 
     /**
+     * Test for method javax.script.AbstractScriptEngine.getClass().getConstructor()
+     */
+    protected void testGetConstructor() {
+        // following constructors should exist
+        Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk6.put("javax.script.AbstractScriptEngine", new Class[] {});
+        constructorsThatShouldExist_jdk6.put("javax.script.AbstractScriptEngine", new Class[] {javax.script.Bindings.class});
+
+        Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk7.put("javax.script.AbstractScriptEngine", new Class[] {});
+        constructorsThatShouldExist_jdk7.put("javax.script.AbstractScriptEngine", new Class[] {javax.script.Bindings.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.abstractScriptEngineClass.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.AbstractScriptEngine.getClass().getDeclaredConstructor()
+     */
+    protected void testGetDeclaredConstructor() {
+        // following constructors should exist
+        Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk6.put("javax.script.AbstractScriptEngine", new Class[] {});
+        constructorsThatShouldExist_jdk6.put("javax.script.AbstractScriptEngine", new Class[] {javax.script.Bindings.class});
+
+        Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk7.put("javax.script.AbstractScriptEngine", new Class[] {});
+        constructorsThatShouldExist_jdk7.put("javax.script.AbstractScriptEngine", new Class[] {javax.script.Bindings.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.abstractScriptEngineClass.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.AbstractScriptEngine.getClass().getFields()
      */
     protected void testGetFields() {
@@ -459,6 +527,35 @@
     }
 
     /**
+     * Test for method javax.script.AbstractScriptEngine.getClass().getDeclaredField()
+     */
+    protected void testGetDeclaredField() {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
+            "context",
+        };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+            "context",
+        };
+
+        final String[] declaredFieldsThatShouldExist = getJavaVersion() < 7 ? declaredFieldsThatShouldExist_jdk6 : declaredFieldsThatShouldExist_jdk7;
+
+        // check if all required declared fields really exists
+        for (String declaredFieldThatShouldExists : declaredFieldsThatShouldExist) {
+            try {
+                Field field = this.abstractScriptEngineClass.getDeclaredField(declaredFieldThatShouldExists);
+                String fieldName = field.getName();
+                assertTrue(fieldName.equals(declaredFieldThatShouldExists),
+                        "field " + declaredFieldThatShouldExists + " not found");
+            }
+            catch (Exception e) {
+                e.printStackTrace();
+                throw new AssertionError(e.getMessage());
+            }
+        }
+    }
+
+    /**
      * Test for method javax.script.AbstractScriptEngine.getClass().getMethods()
      */
     protected void testGetMethods() {



More information about the distro-pkg-dev mailing list