From: David ‘Bombe’ Roden Date: Wed, 11 Feb 2015 19:42:14 +0000 (+0100) Subject: Use test class to load resources from X-Git-Tag: v2~203 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=eca155789d0bb04ccccc5eac3dc805fda1301b52;p=rhynodge.git Use test class to load resources from --- diff --git a/src/test/java/net/pterodactylus/rhynodge/filters/ResourceLoader.java b/src/test/java/net/pterodactylus/rhynodge/filters/ResourceLoader.java index 53a239a..651dcac 100644 --- a/src/test/java/net/pterodactylus/rhynodge/filters/ResourceLoader.java +++ b/src/test/java/net/pterodactylus/rhynodge/filters/ResourceLoader.java @@ -13,8 +13,8 @@ import org.jsoup.nodes.Document; */ public class ResourceLoader { - public static Document loadDocument(String resourceName, String baseUri) throws IOException { - InputStream inputStream = ResourceLoader.class.getResourceAsStream(resourceName); + public static Document loadDocument(Class classToLoadFrom, String resourceName, String baseUri) throws IOException { + InputStream inputStream = classToLoadFrom.getResourceAsStream(resourceName); Document document = Jsoup.parse(inputStream, "UTF-8", baseUri); return document; } diff --git a/src/test/java/net/pterodactylus/rhynodge/filters/comics/AbstruseGooseComicFilterTest.java b/src/test/java/net/pterodactylus/rhynodge/filters/comics/AbstruseGooseComicFilterTest.java index 2232096..f01e841 100644 --- a/src/test/java/net/pterodactylus/rhynodge/filters/comics/AbstruseGooseComicFilterTest.java +++ b/src/test/java/net/pterodactylus/rhynodge/filters/comics/AbstruseGooseComicFilterTest.java @@ -42,7 +42,7 @@ public class AbstruseGooseComicFilterTest { private final Document document; public AbstruseGooseComicFilterTest() throws IOException { - document = ResourceLoader.loadDocument("abstruse-goose.html", "http://abstrusegoose.com/"); + document = ResourceLoader.loadDocument(getClass(), "abstruse-goose.html", "http://abstrusegoose.com/"); } @Test diff --git a/src/test/java/net/pterodactylus/rhynodge/filters/comics/BusinessCatComicFilterTest.java b/src/test/java/net/pterodactylus/rhynodge/filters/comics/BusinessCatComicFilterTest.java index acc40be..7fb08b3 100644 --- a/src/test/java/net/pterodactylus/rhynodge/filters/comics/BusinessCatComicFilterTest.java +++ b/src/test/java/net/pterodactylus/rhynodge/filters/comics/BusinessCatComicFilterTest.java @@ -19,7 +19,7 @@ public class BusinessCatComicFilterTest { private final Document document; public BusinessCatComicFilterTest() throws IOException { - document = ResourceLoader.loadDocument("business-cat.html", "http://www.businesscat.happyjar.com//"); + document = ResourceLoader.loadDocument(getClass(), "business-cat.html", "http://www.businesscat.happyjar.com//"); } @Test diff --git a/src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java b/src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java index 679c67f..bd32ed2 100644 --- a/src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java +++ b/src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java @@ -21,7 +21,7 @@ public class ChiefOBrienAtWorkComicFilterTest { private final Document document; public ChiefOBrienAtWorkComicFilterTest() throws IOException { - document = ResourceLoader.loadDocument("chief-obrien-at-work.html", "http://chiefobrienatwork.com/"); + document = ResourceLoader.loadDocument(getClass(), "chief-obrien-at-work.html", "http://chiefobrienatwork.com/"); } @Test diff --git a/src/test/java/net/pterodactylus/rhynodge/filters/comics/CyanideAndHappinessComicFilterTest.java b/src/test/java/net/pterodactylus/rhynodge/filters/comics/CyanideAndHappinessComicFilterTest.java index 3522d35..ea435d1 100644 --- a/src/test/java/net/pterodactylus/rhynodge/filters/comics/CyanideAndHappinessComicFilterTest.java +++ b/src/test/java/net/pterodactylus/rhynodge/filters/comics/CyanideAndHappinessComicFilterTest.java @@ -21,7 +21,7 @@ public class CyanideAndHappinessComicFilterTest { private final Document document; public CyanideAndHappinessComicFilterTest() throws IOException { - document = ResourceLoader.loadDocument("cyanide-and-happiness.html", "http://www.explosm.net/comics/new/"); + document = ResourceLoader.loadDocument(getClass(), "cyanide-and-happiness.html", "http://www.explosm.net/comics/new/"); } @Test