use of com.acgist.snail.pojo.ITaskSession in project snail by acgist.
the class TaskTableCell method updateItem.
@Override
public void updateItem(String value, boolean empty) {
super.updateItem(value, empty);
final HBox box = new HBox();
final ITaskSession taskSession = this.getTableRow().getItem();
if (taskSession != null) {
final Text name = new Text(value);
if (this.pos != null) {
box.setAlignment(this.pos);
}
if (this.icon) {
final FileType fileType = taskSession.getFileType();
final Label fileLabel = Fonts.fileTypeIconLabel(fileType);
box.getChildren().add(fileLabel);
}
if (this.tooltip) {
this.setTooltip(Tooltips.newTooltip(value));
}
box.getChildren().add(name);
}
this.setGraphic(box);
}
use of com.acgist.snail.pojo.ITaskSession in project snail by acgist.
the class HlsContextTest method testHlsContext.
@Test
void testHlsContext() throws DownloadException {
final String id = UUID.randomUUID().toString();
final TaskEntity task = new TaskEntity();
task.setId(id);
task.setName("acgist");
final ITaskSession session = TaskSession.newInstance(task);
assertDoesNotThrow(() -> {
HlsContext.getInstance().m3u8(id, new M3u8(Type.FILE, null, List.of()));
HlsContext.getInstance().hlsSession(session);
HlsContext.getInstance().remove(session);
});
}
use of com.acgist.snail.pojo.ITaskSession in project snail by acgist.
the class ProtocolContextTest method testBuildTaskSession.
@Test
void testBuildTaskSession() throws DownloadException {
SnailBuilder.newBuilder().enableAllProtocol().buildSync();
ITaskSession result;
result = ProtocolContext.getInstance().buildTaskSession("https://www.acgist.com");
assertNotNull(result);
this.log(result);
// result = ProtocolContext.getInstance().buildTaskSession("641000d9be79ad8947701c338c06211ba69e1b09");
// assertNotNull(result);
// this.log(result);
// result = ProtocolContext.getInstance().buildTaskSession(Base32Utils.encode(StringUtils.unhex("641000d9be79ad8947701c338c06211ba69e1b09")));
// assertNotNull(result);
// this.log(result);
// result = ProtocolContext.getInstance().buildTaskSession("thunder://QUFodHRwOi8vdXBvcy1oei1taXJyb3Jic3l1LmFjZ3ZpZGVvLmNvbS91cGdjeGNvZGUvMjIvNjkvMTI0NDY5MjIvMTI0NDY5MjItMS02NC5mbHY/ZT1pZzhldXhaTTJyTmNOYmhIaGJVVmhvTXpuV05CaHdkRXRvOGc1WDEwdWdOY1hCQl8mZGVhZGxpbmU9MTU2MTAyMTI1NCZnZW49cGxheXVybCZuYnM9MSZvaT0xNzAzMTc4Nzk0Jm9zPWJzeXUmcGxhdGZvcm09aHRtbDUmdHJpZD1kZWIzMTdkMjI0NDc0ZDg5YWI4YmI1ZDgzNWMzMGY3MyZ1aXBrPTUmdXBzaWc9YWY3NmExOTUyYjFlNjZhYmQ0NzBiNmRmOWYyNTA2MWImdXBhcmFtcz1lLGRlYWRsaW5lLGdlbixuYnMsb2ksb3MscGxhdGZvcm0sdHJpZCx1aXBrJm1pZD00NTU5MjY3Wlo==");
// assertNotNull(result);
// this.log(result);
// result = ProtocolContext.getInstance().buildTaskSession("E:/snail/b3e9dcb123b80078aa5ace79323f925e8f755a6a.torrent");
// assertNotNull(result);
// this.log(result);
}
use of com.acgist.snail.pojo.ITaskSession in project snail by acgist.
the class TaskContextTest method testNewTask.
@Test
void testNewTask() throws DownloadException {
SnailBuilder.newBuilder().buildSync();
final var taskContext = TaskContext.getInstance();
var exception = assertThrows(DownloadException.class, () -> taskContext.download("https://www.acgist.com"));
this.log(exception.getMessage());
exception = assertThrows(DownloadException.class, () -> taskContext.submit(null));
this.log(exception.getMessage());
ProtocolContext.getInstance().register(HttpProtocol.getInstance());
final ITaskSession taskSession = taskContext.download("https://www.acgist.com");
assertTrue(taskContext.allTask().size() > 0);
FileUtils.delete(taskSession.getFile());
taskSession.delete();
}
use of com.acgist.snail.pojo.ITaskSession 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();
}
Aggregations