DefaultBinaryManager extends LocalBinaryManager implements
        BinaryManagerStreamSupport { protected String storeAndDigest(FileSource source) throws IOException { File sourceFile = source.getFile(); InputStream in = source.getStream(); OutputStream out = new NullOutputStream(); String digest; try { digest = storeAndDigest(in, out); } finally { in.close(); out.close(); } File digestFile = getFileForDigest(digest, true); atomicMove(sourceFile, digestFile); source.setFile(digestFile); return digest; } DefaultBinaryManager(); @Override Binary getBinary(FileSource source);  }
@Test public void testStreamingCopies() throws IOException { DefaultBinaryManager binaryManager = new DefaultBinaryManager(); binaryManager.initialize(new BinaryManagerDescriptor()); assertEquals(0, countFiles(binaryManager.getStorageDir())); File file = File.createTempFile("test-", ".data", binaryManager.getStorageDir()); FileUtils.writeFile(file, CONTENT.getBytes("UTF-8")); FileSource source = new FileSource(file); binaryManager.storeAndDigest(source); assertFalse(file.exists()); assertTrue(source.getFile().exists()); binaryManager.close(); }