Mercurial > hg > rhino-tests
changeset 363:6f5566e8e8cf draft
Added JavaDoc and four new tests into SimpleBindingsTest suite.
author | ptisnovs |
---|---|
date | Tue, 20 May 2014 08:52:43 +0200 |
parents | bd78ec86c792 |
children | 7d92b73d875d |
files | ChangeLog src/org/RhinoTests/SimpleBindingsTest.java |
diffstat | 2 files changed, 95 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri May 16 09:39:20 2014 +0200 +++ b/ChangeLog Tue May 20 08:52:43 2014 +0200 @@ -1,3 +1,8 @@ +2014-05-20 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/SimpleBindingsTest.java: + Added JavaDoc and four new tests into SimpleBindingsTest suite. + 2014-05-16 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/SimpleScriptContextTest.java:
--- a/src/org/RhinoTests/SimpleBindingsTest.java Fri May 16 09:39:20 2014 +0200 +++ b/src/org/RhinoTests/SimpleBindingsTest.java Tue May 20 08:52:43 2014 +0200 @@ -1,7 +1,7 @@ /* Rhino test framework - Copyright (C) 2011, 2012 Red Hat + Copyright (C) 2011, 2012, 2013, 2014 Red Hat This file is part of IcedTea. @@ -46,8 +46,10 @@ import javax.script.SimpleBindings; /** + * Basic SimpleBindings test suite. Following tests checks the class + * javax.script.SimpleBindings. + * * @author Pavel Tisnovsky - * */ public class SimpleBindingsTest extends BaseRhinoTest { @@ -63,6 +65,9 @@ return; } + /** + * Test for constructor without parameters. + */ protected void testConstructor1() { SimpleBindings simpleBindings = new SimpleBindings(); assertNotNull(simpleBindings, "new SimpleBindings() failed"); @@ -70,6 +75,9 @@ assertTrue(simpleBindings.size() == 0, "simpleBindings should be empty"); } + /** + * Test for constructor with the parameter Map<String,Object> + */ protected void testConstructor2() { SimpleBindings simpleBindings = new SimpleBindings(new HashMap<String, Object>()); assertNotNull(simpleBindings, "new SimpleBindings() failed"); @@ -77,6 +85,9 @@ assertTrue(simpleBindings.size() == 0, "simpleBindings should be empty"); } + /** + * Test for constructor with the parameter Map<String,Object> + */ protected void testConstructor3() { SimpleBindings simpleBindings = new SimpleBindings(new TreeMap<String, Object>()); assertNotNull(simpleBindings, "new SimpleBindings() failed"); @@ -84,17 +95,60 @@ assertTrue(simpleBindings.size() == 0, "simpleBindings should be empty"); } + /** + * Test for method containsKey(String) + */ protected void testContainsKey1() { SimpleBindings simpleBindings = new SimpleBindings(); assertFalse(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); } + /** + * Test for method containsKey(String) + */ protected void testContainsKey2() { SimpleBindings simpleBindings = new SimpleBindings(); simpleBindings.put("key", "value"); assertTrue(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); } + /** + * Test for method containsKey(String) + */ + protected void testContainsKey3() { + SimpleBindings simpleBindings = new SimpleBindings(new HashMap<String, Object>()); + assertFalse(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + /** + * Test for method containsKey(String) + */ + protected void testContainsKey4() { + SimpleBindings simpleBindings = new SimpleBindings(new HashMap<String, Object>()); + simpleBindings.put("key", "value"); + assertTrue(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + /** + * Test for method containsKey(String) + */ + protected void testContainsKey5() { + SimpleBindings simpleBindings = new SimpleBindings(new TreeMap<String, Object>()); + assertFalse(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + /** + * Test for method containsKey(String) + */ + protected void testContainsKey6() { + SimpleBindings simpleBindings = new SimpleBindings(new TreeMap<String, Object>()); + simpleBindings.put("key", "value"); + assertTrue(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + /** + * Test for method containsKey(String) + */ protected void testContainsKeyNegative1() throws Exception { SimpleBindings simpleBindings = new SimpleBindings(); try { @@ -106,6 +160,9 @@ throw new Exception("NPE did not thrown as expected"); } + /** + * Test for method containsKey(String) + */ protected void testContainsKeyNegative2() throws Exception { SimpleBindings simpleBindings = new SimpleBindings(); try { @@ -117,6 +174,9 @@ throw new Exception("IllegalArgumentException did not thrown as expected"); } + /** + * Test for method containsKey(String) + */ protected void testContainsKeyNegative3() throws Exception { SimpleBindings simpleBindings = new SimpleBindings(); try { @@ -129,6 +189,34 @@ } /** + * Test for method containsKey(String) + */ + protected void testContainsKeyNegative4() throws Exception { + SimpleBindings simpleBindings = new SimpleBindings(); + try { + simpleBindings.containsKey(java.awt.Color.GREEN); + } + catch (ClassCastException e) { + return; + } + throw new Exception("ClassCastException did not thrown as expected"); + } + + /** + * Test for method containsKey(String) + */ + protected void testContainsKeyNegative5() throws Exception { + SimpleBindings simpleBindings = new SimpleBindings(); + try { + simpleBindings.containsKey(this); + } + 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