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

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Jan 25 01:33:07 PST 2013


changeset 58a5ce1ad7bd in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=58a5ce1ad7bd
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Jan 25 10:36:06 2013 +0100

	Added three tests into the test CompilableClassTest: GetCanonicalName,
	GetConstructor and GetDeclaredConstructor.


diffstat:

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

diffs (116 lines):

diff -r 1f2be0d19c68 -r 58a5ce1ad7bd ChangeLog
--- a/ChangeLog	Tue Jan 22 09:34:41 2013 +0100
+++ b/ChangeLog	Fri Jan 25 10:36:06 2013 +0100
@@ -1,3 +1,9 @@
+2013-01-25  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/CompilableClassTest.java:
+	Added three tests into this test suite: GetCanonicalName,
+	GetConstructor and GetDeclaredConstructor.
+
 2013-01-22  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/SimpleBindingsClassTest.java:
diff -r 1f2be0d19c68 -r 58a5ce1ad7bd src/org/RhinoTests/CompilableClassTest.java
--- a/src/org/RhinoTests/CompilableClassTest.java	Tue Jan 22 09:34:41 2013 +0100
+++ b/src/org/RhinoTests/CompilableClassTest.java	Fri Jan 25 10:36:06 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.Compilable.getClass().getCanonicalName()
+     */
+    protected void testGetCanonicalName() {
+        String canonicalName = this.compilableClass.getCanonicalName();
+        assertEquals(canonicalName, "javax.script.Compilable",
+                "Method javax.script.Compilable.getClass().getCanonicalName() returns wrong value " + canonicalName);
+    }
+
+    /**
      * Test for method javax.script.Compilable.getClass().getSuperclass()
      */
     protected void testGetSuperclass() {
@@ -314,6 +324,66 @@
     }
 
     /**
+     * Test for method javax.script.Compilable.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.compilableClass.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.Compilable.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.compilableClass.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.Compilable.getClass().getFields()
      */
     protected void testGetFields() {



More information about the distro-pkg-dev mailing list