/hg/rhino-tests: Added new test and updated three other tests in...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Jan 7 01:54:39 PST 2013


changeset 87019bd63c13 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=87019bd63c13
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Jan 07 10:57:47 2013 +0100

	Added new test and updated three other tests in the test case AbstractScriptEngineClassTest.


diffstat:

 ChangeLog                                             |   6 +
 src/org/RhinoTests/AbstractScriptEngineClassTest.java |  63 +++++++++++++++---
 2 files changed, 59 insertions(+), 10 deletions(-)

diffs (152 lines):

diff -r f2a6c496bf93 -r 87019bd63c13 ChangeLog
--- a/ChangeLog	Fri Dec 21 11:21:05 2012 +0100
+++ b/ChangeLog	Mon Jan 07 10:57:47 2013 +0100
@@ -1,3 +1,9 @@
+2013-01-07  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/AbstractScriptEngineClassTest.java:
+	Added new test for a method GetCanonicalName().
+	Updated tests GetFields(), GetDeclaredFields() and GetField().
+
 2012-12-21  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/ScriptEngineManagerClassTest.java:
diff -r f2a6c496bf93 -r 87019bd63c13 src/org/RhinoTests/AbstractScriptEngineClassTest.java
--- a/src/org/RhinoTests/AbstractScriptEngineClassTest.java	Fri Dec 21 11:21:05 2012 +0100
+++ b/src/org/RhinoTests/AbstractScriptEngineClassTest.java	Mon Jan 07 10:57:47 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.AbstractScriptEngine.getClass().getCanonicalName()
+     */
+    protected void testGetCanonicalName() {
+        String canonicalName = this.abstractScriptEngineClass.getCanonicalName();
+        assertEquals(canonicalName, "javax.script.AbstractScriptEngine",
+                "Method javax.script.AbstractScriptEngine.getClass().getCanonicalName() returns wrong value " + canonicalName);
+    }
+
+    /**
      * Test for method javax.script.AbstractScriptEngine.getClass().getSuperclass()
      */
     protected void testGetSuperclass() {
@@ -341,7 +351,7 @@
      */
     protected void testGetFields() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        final String[] fieldsThatShouldExist_jdk6 = {
             "public static final java.lang.String javax.script.ScriptEngine.ARGV",
             "public static final java.lang.String javax.script.ScriptEngine.FILENAME",
             "public static final java.lang.String javax.script.ScriptEngine.ENGINE",
@@ -350,6 +360,19 @@
             "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE",
             "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION",
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+            "public static final java.lang.String javax.script.ScriptEngine.ARGV",
+            "public static final java.lang.String javax.script.ScriptEngine.FILENAME",
+            "public static final java.lang.String javax.script.ScriptEngine.ENGINE",
+            "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION",
+            "public static final java.lang.String javax.script.ScriptEngine.NAME",
+            "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE",
+            "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION",
+        };
+
+        // get the right array of field signatures
+        final String[] fieldsThatShouldExist = getJavaVersion() < 7 ? fieldsThatShouldExist_jdk6 : fieldsThatShouldExist_jdk7;
+
         // get all fields
         Field[] fields = this.abstractScriptEngineClass.getFields();
         // and transform the array into a list of field names
@@ -358,7 +381,7 @@
             fieldsAsString.add(field.toString());
         }
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
+        for (String fieldThatShouldExists : fieldsThatShouldExist) {
             assertTrue(fieldsAsString.contains(fieldThatShouldExists),
                     "field " + fieldThatShouldExists + " not found");
         }
@@ -368,10 +391,18 @@
      * Test for method javax.script.AbstractScriptEngine.getClass().getDeclaredFields()
      */
     protected void testGetDeclaredFields() {
-        // following fields should be declared
-        final String[] fieldsThatShouldExists = {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
             "protected javax.script.ScriptContext javax.script.AbstractScriptEngine.context",
         };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+            "protected javax.script.ScriptContext javax.script.AbstractScriptEngine.context",
+        };
+
+        // get the right array of field signatures
+        // following fields should be declared
+        final String[] declaredFieldsThatShouldExist = getJavaVersion() < 7 ? declaredFieldsThatShouldExist_jdk6 : declaredFieldsThatShouldExist_jdk7;
+
         // get all declared fields
         Field[] declaredFields = this.abstractScriptEngineClass.getDeclaredFields();
         // and transform the array into a list of field names
@@ -380,9 +411,9 @@
             declaredFieldsAsString.add(field.toString());
         }
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
-            assertTrue(declaredFieldsAsString.contains(fieldThatShouldExists),
-                    "field " + fieldThatShouldExists + " not found");
+        for (String declaredFieldThatShouldExists : declaredFieldsThatShouldExist) {
+            assertTrue(declaredFieldsAsString.contains(declaredFieldThatShouldExists),
+                    "field " + declaredFieldThatShouldExists + " not found");
         }
     }
 
@@ -391,7 +422,7 @@
      */
     protected void testGetField() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        final String[] fieldsThatShouldExist_jdk6 = {
             "ARGV",
             "FILENAME",
             "ENGINE",
@@ -400,8 +431,20 @@
             "LANGUAGE",
             "LANGUAGE_VERSION",
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+            "ARGV",
+            "FILENAME",
+            "ENGINE",
+            "ENGINE_VERSION",
+            "NAME",
+            "LANGUAGE",
+            "LANGUAGE_VERSION",
+        };
+
+        final String[] fieldsThatShouldExist = getJavaVersion() < 7 ? fieldsThatShouldExist_jdk6 : fieldsThatShouldExist_jdk7;
+
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
+        for (String fieldThatShouldExists : fieldsThatShouldExist) {
             try {
                 Field field = this.abstractScriptEngineClass.getField(fieldThatShouldExists);
                 String fieldName = field.getName();



More information about the distro-pkg-dev mailing list