DuraStoreChunkSyncEndpoint extends DuraStoreSyncEndpoint { @Override protected void addUpdateContent(String contentId, MonitoredFile syncFile) { Map<String, String> properties = createProps(syncFile.getAbsolutePath(), getUsername()); final ContentStore store = getContentStore(); DuracloudContentWriter contentWriter = new DuracloudContentWriter(store, getUsername(), true, this.jumpStart); FileChunker chunker = new FileChunker(contentWriter, chunkerOptions); final String spaceId = getSpaceId(); chunker.addContent(spaceId, contentId, syncFile.getChecksum(), syncFile.length(), syncFile.getStream(), properties); cleanup(contentId, syncFile, store, spaceId); } DuraStoreChunkSyncEndpoint(ContentStore contentStore,
                                      String username,
                                      String spaceId,
                                      boolean syncDeletes,
                                      boolean jumpStart,
                                      long maxFileSize);  DuraStoreChunkSyncEndpoint(ContentStore contentStore,
                                      String username,
                                      String spaceId,
                                      boolean syncDeletes,
                                      long maxFileSize,
                                      boolean syncUpdates,
                                      boolean renameUpdates,
                                      boolean jumpStart,
                                      String updateSuffix,
                                      String prefix); @Override void deleteContent(String spaceId, String contentId); @Override Iterator<String> getFilesList();  }
@Test public void testAddNewContent() throws Exception { String contentId = "contentId"; String content = "content-file"; File contentFile = File.createTempFile("content", "file.txt"); FileUtils.writeStringToFile(contentFile, content); ChecksumUtil checksumUtil = new ChecksumUtil(ChecksumUtil.Algorithm.MD5); String checksum = checksumUtil.generateChecksum(contentFile); EasyMock.expect(contentStore.getSpaceContents(spaceId)) .andReturn(new ArrayList<String>().iterator()); EasyMock.expect(contentStore.getSpaceACLs(spaceId)) .andReturn(new HashMap<String, AclType>()) .anyTimes(); Capture<Map<String, String>> propsCapture = new Capture<Map<String, String>>(); EasyMock.expect(contentStore.addContent(EasyMock.eq(spaceId), EasyMock.eq(contentId), EasyMock.isA(InputStream.class), EasyMock.eq(contentFile.length()), EasyMock.eq("application/octet-stream"), EasyMock.eq(checksum), EasyMock.capture(propsCapture))) .andReturn(""); EasyMock.expect(contentStore.getSpaceContents(spaceId, contentId + ".dura-")).andReturn( new ArrayList<String>().iterator()); replayMocks(); setEndpoint(); MonitoredFile monitoredFile = new MonitoredFile(contentFile); endpoint.addUpdateContent(contentId, monitoredFile); Map<String, String> props = propsCapture.getValue(); assertNotNull(props); String creator = props.get(StorageProvider.PROPERTIES_CONTENT_CREATOR); assertEquals(username, creator); FileUtils.deleteQuietly(contentFile); }