示例#1
0
  /** Tests removing all the entries, after they have been written to disk. */
  @Test
  public void testRemoveAllSlow() throws Exception {
    final CompoundStore diskStore = (CompoundStore) createDiskStore();

    // Add the entry
    final String value = "value";
    diskStore.put(new Element("key1", value));
    diskStore.put(new Element("key2", value));

    // Wait
    waitShorter();

    // Check the entry is there
    Object o1 = diskStore.unretrievedGet("key1");
    Object o2 = diskStore.unretrievedGet("key2");
    if (o1 instanceof Element) {
      assertEquals("DiskMarker", o2.getClass().getSimpleName());
    } else if (o2 instanceof Element) {
      assertEquals("DiskMarker", o1.getClass().getSimpleName());
    } else {
      fail("One of the elements should be in memory");
    }

    // Remove it
    diskStore.removeAll();

    // Check the entry is not there
    assertEquals(0, diskStore.getSize());
    assertEquals(0, diskStore.getOnDiskSize());
    assertNull(diskStore.get("key1"));
    assertNull(diskStore.get("key2"));
  }