@Test
public void testAddToScriptHash() throws Exception {

    Map<String, Object> hash = new HashMap<String, Object>();
    addToScriptHash(hash, "x", "y", null, null);
    assertEquals("y", hash.get("x"));
    addToScriptHash(hash, "y", "", null, null);
    assertNull(hash.get("y"));
    assertFalse(hash.containsKey("y"));
    addToScriptHash(hash, "y1", null, null, null);
    assertNull(hash.get("y1"));
    assertFalse(hash.containsKey("y1"));
    addToScriptHash(hash, "st", "server", "", null);
    assertEquals("server", hash.get("st"));
    addToScriptHash(hash, "st1", "ajax", "ajax", null);
    assertNull(hash.get("st1"));
    assertFalse(hash.containsKey("st1"));
    addToScriptHash(hash, "st2", "", "ajax", null);
    assertNull(hash.get("st2"));
    assertFalse(hash.containsKey("st2"));
    addToScriptHash(hash, "null", null, "server", null);
    assertNull(hash.get("null"));
    assertFalse(hash.containsKey("null"));
    addToScriptHash(hash, "b", false, null, null);
    assertNull(hash.get("b"));
    assertFalse(hash.containsKey("b"));
    addToScriptHash(hash, "b1", true, null, null);
    assertEquals(Boolean.TRUE, hash.get("b1"));
    addToScriptHash(hash, "b2", true, "true", null);
    assertNull(hash.get("b2"));
    assertFalse(hash.containsKey("b2"));
    addToScriptHash(hash, "b3", false, "true", null);
    assertEquals(Boolean.FALSE, hash.get("b3"));
    addToScriptHash(hash, "b4", true, "false", null);
    assertEquals(Boolean.TRUE, hash.get("b4"));
    addToScriptHash(hash, "b5", false, "false", null);
    assertNull(hash.get("b5"));
    assertFalse(hash.containsKey("b5"));
    addToScriptHash(hash, "i", Integer.valueOf(0), null, null);
    assertEquals(Integer.valueOf(0), hash.get("i"));
    addToScriptHash(hash, "i1", Integer.valueOf(0), "0", null);
    assertNull(hash.get("i1"));
    assertFalse(hash.containsKey("i1"));
    addToScriptHash(hash, "i2", Integer.valueOf(0), "1", null);
    assertEquals(Integer.valueOf(0), hash.get("i2"));
    addToScriptHash(hash, "i3", Integer.MIN_VALUE, null, null);
    assertNull(hash.get("i3"));
    assertFalse(hash.containsKey("i3"));
    addToScriptHash(hash, "i4", Integer.MIN_VALUE, "0", null);
    assertNull(hash.get("i4"));
    assertFalse(hash.containsKey("i4"));
    addToScriptHash(hash, "plain", "test", null, ScriptHashVariableWrapper.noop);
    assertEquals("test", hash.get("plain"));
    addToScriptHash(hash, "plain1", "newtest", "blank", ScriptHashVariableWrapper.noop);
    assertEquals("newtest", hash.get("plain1"));
    addToScriptHash(hash, "onclick", "alert(1)", null, ScriptHashVariableWrapper.eventHandler);
    assertTrue(hash.get("onclick") instanceof JSFunctionDefinition);
    addToScriptHash(hash, "onclick1", "alert(1)", "no-val", ScriptHashVariableWrapper.eventHandler);
    assertTrue(hash.get("onclick1") instanceof JSFunctionDefinition);
}