Exemplo n.º 1
0
 public void testContainsKey() {
   assertTrue(_cache.containsKey("first key"));
   assertTrue(_cache.containsKey("second key"));
   assertTrue(_cache.containsKey("third key"));
   assertFalse(_cache.containsKey("fourth key"));
   assertFalse(_cache.containsKey("fifth key"));
 }
Exemplo n.º 2
0
  public void testClear() {
    _cache.clear();

    assertFalse(_cache.containsKey("first key"));
    assertFalse(_cache.containsKey("second key"));
    assertFalse(_cache.containsKey("third key"));
    assertFalse(_cache.containsKey("fourth key"));
    assertFalse(_cache.containsKey("fifth key"));
  }
Exemplo n.º 3
0
  public void testRemove() {
    assertEquals("third value", _cache.remove("third key"));

    assertTrue(_cache.containsKey("first key"));
    assertTrue(_cache.containsKey("second key"));
    assertFalse(_cache.containsKey("third key"));
    assertFalse(_cache.containsKey("fourth key"));
    assertFalse(_cache.containsKey("fifth key"));
  }
Exemplo n.º 4
0
  public void testPut() {
    assertEquals("third value", _cache.put("third key", "alternate third value"));
    assertNull(_cache.put("fourth key", "forth value"));

    assertTrue(_cache.containsKey("first key"));
    assertTrue(_cache.containsKey("second key"));
    assertTrue(_cache.containsKey("third key"));
    assertTrue(_cache.containsKey("fourth key"));
    assertFalse(_cache.containsKey("fifth key"));
  }
Exemplo n.º 5
0
  public void testPutAll() {
    HashMap map = new HashMap();
    map.put("fourth key", "forth value");
    map.put("fifth key", "fifth value");

    _cache.putAll(map);

    assertTrue(_cache.containsKey("first key"));
    assertTrue(_cache.containsKey("second key"));
    assertTrue(_cache.containsKey("third key"));
    assertTrue(_cache.containsKey("fourth key"));
    assertTrue(_cache.containsKey("fifth key"));
  }