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, -1), cache, -1)); } AssertJUnit.assertEquals(writeSize, indexOutput.getFilePointer()); byte[] results = new byte[readSize]; IndexInput openInput = dir.openInput(filename, IOContext.DEFAULT); try { openInput.readBytes(results, 0, readSize); for (int i = 0; i < writeSize && i < readSize; i++) { AssertJUnit.assertEquals(results[i], toWrite[i]); } if (readSize > writeSize) AssertJUnit.fail("should have thrown an IOException for reading past EOF"); } catch (IOException ioe) { if (readSize <= writeSize) AssertJUnit.fail("should not have thrown an IOException" + ioe.getMessage()); } }
final long finalSize = REPEATABLE_BUFFER_SIZE + someTextAsBytes.length; assert ((InfinispanIndexOutput)io).length() == finalSize; assert ((InfinispanIndexOutput)io).length() == DirectoryIntegrityCheck.deepCountFileSize(new FileCacheKey(INDEXNAME,fileName, -1), cache, -1);
FileMetadata metadata = (FileMetadata) value; long totalFileSize = metadata.getSize(); long actualFileSize = deepCountFileSize(fileCacheKey, cache, affinitySegmentId); assertEquals(actualFileSize, totalFileSize); if (!ignoreFiles.contains(fileCacheKey.getFileName())) {