/hg/rhino-tests: Added three tests into the test suite Invocable...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Jan 21 00:35:18 PST 2013


changeset 0c193d54de35 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=0c193d54de35
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Jan 21 09:38:26 2013 +0100

	Added three tests into the test suite InvocableClassTest.java: GetCanonicalName, GetConstructor and GetDeclaredConstructor.


diffstat:

 ChangeLog                                  |   6 ++
 src/org/RhinoTests/InvocableClassTest.java |  72 +++++++++++++++++++++++++++++-
 2 files changed, 77 insertions(+), 1 deletions(-)

diffs (116 lines):

diff -r fa939752e8db -r 0c193d54de35 ChangeLog
--- a/ChangeLog	Fri Jan 18 10:31:28 2013 +0100
+++ b/ChangeLog	Mon Jan 21 09:38:26 2013 +0100
@@ -1,3 +1,9 @@
+2013-01-21  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/InvocableClassTest.java:
+	Added three tests into this test suite: GetCanonicalName,
+	GetConstructor and GetDeclaredConstructor.
+
 2013-01-18  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/SimpleScriptContextClassTest.java:
diff -r fa939752e8db -r 0c193d54de35 src/org/RhinoTests/InvocableClassTest.java
--- a/src/org/RhinoTests/InvocableClassTest.java	Fri Jan 18 10:31:28 2013 +0100
+++ b/src/org/RhinoTests/InvocableClassTest.java	Mon Jan 21 09:38:26 2013 +0100
@@ -1,7 +1,7 @@
 /*
   Rhino test framework
 
-   Copyright (C) 2011, 2012  Red Hat
+   Copyright (C) 2011, 2012, 2013  Red Hat
 
 This file is part of IcedTea.
 
@@ -45,6 +45,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.TreeMap;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
@@ -261,6 +262,15 @@
     }
 
     /**
+     * Test for method javax.script.Invocable.getClass().getCanonicalName()
+     */
+    protected void testGetCanonicalName() {
+        String canonicalName = this.invocableClass.getCanonicalName();
+        assertEquals(canonicalName, "javax.script.Invocable",
+                "Method javax.script.Invocable.getClass().getCanonicalName() returns wrong value " + canonicalName);
+    }
+
+    /**
      * Test for method javax.script.Invocable.getClass().getSuperclass()
      */
     protected void testGetSuperclass() {
@@ -314,6 +324,66 @@
     }
 
     /**
+     * Test for method javax.script.Invocable.getClass().getConstructor()
+     */
+    protected void testGetConstructor() {
+        // following constructors should exist
+        Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+
+        Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, 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.invocableClass.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.Invocable.getClass().getDeclaredConstructor()
+     */
+    protected void testGetDeclaredConstructor() {
+        // following constructors should exist
+        Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+
+        Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, 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.invocableClass.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.Invocable.getClass().getFields()
      */
     protected void testGetFields() {



More information about the distro-pkg-dev mailing list