Use test class to load resources from
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Feb 2015 19:42:14 +0000 (20:42 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Feb 2015 19:42:14 +0000 (20:42 +0100)
src/test/java/net/pterodactylus/rhynodge/filters/ResourceLoader.java
src/test/java/net/pterodactylus/rhynodge/filters/comics/AbstruseGooseComicFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/comics/BusinessCatComicFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/comics/CyanideAndHappinessComicFilterTest.java

index 53a239a..651dcac 100644 (file)
@@ -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;
        }
index 2232096..f01e841 100644 (file)
@@ -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
index acc40be..7fb08b3 100644 (file)
@@ -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
index 679c67f..bd32ed2 100644 (file)
@@ -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
index 3522d35..ea435d1 100644 (file)
@@ -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