/hg/rhino-tests: Added two new tests getMethod() and getDeclared...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Jan 14 01:24:23 PST 2013


changeset cf26ea1499fc in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=cf26ea1499fc
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Jan 14 10:27:29 2013 +0100

	Added two new tests getMethod() and getDeclaredMethod() into test suite AbstractScriptEngineClassTest.java.


diffstat:

 ChangeLog                                             |    5 +
 src/org/RhinoTests/AbstractScriptEngineClassTest.java |  144 +++++++++++++++++-
 2 files changed, 141 insertions(+), 8 deletions(-)

diffs (209 lines):

diff -r eb0943f105e6 -r cf26ea1499fc ChangeLog
--- a/ChangeLog	Fri Jan 11 11:26:11 2013 +0100
+++ b/ChangeLog	Mon Jan 14 10:27:29 2013 +0100
@@ -1,3 +1,8 @@
+2013-01-12  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/AbstractScriptEngineClassTest.java:
+	Added two new tests: getMethod() and getDeclaredMethod().
+
 2013-01-11  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/AbstractScriptEngineClassTest.java:
diff -r eb0943f105e6 -r cf26ea1499fc src/org/RhinoTests/AbstractScriptEngineClassTest.java
--- a/src/org/RhinoTests/AbstractScriptEngineClassTest.java	Fri Jan 11 11:26:11 2013 +0100
+++ b/src/org/RhinoTests/AbstractScriptEngineClassTest.java	Mon Jan 14 10:27:29 2013 +0100
@@ -560,7 +560,7 @@
      */
     protected void testGetMethods() {
         // following methods should be inherited
-        final String[] methodsThatShouldExists_jdk6 = {
+        final String[] methodsThatShouldExist_jdk6 = {
             "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException",
             "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException",
             "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()",
@@ -586,7 +586,7 @@
             "public void javax.script.AbstractScriptEngine.setContext(javax.script.ScriptContext)",
         };
 
-        final String[] methodsThatShouldExists_jdk7 = {
+        final String[] methodsThatShouldExist_jdk7 = {
             "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException",
             "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException",
             "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()",
@@ -619,9 +619,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");
         }
@@ -632,7 +632,7 @@
      */
     protected void testGetDeclaredMethods() {
         // following methods should be declared
-        final String[] declaredMethodsThatShouldExists_jdk6 = {
+        final String[] declaredMethodsThatShouldExist_jdk6 = {
             "protected javax.script.ScriptContext javax.script.AbstractScriptEngine.getScriptContext(javax.script.Bindings)",
             "public java.lang.Object javax.script.AbstractScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException",
             "public java.lang.Object javax.script.AbstractScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException",
@@ -646,7 +646,7 @@
             "public void javax.script.AbstractScriptEngine.setContext(javax.script.ScriptContext)",
         };
 
-        final String[] declaredMethodsThatShouldExists_jdk7 = {
+        final String[] declaredMethodsThatShouldExist_jdk7 = {
             "protected javax.script.ScriptContext javax.script.AbstractScriptEngine.getScriptContext(javax.script.Bindings)",
             "public java.lang.Object javax.script.AbstractScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException",
             "public java.lang.Object javax.script.AbstractScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException",
@@ -667,15 +667,143 @@
         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.AbstractScriptEngine.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.String.class});
+        methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("getContext", new Class[] {});
+        methodsThatShouldExist_jdk6.put("setContext", new Class[] {javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk6.put("getBindings", new Class[] {int.class});
+        methodsThatShouldExist_jdk6.put("setBindings", new Class[] {javax.script.Bindings.class, int.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class});
+        methodsThatShouldExist_jdk6.put("wait", new Class[] {long.class});
+        methodsThatShouldExist_jdk6.put("wait", new Class[] {long.class, int.class});
+        methodsThatShouldExist_jdk6.put("wait", new Class[] {});
+        methodsThatShouldExist_jdk6.put("hashCode", new Class[] {});
+        methodsThatShouldExist_jdk6.put("getClass", new Class[] {});
+        methodsThatShouldExist_jdk6.put("equals", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("toString", new Class[] {});
+        methodsThatShouldExist_jdk6.put("notify", new Class[] {});
+        methodsThatShouldExist_jdk6.put("notifyAll", new Class[] {});
+        methodsThatShouldExist_jdk6.put("getFactory", new Class[] {});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk6.put("createBindings", new Class[] {});
+
+        Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.String.class});
+        methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("getContext", new Class[] {});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class});
+        methodsThatShouldExist_jdk7.put("getBindings", new Class[] {int.class});
+        methodsThatShouldExist_jdk7.put("setBindings", new Class[] {javax.script.Bindings.class, int.class});
+        methodsThatShouldExist_jdk7.put("setContext", new Class[] {javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk7.put("wait", new Class[] {long.class, int.class});
+        methodsThatShouldExist_jdk7.put("wait", new Class[] {long.class});
+        methodsThatShouldExist_jdk7.put("wait", new Class[] {});
+        methodsThatShouldExist_jdk7.put("equals", new Class[] {java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("toString", new Class[] {});
+        methodsThatShouldExist_jdk7.put("hashCode", new Class[] {});
+        methodsThatShouldExist_jdk7.put("getClass", new Class[] {});
+        methodsThatShouldExist_jdk7.put("notify", new Class[] {});
+        methodsThatShouldExist_jdk7.put("notifyAll", new Class[] {});
+        methodsThatShouldExist_jdk7.put("getFactory", new Class[] {});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk7.put("createBindings", new 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.abstractScriptEngineClass.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.AbstractScriptEngine.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.String.class});
+        methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk6.put("getContext", new Class[] {});
+        methodsThatShouldExist_jdk6.put("setContext", new Class[] {javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk6.put("getBindings", new Class[] {int.class});
+        methodsThatShouldExist_jdk6.put("setBindings", new Class[] {javax.script.Bindings.class, int.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class});
+        methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class});
+        methodsThatShouldExist_jdk6.put("getScriptContext", new Class[] {javax.script.Bindings.class});
+
+        Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+        methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.String.class});
+        methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class});
+        methodsThatShouldExist_jdk7.put("getContext", new Class[] {});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class});
+        methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class});
+        methodsThatShouldExist_jdk7.put("getBindings", new Class[] {int.class});
+        methodsThatShouldExist_jdk7.put("setBindings", new Class[] {javax.script.Bindings.class, int.class});
+        methodsThatShouldExist_jdk7.put("setContext", new Class[] {javax.script.ScriptContext.class});
+        methodsThatShouldExist_jdk7.put("getScriptContext", new Class[] {javax.script.Bindings.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.abstractScriptEngineClass.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.AbstractScriptEngine.getClass().getAnnotations()
      */
     protected void testGetAnnotations() {



More information about the distro-pkg-dev mailing list