@Test
public void reusesEmptySpaceWhenPuttingEntries() {
BTreePersistentIndexedCache<String, String> cache = new BTreePersistentIndexedCache<String, String>(
backingCache, new DefaultSerializer<String>(), (short) 4, 100);
TestFile cacheFile = tmpDir.getDir().file("cache.bin");
cache.put("key_1", "abcd");
cache.put("key_2", "abcd");
cache.put("key_3", "abcd");
cache.put("key_4", "abcd");
cache.put("key_5", "abcd");
long len = cacheFile.length();
assertThat(len, greaterThan(0L));
cache.put("key_1", "1234");
assertThat(cacheFile.length(), equalTo(len));
cache.remove("key_1");
cache.put("key_new", "a1b2");
assertThat(cacheFile.length(), equalTo(len));
cache.put("key_new", "longer value");
assertThat(cacheFile.length(), greaterThan(len));
len = cacheFile.length();
cache.put("key_1", "1234");
assertThat(cacheFile.length(), equalTo(len));
}