/hg/rhino-tests: Added three new tests into the test case src/or...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu Dec 13 01:43:17 PST 2012


changeset 90ebe9af7914 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=90ebe9af7914
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Dec 13 10:46:21 2012 +0100

	Added three new tests into the test case src/org/RhinoTests/SimpleBindingsClassTest.java.


diffstat:

 ChangeLog                                       |   8 ++
 src/org/RhinoTests/SimpleBindingsClassTest.java |  75 +++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 0 deletions(-)

diffs (114 lines):

diff -r 0fc35b431d2e -r 90ebe9af7914 ChangeLog
--- a/ChangeLog	Wed Dec 12 11:25:42 2012 +0100
+++ b/ChangeLog	Thu Dec 13 10:46:21 2012 +0100
@@ -1,3 +1,11 @@
+2012-12-13  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/SimpleBindingsClassTest.java:
+	Added three new tests into this test case:
+	- getAnnotations()
+	- getDeclaredAnnotations()
+	- getField()
+
 2012-12-12  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/SimpleScriptContextClassTest.java:
diff -r 0fc35b431d2e -r 90ebe9af7914 src/org/RhinoTests/SimpleBindingsClassTest.java
--- a/src/org/RhinoTests/SimpleBindingsClassTest.java	Wed Dec 12 11:25:42 2012 +0100
+++ b/src/org/RhinoTests/SimpleBindingsClassTest.java	Thu Dec 13 10:46:21 2012 +0100
@@ -46,6 +46,7 @@
 import java.util.Map;
 import java.util.HashMap;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -379,6 +380,28 @@
     }
 
     /**
+     * Test for method javax.script.SimpleBindings.getClass().getField()
+     */
+    protected void testGetField() {
+        // following fields should exists
+        final String[] fieldsThatShouldExists = {
+        };
+        // check if all required fields really exists
+        for (String fieldThatShouldExists : fieldsThatShouldExists) {
+            try {
+                Field field = this.simpleBindingsClass.getField(fieldThatShouldExists);
+                String fieldName = field.getName();
+                assertTrue(fieldName.equals(fieldThatShouldExists),
+                        "field " + fieldThatShouldExists + " not found");
+            }
+            catch (Exception e) {
+                e.printStackTrace();
+                throw new AssertionError(e.getMessage());
+            }
+        }
+    }
+
+    /**
      * Test for method javax.script.SimpleBindings.getClass().getMethods()
      */
     protected void testGetMethods() {
@@ -503,6 +526,58 @@
     }
 
     /**
+     * Test for method javax.script.SimpleBindings.getClass().getAnnotations()
+     */
+    protected void testGetAnnotations() {
+        // following annotations should be provided
+        final String[] annotationsThatShouldExists_jdk6 = {
+        };
+
+        final String[] annotationsThatShouldExists_jdk7 = {
+        };
+
+        // get all annotations
+        Annotation[] annotations = this.simpleBindingsClass.getAnnotations();
+        // and transform the array into a list of annotation names
+        List<String> annotationsAsString = new ArrayList<String>();
+        for (Annotation annotation : annotations) {
+            annotationsAsString.add(annotation.toString());
+        }
+        String[] annotationsThatShouldExists = getJavaVersion() < 7 ? annotationsThatShouldExists_jdk6 : annotationsThatShouldExists_jdk7;
+        // check if all required annotations really exists
+        for (String annotationThatShouldExists : annotationsThatShouldExists) {
+            assertTrue(annotationsAsString.contains(annotationThatShouldExists),
+                    "annotation " + annotationThatShouldExists + " not found");
+        }
+    }
+
+    /**
+     * Test for method javax.script.SimpleBindings.getClass().getDeclaredAnnotations()
+     */
+    protected void testGetDeclaredAnnotations() {
+        // following annotations should be provided
+        final String[] annotationsThatShouldExists_jdk6 = {
+        };
+
+        final String[] annotationsThatShouldExists_jdk7 = {
+        };
+
+        // get all annotations
+        Annotation[] annotations = this.simpleBindingsClass.getDeclaredAnnotations();
+        // and transform the array into a list of annotation names
+        List<String> annotationsAsString = new ArrayList<String>();
+        for (Annotation annotation : annotations) {
+            annotationsAsString.add(annotation.toString());
+        }
+        String[] annotationsThatShouldExists = getJavaVersion() < 7 ? annotationsThatShouldExists_jdk6 : annotationsThatShouldExists_jdk7;
+        // check if all required annotations really exists
+        for (String annotationThatShouldExists : annotationsThatShouldExists) {
+            assertTrue(annotationsAsString.contains(annotationThatShouldExists),
+                    "annotation " + annotationThatShouldExists + " not found");
+        }
+    }
+
+    /**
      * Test for instanceof operator applied to a class javax.script.SimpleBindings
      */
     @SuppressWarnings("cast")



More information about the distro-pkg-dev mailing list