FilesystemContentWriter implements ContentWriter { @Override public String writeSingle(String spaceId, String chunkChecksum, ChunkInputStream chunk, Map<String, String> properties) throws NotFoundException { AddContentResult result = writeContent(spaceId, chunk.getChunkId(), chunk, chunk.getChunkSize(), properties); String finalChecksum = chunk.getMD5(); if (chunkChecksum != null && chunk.md5Preserved()) { if (!chunkChecksum.equals(finalChecksum)) { result.setState(AddContentResult.State.ERROR); } } result.setMd5(finalChecksum); return finalChecksum; }  List<AddContentResult> getResults(); void ignore(String spaceId, String contentId, long contentSize); ChunksManifest write(String spaceId,
                                ChunkableContent chunkable); ChunksManifest write(String spaceId,
                                ChunkableContent chunkable,
                                Map<String, String> contentProperties); @Override String writeSingle(String spaceId,
                              String chunkChecksum,
                              ChunkInputStream chunk,
                              Map<String, String> properties); @Override String writeSingle(String spaceId,
                              String chunkChecksum,
                              ChunkInputStream chunk);  }
@Test public void testWriteSingle() throws NotFoundException, IOException { long contentSize = 1500; InputStream contentStream = createContentStream(contentSize); String spaceId = new File(destDir, "spaceId-1").getPath(); String contentId = "a/b/c/contentId"; boolean preserveMD5 = true; ChunkInputStream chunk = new ChunkInputStream(contentId, contentStream, contentSize, preserveMD5); IOUtils.closeQuietly(contentStream); String md5 = writer.writeSingle(spaceId, null, chunk); Assert.assertNotNull(md5); File file = new File(spaceId, contentId); Assert.assertTrue(file.exists()); String md5Real = calculateMD5(file); Assert.assertEquals(md5Real, md5); file.delete(); contentStream.reset(); chunk = new ChunkInputStream(contentId, contentStream, contentSize, preserveMD5); md5 = writer.writeSingle(spaceId, md5Real, chunk); Assert.assertNotNull(md5); Assert.assertEquals(md5, md5Real); }