use of com.acgist.snail.pojo.session.StatisticsSession in project snail by acgist.
the class PeerClientTest method testMagnet.
@Test
void testMagnet() throws DownloadException {
final var hash = "1f4f28a6df2ea7899328cbef1dfaaeec9920cdb3";
final var torrentSession = TorrentSession.newInstance(InfoHash.newInstance(hash), null);
final var entity = new TaskEntity();
entity.setFile("E:/snail/tmp/torrent/");
entity.setType(Type.TORRENT);
entity.setUrl(hash);
torrentSession.magnet(TaskSession.newInstance(entity));
final String host = "127.0.0.1";
// final Integer port = 15000; // 迅雷测试端口
// final Integer port = 18888; // 蜗牛测试端口
// FDM测试端口
final Integer port = 49160;
final var peerSession = PeerSession.newInstance(new StatisticsSession(), host, port);
final var downloader = PeerDownloader.newInstance(peerSession, torrentSession);
downloader.handshake();
ThreadUtils.sleep(100000);
assertNotNull(downloader);
}
use of com.acgist.snail.pojo.session.StatisticsSession in project snail by acgist.
the class StatisticsContextTest method testStatisticsContext.
@Test
void testStatisticsContext() {
assertNotNull(StatisticsContext.getInstance());
assertNotNull(StatisticsContext.getInstance().statistics());
assertEquals(0, StatisticsContext.getInstance().uploadSpeed());
assertEquals(0, StatisticsContext.getInstance().downloadSpeed());
final StatisticsSession session = new StatisticsSession(false, StatisticsContext.getInstance().statistics());
session.uploadLimit(1024);
session.downloadLimit(1024);
// 统计等待
ThreadUtils.sleep(4000);
assertNotEquals(0, session.uploadSpeed());
assertNotEquals(0, session.downloadSpeed());
assertNotEquals(0, StatisticsContext.getInstance().uploadSpeed());
assertNotEquals(0, StatisticsContext.getInstance().downloadSpeed());
}
Aggregations