/hg/rhino-tests: New tests added into the testsuite SimpleBindin...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Tue Jan 22 00:32:47 PST 2013


changeset 1f2be0d19c68 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=1f2be0d19c68
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Jan 22 09:34:41 2013 +0100

	New tests added into the testsuite SimpleBindingsClassTest.


diffstat:

 ChangeLog                                       |    5 +
 src/org/RhinoTests/SimpleBindingsClassTest.java |  105 +++++++++++++++++++++--
 2 files changed, 101 insertions(+), 9 deletions(-)

diffs (164 lines):

diff -r 0c193d54de35 -r 1f2be0d19c68 ChangeLog
--- a/ChangeLog	Mon Jan 21 09:38:26 2013 +0100
+++ b/ChangeLog	Tue Jan 22 09:34:41 2013 +0100
@@ -1,3 +1,8 @@
+2013-01-22  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/SimpleBindingsClassTest.java:
+	New tests added into the testsuite SimpleBindingsClassTest.
+
 2013-01-21  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/InvocableClassTest.java:
diff -r 0c193d54de35 -r 1f2be0d19c68 src/org/RhinoTests/SimpleBindingsClassTest.java
--- a/src/org/RhinoTests/SimpleBindingsClassTest.java	Mon Jan 21 09:38:26 2013 +0100
+++ b/src/org/RhinoTests/SimpleBindingsClassTest.java	Tue Jan 22 09:34:41 2013 +0100
@@ -347,12 +347,86 @@
     }
 
     /**
+     * Test for method javax.script.SimpleBindings.getClass().getConstructor()
+     */
+    protected void testGetConstructor() {
+        // following constructors should exist
+        Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class});
+        constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {});
+
+        Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class});
+        constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new 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.simpleBindingsClass.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.SimpleBindings.getClass().getDeclaredConstructor()
+     */
+    protected void testGetDeclaredConstructor() {
+        // following constructors should exist
+        Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class});
+        constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {});
+
+        Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class});
+        constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new 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.simpleBindingsClass.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.SimpleBindings.getClass().getFields()
      */
     protected void testGetFields() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        final String[] fieldsThatShouldExist_jdk6 = {
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+        };
+
+        // get the right array of field signatures
+        final String[] fieldsThatShouldExist = getJavaVersion() < 7 ? fieldsThatShouldExist_jdk6 : fieldsThatShouldExist_jdk7;
+
         // get all fields
         Field[] fields = this.simpleBindingsClass.getFields();
         // and transform the array into a list of field names
@@ -361,7 +435,7 @@
             fieldsAsString.add(field.toString());
         }
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
+        for (String fieldThatShouldExists : fieldsThatShouldExist) {
             assertTrue(fieldsAsString.contains(fieldThatShouldExists),
                     "field " + fieldThatShouldExists + " not found");
         }
@@ -371,10 +445,18 @@
      * Test for method javax.script.SimpleBindings.getClass().getDeclaredFields()
      */
     protected void testGetDeclaredFields() {
-        // following fields should be declared
-        final String[] fieldsThatShouldExists = {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
             "private java.util.Map javax.script.SimpleBindings.map",
         };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+            "private java.util.Map javax.script.SimpleBindings.map",
+        };
+
+        // get the right array of field signatures
+        // following fields should be declared
+        final String[] declaredFieldsThatShouldExist = getJavaVersion() < 7 ? declaredFieldsThatShouldExist_jdk6 : declaredFieldsThatShouldExist_jdk7;
+
         // get all declared fields
         Field[] declaredFields = this.simpleBindingsClass.getDeclaredFields();
         // and transform the array into a list of field names
@@ -383,9 +465,9 @@
             declaredFieldsAsString.add(field.toString());
         }
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
-            assertTrue(declaredFieldsAsString.contains(fieldThatShouldExists),
-                    "field " + fieldThatShouldExists + " not found");
+        for (String declaredFieldThatShouldExists : declaredFieldsThatShouldExist) {
+            assertTrue(declaredFieldsAsString.contains(declaredFieldThatShouldExists),
+                    "field " + declaredFieldThatShouldExists + " not found");
         }
     }
 
@@ -394,10 +476,15 @@
      */
     protected void testGetField() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        final String[] fieldsThatShouldExist_jdk6 = {
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+        };
+
+        final String[] fieldsThatShouldExist = getJavaVersion() < 7 ? fieldsThatShouldExist_jdk6 : fieldsThatShouldExist_jdk7;
+
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
+        for (String fieldThatShouldExists : fieldsThatShouldExist) {
             try {
                 Field field = this.simpleBindingsClass.getField(fieldThatShouldExists);
                 String fieldName = field.getName();



More information about the distro-pkg-dev mailing list