/hg/rhino-tests: Three new tests added into BindingsClassTest: g...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu Jan 31 00:49:08 PST 2013


changeset 358cb09b56b9 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=358cb09b56b9
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jan 31 09:52:04 2013 +0100

	Three new tests added into BindingsClassTest: getMethod(),
	getDeclaredMethod() and getAnnotation().


diffstat:

 ChangeLog                                 |    6 +
 src/org/RhinoTests/BindingsClassTest.java |  139 ++++++++++++++++++++++++++++-
 2 files changed, 137 insertions(+), 8 deletions(-)

diffs (212 lines):

diff -r 667993be1ed8 -r 358cb09b56b9 ChangeLog
--- a/ChangeLog	Wed Jan 30 09:22:04 2013 +0100
+++ b/ChangeLog	Thu Jan 31 09:52:04 2013 +0100
@@ -1,3 +1,9 @@
+2013-01-31  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/BindingsClassTest.java:
+	Three new tests added into BindingsClassTest: getMethod(),
+	getDeclaredMethod() and getAnnotation().
+
 2013-01-30  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/ScriptEngineClassTest.java:
diff -r 667993be1ed8 -r 358cb09b56b9 src/org/RhinoTests/BindingsClassTest.java
--- a/src/org/RhinoTests/BindingsClassTest.java	Wed Jan 30 09:22:04 2013 +0100
+++ b/src/org/RhinoTests/BindingsClassTest.java	Thu Jan 31 09:52:04 2013 +0100
@@ -497,7 +497,7 @@
      */
     protected void testGetMethods() {
         // following methods should be inherited
-        final String[] methodsThatShouldExists_jdk6 = {
+        final String[] methodsThatShouldExist_jdk6 = {
             "public abstract boolean java.util.Map.containsValue(java.lang.Object)",
             "public abstract boolean java.util.Map.equals(java.lang.Object)",
             "public abstract boolean java.util.Map.isEmpty()",
@@ -515,7 +515,7 @@
             "public abstract void javax.script.Bindings.putAll(java.util.Map)",
         };
 
-        final String[] methodsThatShouldExists_jdk7 = {
+        final String[] methodsThatShouldExist_jdk7 = {
             "public abstract boolean java.util.Map.containsValue(java.lang.Object)",
             "public abstract boolean java.util.Map.equals(java.lang.Object)",
             "public abstract boolean java.util.Map.isEmpty()",
@@ -540,9 +540,9 @@
         for (Method method : methods) {
             methodsAsString.add(method.toString());
         }
-        String[] methodsThatShouldExists = getJavaVersion() < 7 ? methodsThatShouldExists_jdk6 : methodsThatShouldExists_jdk7;
+        String[] methodsThatShouldExist = getJavaVersion() < 7 ? methodsThatShouldExist_jdk6 : methodsThatShouldExist_jdk7;
         // check if all required methods really exists
-        for (String methodThatShouldExists : methodsThatShouldExists) {
+        for (String methodThatShouldExists : methodsThatShouldExist) {
             assertTrue(methodsAsString.contains(methodThatShouldExists),
                     "method " + methodThatShouldExists + " not found");
         }
@@ -553,7 +553,7 @@
      */
     protected void testGetDeclaredMethods() {
         // following methods should be declared
-        final String[] declaredMethodsThatShouldExists_jdk6 = {
+        final String[] declaredMethodsThatShouldExist_jdk6 = {
             "public abstract boolean javax.script.Bindings.containsKey(java.lang.Object)",
             "public abstract java.lang.Object javax.script.Bindings.get(java.lang.Object)",
             "public abstract java.lang.Object javax.script.Bindings.put(java.lang.String,java.lang.Object)",
@@ -561,7 +561,7 @@
             "public abstract void javax.script.Bindings.putAll(java.util.Map)",
         };
 
-        final String[] declaredMethodsThatShouldExists_jdk7 = {
+        final String[] declaredMethodsThatShouldExist_jdk7 = {
             "public abstract boolean javax.script.Bindings.containsKey(java.lang.Object)",
             "public abstract java.lang.Object javax.script.Bindings.get(java.lang.Object)",
             "public abstract java.lang.Object javax.script.Bindings.put(java.lang.String,java.lang.Object)",
@@ -576,15 +576,115 @@
         for (Method method : declaredMethods) {
             methodsAsString.add(method.toString());
         }
-        String[] declaredMethodsThatShouldExists = getJavaVersion() < 7 ? declaredMethodsThatShouldExists_jdk6 : declaredMethodsThatShouldExists_jdk7;
+        String[] declaredMethodsThatShouldExist = getJavaVersion() < 7 ? declaredMethodsThatShouldExist_jdk6 : declaredMethodsThatShouldExist_jdk7;
         // check if all required methods really exists
-        for (String methodThatShouldExists : declaredMethodsThatShouldExists) {
+        for (String methodThatShouldExists : declaredMethodsThatShouldExist) {
             assertTrue(methodsAsString.contains(methodThatShouldExists),
                     "declared method " + methodThatShouldExists + " not found");
         }
     }
 
     /**
+     * Test for method javax.script.Bindings.getClass().getMethod()
+     */
+    protected void testGetMethod() {
+        // following methods should exist
+        Map<String, Class[]> methodsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+        methodsThatShouldExist_jdk6.put("get", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("putAll", new Class[] {java.util.Map.class});
+        methodsThatShouldExist_jdk6.put("remove", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("containsKey", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("hashCode", new Class[] {});
+        methodsThatShouldExist_jdk6.put("equals", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("clear", new Class[] {});
+        methodsThatShouldExist_jdk6.put("size", new Class[] {});
+        methodsThatShouldExist_jdk6.put("isEmpty", new Class[] {});
+        methodsThatShouldExist_jdk6.put("values", new Class[] {});
+        methodsThatShouldExist_jdk6.put("entrySet", new Class[] {});
+        methodsThatShouldExist_jdk6.put("keySet", new Class[] {});
+        methodsThatShouldExist_jdk6.put("containsValue", new Class[] {java.lang.Object.class});
+
+        Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        methodsThatShouldExist_jdk7.put("remove", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("putAll", new Class[] {java.util.Map.class});
+        methodsThatShouldExist_jdk7.put("containsKey", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("equals", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("values", new Class[] {});
+        methodsThatShouldExist_jdk7.put("hashCode", new Class[] {});
+        methodsThatShouldExist_jdk7.put("clear", new Class[] {});
+        methodsThatShouldExist_jdk7.put("isEmpty", new Class[] {});
+        methodsThatShouldExist_jdk7.put("size", new Class[] {});
+        methodsThatShouldExist_jdk7.put("entrySet", new Class[] {});
+        methodsThatShouldExist_jdk7.put("keySet", new Class[] {});
+        methodsThatShouldExist_jdk7.put("containsValue", new Class[] {java.lang.Object.class});
+
+        Map<String, Class[]> methodsThatShouldExist = getJavaVersion() < 7 ? methodsThatShouldExist_jdk6 : methodsThatShouldExist_jdk7;
+
+        // check if all required methods really exist
+        for (Map.Entry<String, Class[]> methodThatShouldExists : methodsThatShouldExist.entrySet()) {
+            try {
+                Method method = this.bindingsClass.getMethod(methodThatShouldExists.getKey(), methodThatShouldExists.getValue());
+                assertNotNull(method,
+                        "method " + methodThatShouldExists.getKey() + " not found");
+                String methodName = method.getName();
+                assertNotNull(methodName,
+                        "method " + methodThatShouldExists.getKey() + " does not have name assigned");
+                assertTrue(methodName.equals(methodThatShouldExists.getKey()),
+                        "method " + methodThatShouldExists.getKey() + " not found");
+            }
+            catch (Exception e) {
+                e.printStackTrace();
+                throw new AssertionError(e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * Test for method javax.script.Bindings.getClass().getDeclaredMethod()
+     */
+    protected void testGetDeclaredMethod() {
+        // following methods should exist
+        Map<String, Class[]> methodsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+        methodsThatShouldExist_jdk6.put("get", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("putAll", new Class[] {java.util.Map.class});
+        methodsThatShouldExist_jdk6.put("remove", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("containsKey", new Class[] {java.lang.Object.class});
+
+        Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        methodsThatShouldExist_jdk7.put("remove", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("putAll", new Class[] {java.util.Map.class});
+        methodsThatShouldExist_jdk7.put("containsKey", new Class[] {java.lang.Object.class});
+
+        Map<String, Class[]> methodsThatShouldExist = getJavaVersion() < 7 ? methodsThatShouldExist_jdk6 : methodsThatShouldExist_jdk7;
+
+        // check if all required methods really exist
+        for (Map.Entry<String, Class[]> methodThatShouldExists : methodsThatShouldExist.entrySet()) {
+            try {
+                Method method = this.bindingsClass.getDeclaredMethod(methodThatShouldExists.getKey(), methodThatShouldExists.getValue());
+                assertNotNull(method,
+                        "method " + methodThatShouldExists.getKey() + " not found");
+                String methodName = method.getName();
+                assertNotNull(methodName,
+                        "method " + methodThatShouldExists.getKey() + " does not have name assigned");
+                assertTrue(methodName.equals(methodThatShouldExists.getKey()),
+                        "method " + methodThatShouldExists.getKey() + " not found");
+            }
+            catch (Exception e) {
+                e.printStackTrace();
+                throw new AssertionError(e.getMessage());
+            }
+        }
+    }
+
+    /**
      * Test for method javax.script.Bindings.getClass().getAnnotations()
      */
     protected void testGetAnnotations() {
@@ -639,6 +739,29 @@
     }
 
     /**
+     * Test for method javax.script.Bindings.getClass().getAnnotation()
+     */
+    protected void testGetAnnotation() {
+        Annotation annotation;
+        annotation = this.bindingsClass.getAnnotation(java.lang.annotation.Annotation.class);
+        assertNull(annotation, "annotation java.lang.annotation.Annotation should not be returned");
+        annotation = this.bindingsClass.getAnnotation(java.lang.annotation.Documented.class);
+        assertNull(annotation, "annotation java.lang.annotation.Documented should not be returned");
+        annotation = this.bindingsClass.getAnnotation(java.lang.annotation.Inherited.class);
+        assertNull(annotation, "annotation java.lang.annotation.Inherited should not be returned");
+        annotation = this.bindingsClass.getAnnotation(java.lang.annotation.Retention.class);
+        assertNull(annotation, "annotation java.lang.annotation.Retention should not be returned");
+        annotation = this.bindingsClass.getAnnotation(java.lang.annotation.Target.class);
+        assertNull(annotation, "annotation java.lang.annotation.Target should not be returned");
+        annotation = this.bindingsClass.getAnnotation(java.lang.Deprecated.class);
+        assertNull(annotation, "annotation java.lang.Deprecated should not be returned");
+        annotation = this.bindingsClass.getAnnotation(java.lang.Override.class);
+        assertNull(annotation, "annotation java.lang.Override should not be returned");
+        annotation = this.bindingsClass.getAnnotation(java.lang.SuppressWarnings.class);
+        assertNull(annotation, "annotation java.lang.SuppressWarnings should not be returned");
+    }
+
+    /**
      * Test for method javax.script.Bindings.getClass().getEnclosingClass()
      */
     protected void testGetEnclosingClass() {



More information about the distro-pkg-dev mailing list