@Test public void testCreateChunksFrom5MBFileAndTestChunkSize() throws Exception { final int TOTAL_FILE_SIZE = 5*1024*1024; final int AVG_CHUNK_SIZE = 512*1024; File inputRandom5MBFile = TestFileUtil.createRandomFileInDirectory(tempDir, TOTAL_FILE_SIZE); File outputCopyOfRandom5MBFile = TestFileUtil.getRandomFilenameInDirectory(tempDir); FileOutputStream outputCopyOfRandom5MBFileOutputStream = new FileOutputStream(outputCopyOfRandom5MBFile); Chunker chunker = new TttdChunker(AVG_CHUNK_SIZE); Enumeration<Chunk> chunkEnumeration = chunker.createChunks(inputRandom5MBFile); Chunk lastChunk = null; while (chunkEnumeration.hasMoreElements()) { lastChunk = chunkEnumeration.nextElement(); assertNotNull("Chunk checksum should not be null.", lastChunk.getChecksum()); outputCopyOfRandom5MBFileOutputStream.write(lastChunk.getContent(), 0, lastChunk.getSize()); } outputCopyOfRandom5MBFileOutputStream.close(); byte[] inputFileChecksum = FileUtil.createChecksum(inputRandom5MBFile, TttdChunker.DEFAULT_DIGEST_ALG); byte[] outputFileChecksum = FileUtil.createChecksum(outputCopyOfRandom5MBFile, TttdChunker.DEFAULT_DIGEST_ALG); assertArrayEquals("Checksums of input and output file do not match.", inputFileChecksum, outputFileChecksum); assertArrayEquals("Last chunk's getFileChecksum() should be the file checksum.", inputFileChecksum, lastChunk.getFileChecksum()); }
@Override public ChunkEnumeration createChunks(File file) throws IOException { return new TTTDEnumeration(new FileInputStream(file)); }
TttdChunker extends Chunker { @Override public ChunkEnumeration createChunks(File file) throws IOException { return new TTTDEnumeration(new FileInputStream(file)); } }
TttdChunker extends Chunker { @Override public ChunkEnumeration createChunks(File file) throws IOException { return new TTTDEnumeration(new FileInputStream(file)); } TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize);  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg);  TttdChunker(int avgChunkSize);  TttdChunker(int avgChunkSize, int windowSize, String digestAlg, String fingerprintAlg);  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg, String fingerprintAlg); private  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg, String fingerprintAlg, String name); }
TttdChunker extends Chunker { @Override public ChunkEnumeration createChunks(File file) throws IOException { return new TTTDEnumeration(new FileInputStream(file)); } TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize);  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg);  TttdChunker(int avgChunkSize);  TttdChunker(int avgChunkSize, int windowSize, String digestAlg, String fingerprintAlg);  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg, String fingerprintAlg); private  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg, String fingerprintAlg, String name); @Override ChunkEnumeration createChunks(File file); @Override String getChecksumAlgorithm(); @Override String toString(); }
TttdChunker extends Chunker { @Override public ChunkEnumeration createChunks(File file) throws IOException { return new TTTDEnumeration(new FileInputStream(file)); } TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize);  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg);  TttdChunker(int avgChunkSize);  TttdChunker(int avgChunkSize, int windowSize, String digestAlg, String fingerprintAlg);  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg, String fingerprintAlg); private  TttdChunker(int Tmin, int Tmax, int D, int Ddash, int windowSize, String digestAlg, String fingerprintAlg, String name); @Override ChunkEnumeration createChunks(File file); @Override String getChecksumAlgorithm(); @Override String toString(); static final int DEFAULT_WINDOW_SIZE; static final String DEFAULT_DIGEST_ALG; static final String DEFAULT_FINGERPRINT_ALG; }