示例#1
0
  private Cache<String, String> initialize() {
    Cache<String, String> cache = new Unlimited<String, String>();

    assertNull(cache.put("first key", "first value"));
    assertNull(cache.put("second key", "second value"));
    assertNull(cache.put("third key", "third value"));

    return cache;
  }
示例#2
0
  public void testPut() {
    Cache<String, String> cache = initialize();

    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"));
  }
示例#3
0
  public void testBasics() {
    assertEquals("unlimited", Unlimited.TYPE);

    Cache<String, String> cache = new Unlimited<String, String>();
    assertTrue(cache instanceof Unlimited);

    assertEquals("unlimited", cache.getType());

    assertFalse(cache.containsKey("first key"));
    assertFalse(cache.containsKey("second key"));

    assertNull(cache.put("first key", "first value"));

    assertTrue(cache.containsKey("first key"));
    assertFalse(cache.containsKey("second key"));

    assertNull(cache.put("second key", "second value"));

    assertTrue(cache.containsKey("first key"));
    assertTrue(cache.containsKey("second key"));
  }