Mercurial > hg > rhino-tests
changeset 249:c8b6ebc43fa5 draft
Added new test testCast (that checks Class.cast() method) into test
test suite ScriptExceptionClassTest.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Wed, 09 Oct 2013 13:44:15 +0200 |
parents | 0a809843f715 |
children | ffa80879d9af |
files | ChangeLog src/org/RhinoTests/ScriptExceptionClassTest.java |
diffstat | 2 files changed, 204 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Oct 08 10:06:10 2013 +0200 +++ b/ChangeLog Wed Oct 09 13:44:15 2013 +0200 @@ -1,3 +1,9 @@ +2013-10-09 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/ScriptExceptionClassTest.java: + Added new test testCast (that checks Class.cast() method) into test + test suite ScriptExceptionClassTest. + 2013-10-08 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/ScriptEngineFactoryClassTest.java:
--- a/src/org/RhinoTests/ScriptExceptionClassTest.java Tue Oct 08 10:06:10 2013 +0200 +++ b/src/org/RhinoTests/ScriptExceptionClassTest.java Wed Oct 09 13:44:15 2013 +0200 @@ -1448,6 +1448,204 @@ } /** + * Test for method javax.script.ScriptException.getClass().cast() + */ + protected void testCast() { + try { + this.scriptExceptionClass.cast(new javax.script.ScriptException("script exception")); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + + try { + this.scriptExceptionClass.cast(new Object()); + throw new AssertionError("Class.cast(new Object()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new Object().getClass()); + throw new AssertionError("Class.cast(new Object().getClass()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new String()); + throw new AssertionError("Class.cast(new String()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Boolean.valueOf(true)); + throw new AssertionError("Class.cast(Boolean.valueOf(true)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Boolean.valueOf(false)); + throw new AssertionError("Class.cast(Boolean.valueOf(false)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Byte.valueOf((byte)42)); + throw new AssertionError("Class.cast(Byte.valueOf((byte)42)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Short.valueOf((short)42)); + throw new AssertionError("Class.cast(Short.valueOf((short)42)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Integer.valueOf(42)); + throw new AssertionError("Class.cast(Integer.valueOf(42)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Long.valueOf(42L)); + throw new AssertionError("Class.cast(Long.valueOf(42L)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Float.valueOf(42f)); + throw new AssertionError("Class.cast(Float.valueOf(42f)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(Double.valueOf(42.)); + throw new AssertionError("Class.cast(Double.valueOf(42.)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new Throwable()); + throw new AssertionError("Class.cast(new Throwable()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new RuntimeException()); + throw new AssertionError("Class.cast(new RuntimeException()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new Error()); + throw new AssertionError("Class.cast(new Error()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new java.lang.String()); + throw new AssertionError("Class.cast(new java.lang.String()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new java.lang.StringBuffer()); + throw new AssertionError("Class.cast(new java.lang.StringBuffer()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new java.lang.StringBuilder()); + throw new AssertionError("Class.cast(new java.lang.StringBuilder()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(java.awt.Color.black); + throw new AssertionError("Class.cast(java.awt.Color.black) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new java.awt.Frame()); + throw new AssertionError("Class.cast(new java.awt.Frame()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new java.awt.Frame(new String())); + throw new AssertionError("Class.cast(new java.awt.Frame(new String())) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new javax.swing.JLabel()); + throw new AssertionError("Class.cast(new javax.swing.JLabel()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new javax.swing.JLabel(new String())); + throw new AssertionError("Class.cast(new javax.swing.JLabel(new String())) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptExceptionClass.cast(new javax.swing.JPanel()); + throw new AssertionError("Class.cast(new javax.swing.JPanel()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + } + + /** * Test for instanceof operator applied to a class javax.script.ScriptException */ @SuppressWarnings("cast")