changeset 231:78bab1320e16 draft

Added new test testAsSubclass into the test suite ScriptContextClassTest.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Thu, 12 Sep 2013 11:48:50 +0200
parents 9a2fbbac6020
children 61ed92f655a5
files ChangeLog src/org/RhinoTests/ScriptContextClassTest.java
diffstat 2 files changed, 165 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 11 09:52:46 2013 +0200
+++ b/ChangeLog	Thu Sep 12 11:48:50 2013 +0200
@@ -1,8 +1,14 @@
+2013-09-12  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/ScriptContextClassTest.java:
+	Added new test testAsSubclass into the test suite
+	ScriptContextClassTest.
+
 2013-09-11  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/ScriptContextClassTest.java:
 	Added new test testCast (that checks Class.cast() method) into test
-	test suite InvocableClassTest.
+	test suite ScriptContextClassTest.
 
 2013-09-10  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
--- a/src/org/RhinoTests/ScriptContextClassTest.java	Wed Sep 11 09:52:46 2013 +0200
+++ b/src/org/RhinoTests/ScriptContextClassTest.java	Thu Sep 12 11:48:50 2013 +0200
@@ -1214,6 +1214,164 @@
     }
 
     /**
+     * Test for method javax.script.ScriptContext.getClass().asSubclass()
+     */
+    protected void testAsSubclass() {
+        try {
+            this.scriptContextClass.asSubclass(scriptContextClass);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            throw new AssertionError(e.getMessage());
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Void.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Void.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Number.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Number.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Byte.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Byte.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Double.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Double.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Float.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Float.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Integer.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Integer.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Long.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Long.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.Short.class);
+            throw new AssertionError("Class.asSubclass(java.lang.Short.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.String.class);
+            throw new AssertionError("Class.asSubclass(java.lang.String.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.StringBuffer.class);
+            throw new AssertionError("Class.asSubclass(java.lang.StringBuffer.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.lang.StringBuilder.class);
+            throw new AssertionError("Class.asSubclass(java.lang.StringBuilder.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.awt.Color.class);
+            throw new AssertionError("Class.asSubclass(java.awt.Color.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.awt.Font.class);
+            throw new AssertionError("Class.asSubclass(java.awt.Font.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(java.awt.Image.class);
+            throw new AssertionError("Class.asSubclass(java.awt.Image.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(javax.swing.JPanel.class);
+            throw new AssertionError("Class.asSubclass(javax.swing.JPanel.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(javax.swing.JColorChooser.class);
+            throw new AssertionError("Class.asSubclass(javax.swing.JColorChooser.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(javax.swing.JScrollBar.class);
+            throw new AssertionError("Class.asSubclass(javax.swing.JScrollBar.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+        try {
+            this.scriptContextClass.asSubclass(javax.swing.JSlider.class);
+            throw new AssertionError("Class.asSubclass(javax.swing.JSlider.class) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+
+    }
+
+    /**
      * Test for method javax.script.ScriptContext.getClass().cast()
      */
     protected void testCast() {