use of de.danoeh.antennapod.core.service.download.Downloader in project AntennaPod by AntennaPod.
the class HttpDownloaderTest method testCancel.
@Test
public void testCancel() {
final String url = httpServer.getBaseUrl() + "/delay/3";
FeedFileImpl feedFile = setupFeedFile(url, "delay", true);
final Downloader downloader = new HttpDownloader(new DownloadRequest(feedFile.getFile_url(), url, "delay", 0, feedFile.getTypeAsInt(), null, null, true, null, false));
Thread t = new Thread() {
@Override
public void run() {
downloader.call();
}
};
t.start();
downloader.cancel();
try {
t.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
DownloadStatus result = downloader.getResult();
assertTrue(result.isDone());
assertFalse(result.isSuccessful());
assertTrue(result.isCancelled());
assertFalse(new File(feedFile.getFile_url()).exists());
}
Aggregations