changeset 221:e89e9eb83631 draft

Added new test testAsSubclass into the test suite InvocableClassTest.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Thu, 29 Aug 2013 11:22:40 +0200
parents fbd5a6ff705f
children e55f8607a4cf
files ChangeLog src/org/RhinoTests/InvocableClassTest.java
diffstat 2 files changed, 163 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Aug 28 11:21:38 2013 +0200
+++ b/ChangeLog	Thu Aug 29 11:22:40 2013 +0200
@@ -1,3 +1,8 @@
+2013-08-29  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/InvocableClassTest.java:
+	Added new test testAsSubclass into the test suite InvocableClassTest.
+
 2013-08-28  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/SimpleScriptContextClassTest.java:
--- a/src/org/RhinoTests/InvocableClassTest.java	Wed Aug 28 11:21:38 2013 +0200
+++ b/src/org/RhinoTests/InvocableClassTest.java	Thu Aug 29 11:22:40 2013 +0200
@@ -1072,6 +1072,164 @@
     }
 
     /**
+     * Test for method javax.script.Invocable.getClass().asSubclass()
+     */
+    protected void testAsSubclass() {
+        try {
+            this.invocableClass.asSubclass(invocableClass);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            throw new AssertionError(e.getMessage());
+        }
+
+        try {
+            this.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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.invocableClass.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 instanceof operator applied to a class javax.script.Invocable
      */
     @SuppressWarnings("cast")