@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)); }
@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)); }