Mercurial > hg > rhino-tests
changeset 64:bba804edaeab draft
Added eight new tests to the test suite SimpleBindingsTest.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Mon, 19 Nov 2012 11:15:37 +0100 |
parents | 649ff1c652d1 |
children | 94369d709381 |
files | ChangeLog src/org/RhinoTests/SimpleBindingsTest.java |
diffstat | 2 files changed, 92 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Nov 16 11:46:08 2012 +0100 +++ b/ChangeLog Mon Nov 19 11:15:37 2012 +0100 @@ -1,3 +1,8 @@ +2012-11-19 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/SimpleBindingsTest.java: + Added eight new tests. + 2012-11-16 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/BindingsTest.java:
--- a/src/org/RhinoTests/SimpleBindingsTest.java Fri Nov 16 11:46:08 2012 +0100 +++ b/src/org/RhinoTests/SimpleBindingsTest.java Mon Nov 19 11:15:37 2012 +0100 @@ -1,7 +1,7 @@ /* Rhino test framework - Copyright (C) 2011 Red Hat + Copyright (C) 2011, 2012 Red Hat This file is part of IcedTea. @@ -40,18 +40,101 @@ package org.RhinoTests; +import java.util.HashMap; +import java.util.TreeMap; + +import javax.script.SimpleBindings; + /** - * TODO: not implemented - * @author ptisnovs + * @author Pavel Tisnovsky * */ -public class SimpleBindingsTest { +public class SimpleBindingsTest extends BaseRhinoTest { + + @Override + protected void setUp(String[] args) { + // this block could be empty + return; + } + + @Override + protected void tearDown() { + // this block could be empty + return; + } + + protected void testConstructor1() { + SimpleBindings simpleBindings = new SimpleBindings(); + assertNotNull(simpleBindings, "new SimpleBindings() failed"); + assertTrue(simpleBindings.isEmpty(), "simpleBindings should be empty"); + assertTrue(simpleBindings.size() == 0, "simpleBindings should be empty"); + } + + protected void testConstructor2() { + SimpleBindings simpleBindings = new SimpleBindings(new HashMap()); + assertNotNull(simpleBindings, "new SimpleBindings() failed"); + assertTrue(simpleBindings.isEmpty(), "simpleBindings should be empty"); + assertTrue(simpleBindings.size() == 0, "simpleBindings should be empty"); + } + + protected void testConstructor3() { + SimpleBindings simpleBindings = new SimpleBindings(new TreeMap()); + assertNotNull(simpleBindings, "new SimpleBindings() failed"); + assertTrue(simpleBindings.isEmpty(), "simpleBindings should be empty"); + assertTrue(simpleBindings.size() == 0, "simpleBindings should be empty"); + } + + protected void testContainsKey1() { + SimpleBindings simpleBindings = new SimpleBindings(); + assertFalse(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + protected void testContainsKey2() { + SimpleBindings simpleBindings = new SimpleBindings(); + simpleBindings.put("key", "value"); + assertTrue(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + protected void testContainsKeyNegative1() throws Exception { + SimpleBindings simpleBindings = new SimpleBindings(); + try { + simpleBindings.containsKey(null); + } + catch (NullPointerException e) { + return; + } + throw new Exception("NPE did not thrown as expected"); + } + + protected void testContainsKeyNegative2() throws Exception { + SimpleBindings simpleBindings = new SimpleBindings(); + try { + simpleBindings.containsKey(""); + } + catch (IllegalArgumentException e) { + return; + } + throw new Exception("IllegalArgumentException did not thrown as expected"); + } + + protected void testContainsKeyNegative3() throws Exception { + SimpleBindings simpleBindings = new SimpleBindings(); + try { + simpleBindings.containsKey(new Integer(42)); + } + catch (ClassCastException e) { + return; + } + throw new Exception("ClassCastException did not thrown as expected"); + } + /** * Entry point to this test case. * * @param args parameters passed from command line */ public static void main(String[] args) { + new SimpleBindingsTest().doTests(args); } }