### Question:
FSToFSTransferClient implements BinaryTransferClient { @Override public URI transfer(PID binPid, URI sourceFileUri) { return transfer(binPid, sourceFileUri, false); } FSToFSTransferClient(IngestSource source, StorageLocation destination); @Override URI transfer(PID binPid, URI sourceFileUri); @Override URI transferReplaceExisting(PID binPid, URI sourceFileUri); URI transfer(PID binPid, URI sourceFileUri, boolean allowOverwrite); @Override URI transferVersion(PID binPid, URI sourceFileUri); @Override void shutdown(); @Override boolean isTransferred(PID binPid, URI sourceUri); @Override BinaryDetails getStoredBinaryDetails(PID binPid);  }### Answer:
@Test(expected = BinaryTransferException.class) public void transferFileThatDoesNotExist() { Path sourceFile = sourcePath.resolve("nofilehere.txt"); client.transfer(binPid, sourceFile.toUri()); }
@Test public void transferFileReadOnlySource() throws Exception { when(ingestSource.isReadOnly()).thenReturn(true); Path sourceFile = createSourceFile(); client.transfer(binPid, sourceFile.toUri()); assertIsSourceFile(binDestPath); assertIsSourceFile(sourceFile); }
@Test public void transferFileModifiableSource() throws Exception { when(ingestSource.isReadOnly()).thenReturn(false); Path sourceFile = createSourceFile(); client.transfer(binPid, sourceFile.toUri()); assertIsSourceFile(binDestPath); }
@Test(expected = BinaryAlreadyExistsException.class) public void transferFileAlreadyExists() throws Exception { String existingContent = "I exist"; Files.createDirectories(binDestPath.getParent()); createFile(binDestPath, existingContent); Path sourceFile = createSourceFile(); client.transfer(binPid, sourceFile.toUri()); }
@Test public void interruptTransfer() throws Exception { when(ingestSource.isReadOnly()).thenReturn(true); Path sourceFile = sourcePath.resolve("file.txt"); try (RandomAccessFile filler = new RandomAccessFile(sourceFile.toFile(), "rw")) { filler.setLength(100 * 1024 * 1024); } Thread copyThread = new Thread() { @Override public void run() { try { client.transfer(binPid, sourceFile.toUri()); fail("Transfer must be interrupted"); } catch (BinaryTransferException e) { } } }; copyThread.start(); Thread.sleep(10); copyThread.interrupt(); assertFalse(Files.exists(binDestPath)); }