# HG changeset patch # User ptisnovs # Date 1400568763 -7200 # Node ID 6f5566e8e8cf653151dc4319ea09d581b173c641 # Parent bd78ec86c79237e1186ed07a3c1bd7f41284e07d Added JavaDoc and four new tests into SimpleBindingsTest suite. diff -r bd78ec86c792 -r 6f5566e8e8cf ChangeLog --- 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 + + * src/org/RhinoTests/SimpleBindingsTest.java: + Added JavaDoc and four new tests into SimpleBindingsTest suite. + 2014-05-16 Pavel Tisnovsky * src/org/RhinoTests/SimpleScriptContextTest.java: diff -r bd78ec86c792 -r 6f5566e8e8cf src/org/RhinoTests/SimpleBindingsTest.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()); 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()); 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()); + assertFalse(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + /** + * Test for method containsKey(String) + */ + protected void testContainsKey4() { + SimpleBindings simpleBindings = new SimpleBindings(new HashMap()); + 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()); + assertFalse(simpleBindings.containsKey("key"), "Bingings.containsKey() failed"); + } + + /** + * Test for method containsKey(String) + */ + protected void testContainsKey6() { + SimpleBindings simpleBindings = new SimpleBindings(new TreeMap()); + 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