# HG changeset patch # User Pavel Tisnovsky # Date 1397560781 -7200 # Node ID 6cb1ff232c3906b49bc54fa9e09b797b64006204 # Parent 9b40969f01e3f5b17852dca46fec912668965292 Nine new tests added into BindingsTest. diff -r 9b40969f01e3 -r 6cb1ff232c39 ChangeLog --- a/ChangeLog Thu Apr 10 11:05:49 2014 +0200 +++ b/ChangeLog Tue Apr 15 13:19:41 2014 +0200 @@ -1,3 +1,8 @@ +2014-04-15 Pavel Tisnovsky + + * src/org/RhinoTests/BindingsTest.java: + Nine new tests added into BindingsTest. + 2014-04-10 Pavel Tisnovsky * src/org/RhinoTests/CompiledScriptTest.java: diff -r 9b40969f01e3 -r 6cb1ff232c39 src/org/RhinoTests/BindingsTest.java --- a/src/org/RhinoTests/BindingsTest.java Thu Apr 10 11:05:49 2014 +0200 +++ b/src/org/RhinoTests/BindingsTest.java Tue Apr 15 13:19:41 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. @@ -41,15 +41,18 @@ package org.RhinoTests; import java.util.HashMap; +import java.util.Hashtable; import java.util.Map; +import java.util.LinkedHashMap; import java.util.TreeMap; import javax.script.SimpleBindings; import javax.script.Bindings; /** + * Test for the class javax.script.Bingings. + * * @author Pavel Tisnovsky - * */ public class BindingsTest extends BaseRhinoTest { @@ -65,6 +68,9 @@ return; } + /** + * Test of the default constructor. + */ protected void testConstructor1() { Bindings bindings = new SimpleBindings(); assertNotNull(bindings, "new SimpleBindings() failed"); @@ -72,6 +78,9 @@ assertTrue(bindings.size() == 0, "bindings should be empty"); } + /** + * Test of the constructor with Map parameter.. + */ protected void testConstructor2() { Bindings bindings = new SimpleBindings(new HashMap()); assertNotNull(bindings, "new SimpleBindings() failed"); @@ -87,6 +96,20 @@ } protected void testConstructor4() { + Bindings bindings = new SimpleBindings(new Hashtable()); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(bindings.isEmpty(), "bindings should be empty"); + assertTrue(bindings.size() == 0, "bindings should be empty"); + } + + protected void testConstructor5() { + Bindings bindings = new SimpleBindings(new LinkedHashMap()); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(bindings.isEmpty(), "bindings should be empty"); + assertTrue(bindings.size() == 0, "bindings should be empty"); + } + + protected void testConstructor6() { Map map = new HashMap(); map.put("key", "value"); Bindings bindings = new SimpleBindings(map); @@ -97,7 +120,7 @@ assertEquals(bindings.get("key"), "value", "wrong value returned"); } - protected void testConstructor5() { + protected void testConstructor7() { Map map = new TreeMap(); map.put("key", "value"); Bindings bindings = new SimpleBindings(map); @@ -108,7 +131,29 @@ assertEquals(bindings.get("key"), "value", "wrong value returned"); } - protected void testConstructor6() { + protected void testConstructor8() { + Map hashtable = new Hashtable(); + hashtable.put("key", "value"); + Bindings bindings = new SimpleBindings(hashtable); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(!bindings.isEmpty(), "bindings should not be empty"); + assertTrue(bindings.size() == 1, "bindings should not be empty"); + assertNotNull(bindings.get("key"), "this object should be stored in bindings"); + assertEquals(bindings.get("key"), "value", "wrong value returned"); + } + + protected void testConstructor9() { + Map hashtable = new LinkedHashMap(); + hashtable.put("key", "value"); + Bindings bindings = new SimpleBindings(hashtable); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(!bindings.isEmpty(), "bindings should not be empty"); + assertTrue(bindings.size() == 1, "bindings should not be empty"); + assertNotNull(bindings.get("key"), "this object should be stored in bindings"); + assertEquals(bindings.get("key"), "value", "wrong value returned"); + } + + protected void testConstructor10() { Map map = new HashMap(); map.put("key", null); Bindings bindings = new SimpleBindings(map); @@ -118,8 +163,51 @@ assertNull(bindings.get("key"), "this object should be stored in bindings"); } - protected void testConstructor7() { + protected void testConstructor11() { + Map map = new TreeMap(); + map.put("key", null); + Bindings bindings = new SimpleBindings(map); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(!bindings.isEmpty(), "bindings should not be empty"); + assertTrue(bindings.size() == 1, "bindings should not be empty"); + assertNull(bindings.get("key"), "this object should be stored in bindings"); + } + + protected void testConstructor12() { + Map map = new LinkedHashMap(); + map.put("key", "value"); + map.put("key", null); + Bindings bindings = new SimpleBindings(map); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(!bindings.isEmpty(), "bindings should not be empty"); + assertTrue(bindings.size() == 1, "bindings should not be empty"); + assertNull(bindings.get("key"), "this object should be stored in bindings"); + } + + protected void testConstructor13() { Map map = new HashMap(); + map.put("key", "value"); + map.put("key", null); + Bindings bindings = new SimpleBindings(map); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(!bindings.isEmpty(), "bindings should not be empty"); + assertTrue(bindings.size() == 1, "bindings should not be empty"); + assertNull(bindings.get("key"), "this object should be stored in bindings"); + } + + protected void testConstructor14() { + Map map = new TreeMap(); + map.put("key", "value"); + map.put("key", null); + Bindings bindings = new SimpleBindings(map); + assertNotNull(bindings, "new SimpleBindings() failed"); + assertTrue(!bindings.isEmpty(), "bindings should not be empty"); + assertTrue(bindings.size() == 1, "bindings should not be empty"); + assertNull(bindings.get("key"), "this object should be stored in bindings"); + } + + protected void testConstructor15() { + Map map = new LinkedHashMap(); map.put("key", null); Bindings bindings = new SimpleBindings(map); assertNotNull(bindings, "new SimpleBindings() failed");