Mercurial > hg > rhino-tests
view src/org/RhinoTests/SimpleScriptContextTest.java @ 362:bd78ec86c792 draft
Ten new tests added into SimpleScriptContextTest.
author | ptisnovs |
---|---|
date | Fri, 16 May 2014 09:39:20 +0200 |
parents | 8fa0f2667f65 |
children | 67c8a396f43f |
line wrap: on
line source
/* Rhino test framework Copyright (C) 2011, 2012, 2013, 2014 Red Hat This file is part of IcedTea. IcedTea is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. IcedTea is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with IcedTea; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package org.RhinoTests; import javax.script.ScriptContext; import javax.script.SimpleScriptContext; /** * Basic ScriptContext test suite. Following tests checks the interface * javax.script.SimpleScriptContext. * * @author Pavel Tisnovsky */ public class SimpleScriptContextTest extends BaseRhinoTest { @Override protected void setUp(String[] args) { // this block could be empty return; } @Override protected void tearDown() { // this block could be empty return; } /** * Test for toString() method. */ protected void testToString() { // tested object Object object = new SimpleScriptContext(); // call the toString() method String string = object.toString(); assertTrue(string != null, "toString() method returned null!"); assertTrue(string.startsWith("javax.script.SimpleScriptContext"), "bad toString() return value " + string); } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute1() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute("name", "value", ScriptContext.ENGINE_SCOPE); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute2() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute("name", "", ScriptContext.ENGINE_SCOPE); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute3() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute("name", null, ScriptContext.ENGINE_SCOPE); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute4() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute("", "value", ScriptContext.ENGINE_SCOPE); throw new AssertionError("ScriptContext.setAttribute(\"\", \"value\", ScriptContext.ENGINE_SCOPE.) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute5() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute("", "", ScriptContext.ENGINE_SCOPE); throw new AssertionError("ScriptContext.setAttribute(\"\", \"\", ScriptContext.ENGINE_SCOPE) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute6() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute("", null, ScriptContext.ENGINE_SCOPE); throw new AssertionError("ScriptContext.setAttribute(\"\", null, ScriptContext.ENGINE_SCOPE) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute7() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE); throw new AssertionError("ScriptContext.setAttribute(null, \"value\", ScriptContext.ENGINE_SCOPE) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute8() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute(null, "", ScriptContext.ENGINE_SCOPE); throw new AssertionError("ScriptContext.setAttribute(null, \"\", ScriptContext.ENGINE_SCOPE) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute9() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute(null, null, ScriptContext.ENGINE_SCOPE); throw new AssertionError("ScriptContext.setAttribute(null, null, ScriptContext.ENGINE_SCOPE) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method SimpleScriptContext.setAttribute(). */ protected void testSetAttribute10() { // tested object SimpleScriptContext object = new SimpleScriptContext(); try { object.setAttribute("name", "value", 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 */ public static void main(String[] args) { new SimpleScriptContextTest().doTests(args); } }