@Test
public void testCompositePersistence_EndToEnd() {

    OffHeapPersistence<Car, Integer> offHeapPersistence = OffHeapPersistence.onPrimaryKey(Car.CAR_ID);
    DiskPersistence<Car, Integer> diskPersistence = DiskPersistence.onPrimaryKey(Car.CAR_ID);
    IndexedCollection<Car> collection = new ConcurrentIndexedCollection<Car>(CompositePersistence.of(
            offHeapPersistence,
            diskPersistence,
            singletonList(OnHeapPersistence.onPrimaryKey(Car.CAR_ID))
    ));
    collection.addIndex(DiskIndex.onAttribute(Car.MANUFACTURER));
    collection.addIndex(OffHeapIndex.onAttribute(Car.MODEL));
    collection.addIndex(NavigableIndex.onAttribute(Car.PRICE));
    collection.addAll(CarFactory.createCollectionOfCars(1000));
    ResultSet<Car> results = null;
    try {
        results = collection.retrieve(
                and(
                        or(
                                equal(Car.MANUFACTURER, "Ford"),
                                equal(Car.MODEL, "Avensis")
                        ),
                        lessThan(Car.PRICE, 6000.0)
                )
        );
        Assert.assertEquals(300, results.size());
        Assert.assertTrue(offHeapPersistence.getBytesUsed() > 4096); // example: 163840
        Assert.assertTrue(diskPersistence.getBytesUsed() > 4096); // example: 30720
    }
    finally {
        CloseableRequestResources.closeQuietly(results);
        collection.clear();
        offHeapPersistence.close();
        diskPersistence.getFile().delete();
    }
}