private void testOn(Directory dir, int writeSize, int readSize, Cache cache) throws IOException {
if (cache != null) cache.clear();//needed to make sure no chunks are left over in case of Infinispan implementation
final String filename = "chunkTest";
IndexOutput indexOutput = dir.createOutput(filename, IOContext.DEFAULT);
byte[] toWrite = fillBytes(writeSize);
indexOutput.writeBytes(toWrite, writeSize);
indexOutput.close();
if (cache != null) {
AssertJUnit.assertEquals(writeSize, DirectoryIntegrityCheck.deepCountFileSize(new FileCacheKey(INDEXNAME,filename), cache));
}
AssertJUnit.assertEquals(writeSize, indexOutput.length());