1 package net.pterodactylus.rhynodge.filters.torrents;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.instanceOf;
6 import java.io.IOException;
8 import net.pterodactylus.rhynodge.filters.ResourceLoader;
9 import net.pterodactylus.rhynodge.states.HtmlState;
10 import net.pterodactylus.rhynodge.states.TorrentState;
12 import org.hamcrest.Matchers;
13 import org.jsoup.nodes.Document;
14 import org.junit.Test;
17 * Unit test for {@link PirateBayFilter}.
19 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
21 public class PirateBayFilterTest {
23 private final PirateBayFilter filter = new PirateBayFilter();
24 private final Document document;
25 private final HtmlState htmlState;
27 public PirateBayFilterTest() throws IOException {
28 document = ResourceLoader.loadDocument(getClass(), "pirate-bay-results.html", "http://uj3wazyk5u4hnvtk.onion/");
29 htmlState = new HtmlState("http://uj3wazyk5u4hnvtk.onion/", document);
33 public void filterReturnsTorrentState() {
34 assertThat(filter.filter(htmlState), instanceOf(TorrentState.class));
38 public void testTorrentStateContainsCorrentTorrents() {
39 TorrentState newState = (TorrentState) filter.filter(htmlState);
41 assertThat(newState.torrentFiles(), Matchers.contains(
42 TorrentMatcher.isTorrent("ubuntu-14.04-desktop-amd64.iso", "964 MiB",
43 "magnet:?xt=urn:btih:18ac50d74c61883b3ab4c40f5dd3e35f157de1a2&dn=ubuntu-14.04-desktop-amd64.iso&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969",
45 TorrentMatcher.isTorrent("ubuntu 14 04 3 desktop i386 iso (Server)", "1015 MiB",
46 "magnet:?xt=urn:btih:58ad8b464a0a4114e1890492543b6388d50af04a&dn=ubuntu+14+04+3+desktop+i386+iso+%28Server%29&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969",
48 TorrentMatcher.isTorrent("ubuntu-gnome-14.04-beta1-desktop-amd64.iso", "890 MiB",
49 "magnet:?xt=urn:btih:baab5076469a52ea9f0d3eeae8263f154da2fbab&dn=ubuntu-gnome-14.04-beta1-desktop-amd64.iso&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969",
51 TorrentMatcher.isTorrent("Ubuntu 14.04.1 Server 64 Bit DE ISO", "572 MiB",
52 "magnet:?xt=urn:btih:236fc296473ae52b2ff0c46a8de5ae04236cc774&dn=Ubuntu+14.04.1+Server+64+Bit+DE+ISO&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969",
54 TorrentMatcher.isTorrent("Ubuntu 14.04.1 Server 32 Bit DE ISO", "552 MiB",
55 "magnet:?xt=urn:btih:2c0cef0ca97e31dceae9ddf48fe0d85f1fdb4550&dn=Ubuntu+14.04.1+Server+32+Bit+DE+ISO&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969",