@Test
  public void testUpdate() {
    byteBufferCacheAccessor.prepare(ByteBufferCacheAccessor.class + "#testUpdate", props);

    byteBufferCacheAccessor.update(0, "01234567890123456789", index);
    assertThat(index.get(0).value(), is("01234567890123456789"));
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(3L));

    char[] a = new char[70];
    Arrays.fill(a, '0');
    try {
      byteBufferCacheAccessor.update(0, new String(a), index);
    } catch (IllegalStateException ise) {
      assertThat(ise.getMessage(), is("no free block."));
    }
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(0L));
  }
  @Test
  public void testUpdateMulti() {
    byteBufferCacheAccessor.prepare(ByteBufferCacheAccessorTest.class + "#testUpdateMulti", props);

    Map<Integer, String> map = new HashMap<Integer, String>();
    map.put(0, "hoge");
    map.put(1, "fizzbuzzfizz");
    byteBufferCacheAccessor.update(map, index);
    assertThat(index.get(0).value(), is("hoge"));
    assertThat(index.get(1).value(), is("fizzbuzzfizz"));
    assertThat(index.size(), is(2));
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(3L));

    map.clear();
    map.put(1, "hogehoge");
    map.put(2, "fizzbuzzfizzbuzz");
    byteBufferCacheAccessor.update(map, index);
    assertThat(index.get(1).value(), is("hogehoge"));
    assertThat(index.get(2).value(), is("fizzbuzzfizzbuzz"));
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(4L));
  }
  @Test
  public void testRemoveMulti() {
    byteBufferCacheAccessor.prepare(ByteBufferCacheAccessorTest.class + "#testRemoveMulti", props);

    Map<Integer, String> map = new HashMap<Integer, String>();
    map.put(0, "hoge");
    map.put(1, "hoge");
    map.put(2, "hoge");
    byteBufferCacheAccessor.update(map, index);
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(3L));
    byteBufferCacheAccessor.remove(index.remove(Arrays.asList(0, 1, 2)));
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(0L));
  }
  @Test
  public void testRemove() {
    byteBufferCacheAccessor.prepare(ByteBufferCacheAccessor.class + "#testRemove", props);

    Map<Integer, String> map = new HashMap<Integer, String>();
    map.put(0, "hoge");
    map.put(1, "fizzbuzzfizz");
    byteBufferCacheAccessor.update(map, index);

    byteBufferCacheAccessor.remove(0, index.remove(0));
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(2L));

    byteBufferCacheAccessor.remove(0, index.remove(0)); // double remove has no side effect.
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(2L));

    byteBufferCacheAccessor.remove(1, index.remove(1));
    assertThat(byteBufferCacheAccessor.getAllocatedBlocks(), is(0L));
  }