DownloadResult downloadResult;
Future<DownloadResult> future;
final DownloadHandle handle = downloadHandler.getHandle(m_testContentURL);
// Start the download, but interrupt it after reading the first chunk of data...
future = handle.start(new DownloadProgressListener() {
@Override
public void progress(long bytesRead) {
System.out.printf("Downloaded %d bytes, interrupting download...%n", bytesRead);
Thread.currentThread().interrupt();
}
});
assertDownloadStopped(future);
File file = ((DownloadHandleImpl) handle).getDownloadFile();
long firstFileLength = file.length();
assertTrue(file.exists(), file.getName() + " does not exist?!");
assertTrue(firstFileLength > 0, "Nothing downloaded yet for " + file.getName() + "?");
assertTrue(firstFileLength < m_contentLength, "Everything downloaded for " + file.getName() + "?");
final DownloadHandle handle2 = downloadHandler.getHandle(m_testContentURL);
// Resume the download, but stop it after reading the first chunk of data...
future = handle2.start(new DownloadProgressListener() {
private int m_count = 5;
@Override
public void progress(long bytesRead) {
if (--m_count == 0) {