Mercurial > hg > rhino-tests
changeset 365:67c8a396f43f draft
Ten new tests added into SimpleScriptContextTest.
author | ptisnovs |
---|---|
date | Tue, 20 May 2014 09:12:11 +0200 |
parents | 7d92b73d875d |
children | 946d61915104 |
files | ChangeLog src/org/RhinoTests/SimpleScriptContextTest.java |
diffstat | 2 files changed, 137 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue May 20 09:04:26 2014 +0200 +++ b/ChangeLog Tue May 20 09:12:11 2014 +0200 @@ -1,3 +1,8 @@ +2014-05-20 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/SimpleScriptContextTest.java: + Ten new tests added into SimpleScriptContextTest. + 2014-05-20 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/ScriptContextTest.java:
--- a/src/org/RhinoTests/SimpleScriptContextTest.java Tue May 20 09:04:26 2014 +0200 +++ b/src/org/RhinoTests/SimpleScriptContextTest.java Tue May 20 09:12:11 2014 +0200 @@ -40,9 +40,15 @@ package org.RhinoTests; +import java.util.HashMap; + +import javax.script.Bindings; +import javax.script.SimpleBindings; import javax.script.ScriptContext; import javax.script.SimpleScriptContext; + + /** * Basic ScriptContext test suite. Following tests checks the interface * javax.script.SimpleScriptContext. @@ -51,6 +57,12 @@ */ public class SimpleScriptContextTest extends BaseRhinoTest { + /** + * Many methods accepts ScriptContext.GLOBAL_SCOPE or ScriptContext.ENGINE_SCOPE + * as one integer parameters. Let's see how those methods works with different value. + */ + private final static Integer INVALID_SCOPE = 42; + @Override protected void setUp(String[] args) { // this block could be empty @@ -228,6 +240,126 @@ } /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute11() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute("name", "", ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute12() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute("name", null, ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute13() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute("", "value", ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute14() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute("", "", ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute15() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute("", null, ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute16() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute(null, "value", ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute17() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute(null, "", ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** + * Test for method SimpleScriptContext.setAttribute(). + */ + protected void testSetAttribute18() { + // tested object + SimpleScriptContext object = new SimpleScriptContext(); + try { + object.setAttribute(null, null, ScriptContext.GLOBAL_SCOPE); + } + catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e.getMessage()); + } + } + + /** * Entry point to this test case. * * @param args parameters passed from command line