コード例 #1
0
  @Test
  public void testExists() throws Exception {
    IObjectCache cache = new FileSerializedObjectCache(tempDir.getTempDir());

    String[] key = {"A", "B.txt"};
    cache.put(key, key, true);

    assertFalse(cache.exists(new String[] {"C"}));
    assertFalse(cache.exists(new String[] {"A", "C.txt"}));
    assertTrue(cache.exists(key));
  }
コード例 #2
0
  @Test
  public void testList() throws Exception {
    IObjectCache cache = new FileSerializedObjectCache(tempDir.getTempDir());

    String[] key = {"A", "B.txt"};
    cache.put(key, key, true);

    // should return empty
    List<String[]> result;
    result = cache.list(new String[] {"C"});
    assertNotNull(result);
    assertEquals(0, result.size());

    // listing parent should return they original key
    result = cache.list(new String[] {"A"});
    assertNotNull(result);
    assertEquals(1, result.size());
    String[] childKey = result.get(0);
    assertEquals(2, childKey.length);
    assertEquals("A", childKey[0]);
    assertEquals("B.txt", childKey[1]);
  }