use of com.acgist.snail.pojo.entity.TaskEntity in project snail by acgist.
the class PropertyDescriptorTest method testSetter.
@Test
void testSetter() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
final String id = "1234";
final TaskEntity task = new TaskEntity();
assertNull(task.getId());
PropertyDescriptor.newInstance(task).set("id", id);
assertEquals(id, task.getId());
}
use of com.acgist.snail.pojo.entity.TaskEntity 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.entity.TaskEntity in project snail by acgist.
the class LoggerTest method testLevel.
@Test
void testLevel() {
String arga = null;
String argb = "";
final TaskEntity taskEntity = new TaskEntity();
LOGGER.debug("debug:{}-{}-{}-{}", arga, argb, taskEntity);
LOGGER.info("info:{}-{}-{}-{}", arga, argb, taskEntity);
LOGGER.warn("warn:{}-{}-{}-{}", arga, argb, taskEntity);
LOGGER.error("error:{}-{}-{}-{}", arga, argb, taskEntity);
try {
throw new NetException("错误测试");
} catch (Exception e) {
LOGGER.debug("debug", e);
LOGGER.info("info", e);
LOGGER.warn("warn", e);
LOGGER.error("error", e);
}
assertNotNull(LOGGER);
}
use of com.acgist.snail.pojo.entity.TaskEntity in project snail by acgist.
the class TorrentStreamGroupTest method testPick.
@Test
void testPick() throws DownloadException {
LoggerConfig.off();
final var path = "E:/snail/07E1B909D8D193D80E440A8593FB57A658223A0E.torrent";
final var session = TorrentContext.getInstance().newTorrentSession(path);
final var entity = new TaskEntity();
entity.setFile("E:/snail/tmp/pick/");
entity.setType(Type.TORRENT);
entity.setName("acgist");
entity.setStatus(Status.AWAIT);
final List<String> list = new ArrayList<>();
session.torrent().getInfo().files().stream().filter(TorrentFile::notPaddingFile).forEach(file -> {
file.selected(true);
list.add(file.path());
});
entity.setDescription(DescriptionWrapper.newEncoder(list).serialize());
session.upload(TaskSession.newInstance(entity));
final var group = session.torrentStreamGroup();
final BitSet peerPieces = new BitSet();
peerPieces.set(0, session.torrent().getInfo().pieceSize(), true);
final BitSet suggestPieces = new BitSet();
this.cost();
TorrentPiece index;
final Set<Integer> indexSet = new HashSet<Integer>();
while ((index = group.pick(peerPieces, suggestPieces)) != null) {
this.log(index);
group.done(index.getIndex());
indexSet.add(index.getIndex());
}
assertEquals(session.torrent().getInfo().pieceSize(), indexSet.size());
this.costed();
}
use of com.acgist.snail.pojo.entity.TaskEntity in project snail by acgist.
the class PeerServerTest method testServer.
@Test
void testServer() throws DownloadException {
final var path = "E:/snail/902FFAA29EE632C8DC966ED9AB573409BA9A518E.torrent";
final var torrentSession = TorrentContext.getInstance().newTorrentSession(path);
DownloadConfig.setBuffer(40 * 1024);
final List<String> list = new ArrayList<>();
final AtomicLong size = new AtomicLong();
torrentSession.torrent().getInfo().files().stream().filter(TorrentFile::notPaddingFile).forEach(file -> {
if (file.path().contains("Scans/Vol.1")) {
list.add(file.path());
}
size.addAndGet(file.getLength());
});
final var entity = new TaskEntity();
entity.setFile("E:\\snail\\server");
entity.setType(Type.TORRENT);
entity.setSize(size.get());
entity.setDescription(DescriptionWrapper.newEncoder(list).serialize());
torrentSession.upload(TaskSession.newInstance(entity));
torrentSession.verify();
PeerServer.getInstance();
TorrentServer.getInstance();
ThreadUtils.sleep(100000);
}
Aggregations