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

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Wed Dec 19 02:00:24 PST 2012


changeset 3b33320797eb in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=3b33320797eb
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Wed Dec 19 11:03:19 2012 +0100

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


diffstat:

 ChangeLog                                        |   5 +
 src/org/RhinoTests/ScriptExceptionClassTest.java |  75 ++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)

diffs (111 lines):

diff -r 499bf38b565f -r 3b33320797eb ChangeLog
--- a/ChangeLog	Tue Dec 18 10:49:01 2012 +0100
+++ b/ChangeLog	Wed Dec 19 11:03:19 2012 +0100
@@ -1,3 +1,8 @@
+2012-12-19  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/ScriptExceptionClassTest.java:
+	Added three new tests into this test case.
+
 2012-12-18  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/ScriptEngineFactoryClassTest.java:
diff -r 499bf38b565f -r 3b33320797eb src/org/RhinoTests/ScriptExceptionClassTest.java
--- a/src/org/RhinoTests/ScriptExceptionClassTest.java	Tue Dec 18 10:49:01 2012 +0100
+++ b/src/org/RhinoTests/ScriptExceptionClassTest.java	Wed Dec 19 11:03:19 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;
@@ -389,6 +390,28 @@
     }
 
     /**
+     * Test for method javax.script.ScriptException.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.scriptExceptionClass.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.ScriptException.getClass().getMethods()
      */
     protected void testGetMethods() {
@@ -495,6 +518,58 @@
     }
 
     /**
+     * Test for method javax.script.ScriptException.getClass().getAnnotations()
+     */
+    protected void testGetAnnotations() {
+        // following annotations should be provided
+        final String[] annotationsThatShouldExists_jdk6 = {
+        };
+
+        final String[] annotationsThatShouldExists_jdk7 = {
+        };
+
+        // get all annotations
+        Annotation[] annotations = this.scriptExceptionClass.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.ScriptException.getClass().getDeclaredAnnotations()
+     */
+    protected void testGetDeclaredAnnotations() {
+        // following annotations should be provided
+        final String[] annotationsThatShouldExists_jdk6 = {
+        };
+
+        final String[] annotationsThatShouldExists_jdk7 = {
+        };
+
+        // get all annotations
+        Annotation[] annotations = this.scriptExceptionClass.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.ScriptException
      */
     @SuppressWarnings("cast")



More information about the distro-pkg-dev mailing list