From eca155789d0bb04ccccc5eac3dc805fda1301b52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 11 Feb 2015 20:42:14 +0100 Subject: [PATCH] Use test class to load resources from --- src/test/java/net/pterodactylus/rhynodge/filters/ResourceLoader.java | 4 ++-- .../rhynodge/filters/comics/AbstruseGooseComicFilterTest.java | 2 +- .../rhynodge/filters/comics/BusinessCatComicFilterTest.java | 2 +- .../rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java | 2 +- .../rhynodge/filters/comics/CyanideAndHappinessComicFilterTest.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) 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 -- 2.7.4