@Test
public void testExpand() {

    final long bytesToExpand = 102400;  // Expand by 100KB;
    DiskPersistence<Car, Integer> persistence = DiskPersistence.onPrimaryKey(Car.CAR_ID);
    @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>(persistence);
    cars.addAll(CarFactory.createCollectionOfCars(50));
    persistence.compact();
    long initialBytesUsed = persistence.getBytesUsed();
    Assert.assertTrue("Initial bytes used should be greater than zero: " + initialBytesUsed, initialBytesUsed > 0);
    persistence.expand(bytesToExpand);
    long bytesUsedAfterExpanding = persistence.getBytesUsed();
    Assert.assertTrue("Bytes used after expanding (" + bytesUsedAfterExpanding + ") should have been increased by at least bytes to expand (" + bytesToExpand + ") above initial bytes used (" + initialBytesUsed + ")", bytesUsedAfterExpanding >= (initialBytesUsed + bytesToExpand));
    persistence.compact();
    long bytesUsedAfterCompaction = persistence.getBytesUsed();
    Assert.assertTrue("Bytes used after compaction (" + bytesUsedAfterCompaction + ") should be equal to initial bytes used (" + initialBytesUsed + ")", bytesUsedAfterCompaction == initialBytesUsed);
    Assert.assertTrue("Failed to delete temp file:" + persistence.getFile(), persistence.getFile().delete());
}