Mercurial > hg > rhino-tests
changeset 251:00b968a159d4 draft
Added new test testCast (that checks Class.cast() method) into test
test suite ScriptEngineManagerClassTest.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Fri, 11 Oct 2013 10:20:55 +0200 |
parents | ffa80879d9af |
children | 91022c9f48b3 |
files | ChangeLog src/org/RhinoTests/ScriptEngineManagerClassTest.java |
diffstat | 2 files changed, 204 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Oct 10 10:42:18 2013 +0200 +++ b/ChangeLog Fri Oct 11 10:20:55 2013 +0200 @@ -1,3 +1,9 @@ +2013-10-11 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/ScriptEngineManagerClassTest.java: + Added new test testCast (that checks Class.cast() method) into test + test suite ScriptEngineManagerClassTest. + 2013-10-10 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/ScriptExceptionClassTest.java:
--- a/src/org/RhinoTests/ScriptEngineManagerClassTest.java Thu Oct 10 10:42:18 2013 +0200 +++ b/src/org/RhinoTests/ScriptEngineManagerClassTest.java Fri Oct 11 10:20:55 2013 +0200 @@ -1316,6 +1316,204 @@ } /** + * Test for method javax.script.ScriptEngineManager.getClass().cast() + */ + protected void testCast() { + try { + this.scriptEngineManagerClass.cast(new javax.script.ScriptEngineManager()); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + + try { + this.scriptEngineManagerClass.cast(new Object()); + throw new AssertionError("Class.cast(new Object()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(new Object().getClass()); + throw new AssertionError("Class.cast(new Object().getClass()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(new String()); + throw new AssertionError("Class.cast(new String()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(Boolean.valueOf(true)); + throw new AssertionError("Class.cast(Boolean.valueOf(true)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(Boolean.valueOf(false)); + throw new AssertionError("Class.cast(Boolean.valueOf(false)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.cast(Integer.valueOf(42)); + throw new AssertionError("Class.cast(Integer.valueOf(42)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(Long.valueOf(42L)); + throw new AssertionError("Class.cast(Long.valueOf(42L)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(Float.valueOf(42f)); + throw new AssertionError("Class.cast(Float.valueOf(42f)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(Double.valueOf(42.)); + throw new AssertionError("Class.cast(Double.valueOf(42.)) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(new Throwable()); + throw new AssertionError("Class.cast(new Throwable()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(new RuntimeException()); + throw new AssertionError("Class.cast(new RuntimeException()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.cast(new Error()); + throw new AssertionError("Class.cast(new Error()) does not throw any exception"); + } + catch (Exception e) { + // expected exception + } + + try { + this.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.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.scriptEngineManagerClass.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 method javax.script.ScriptEngineManager.getClass().newInstance() */ protected void testNewInstance() {