Search in sources :

Example 1 with MagnetDownloader

use of com.acgist.snail.downloader.magnet.MagnetDownloader in project snail by acgist.

the class TaskContextTest method testRestart.

@Test
void testRestart() throws DownloadException {
    SnailBuilder.newBuilder().enableAllProtocol().buildSync();
    final var taskContext = TaskContext.getInstance();
    ITaskSession taskSession = taskContext.download("1234567890123456789012345678901234567890");
    assertNotNull(taskSession);
    assertTrue(taskContext.allTask().size() > 0);
    this.log(taskSession.getClass());
    taskSession.setType(Type.TORRENT);
    taskSession.setStatus(Status.AWAIT);
    assertTrue(taskSession.buildDownloader() instanceof MagnetDownloader);
    taskSession.setTorrent("E://snail/902FFAA29EE632C8DC966ED9AB573409BA9A518E.torrent");
    taskSession.restart();
    assertNotNull(taskSession);
    assertTrue(taskContext.allTask().size() > 0);
    assertTrue(taskSession.buildDownloader() instanceof TorrentDownloader);
    this.log(taskSession.getClass());
    FileUtils.delete(taskSession.getFile());
    taskSession.delete();
}
Also used : MagnetDownloader(com.acgist.snail.downloader.magnet.MagnetDownloader) ITaskSession(com.acgist.snail.pojo.ITaskSession) TorrentDownloader(com.acgist.snail.downloader.torrent.TorrentDownloader) Test(org.junit.jupiter.api.Test)

Aggregations

MagnetDownloader (com.acgist.snail.downloader.magnet.MagnetDownloader)1 TorrentDownloader (com.acgist.snail.downloader.torrent.TorrentDownloader)1 ITaskSession (com.acgist.snail.pojo.ITaskSession)1 Test (org.junit.jupiter.api.Test)1