ChunkableContent implements Iterable<ChunkInputStream>, Iterator<ChunkInputStream> { public ChunkInputStream next() { throwIfChunkNotFullyRead(); addEntry(); long chunkSize = calculateNextChunkSize(); String chunkId = manifest.nextChunkId(); InputStream buffIS = new BufferedInputStream(largeStream, BUFFER_SIZE); return currentChunk = new ChunkInputStream(chunkId, buffIS, chunkSize, preserveChunkMD5s); } ChunkableContent(String contentId,
                            InputStream largeStream,
                            long contentSize,
                            long maxChunkSize);  ChunkableContent(String contentId,
                            String contentMimetype,
                            InputStream largeStream,
                            long contentSize,
                            long maxChunkSize); boolean hasNext(); ChunkInputStream next(); void remove(); Iterator<ChunkInputStream> iterator(); void setPreserveChunkMD5s(boolean preserveChunkMD5s); long getMaxChunkSize(); ChunksManifest getManifest(); ChunksManifest finalizeManifest();  }
@Test public void testNext() throws IOException { ChunkInputStream chunk = chunkable.next(); Assert.assertNotNull(chunk); verifyThrow(true); int bytesRead = 0; while (bytesRead < MAX_CHUNK_SIZE - 10) { chunk.read(); bytesRead++; } verifyThrow(true); while (bytesRead < MAX_CHUNK_SIZE) { chunk.read(); bytesRead++; } verifyThrow(false); Assert.assertEquals(bytesRead, MAX_CHUNK_SIZE); }