File filePath = new File(container.getTmpDirectory(), String.format("%s.%s", digest, transferId.toString()));
if (filePath.exists()) {
filePath.delete();
}
DigestBlob digestBlob = DigestBlob.resumeTransfer(
container, digest, transferId, currentPos);
BytesArray contentHead = new BytesArray("A".getBytes());
digestBlob.addToHead(contentHead);
BytesArray contentTail = new BytesArray("CDEFGHIJKL".getBytes());
digestBlob.addContent(contentTail, false);
contentHead = new BytesArray("B".getBytes());
digestBlob.addToHead(contentHead);
contentTail = new BytesArray("MNO".getBytes());
digestBlob.addContent(contentTail, true);
byte[] buffer = new byte[15];
FileInputStream stream = new FileInputStream(digestBlob.file());
stream.read(buffer, 0, 15);
assertEquals("ABCDEFGHIJKLMNO", new BytesArray(buffer).toUtf8().trim());
File file = digestBlob.commit();
assertTrue(file.exists());
file.delete();
}