Use new comic loader, update HTML file and test
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 10 Feb 2015 20:24:55 +0000 (21:24 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 10 Feb 2015 20:24:55 +0000 (21:24 +0100)
src/test/java/net/pterodactylus/rhynodge/filters/comics/AbstruseGooseComicFilterTest.java
src/test/resources/comics/abstrusegoose.html [deleted file]
src/test/resources/net/pterodactylus/rhynodge/filters/comics/abstruse-goose.html [new file with mode: 0644]

index 8ad16b0..931dd35 100644 (file)
@@ -42,31 +42,25 @@ public class AbstruseGooseComicFilterTest {
        private final Document document;
 
        public AbstruseGooseComicFilterTest() throws IOException {
-               document = loadDocument("/comics/abstrusegoose.html", "http://abstrusegoose.com/");
-       }
-
-       private Document loadDocument(String resourceName, String baseUri) throws IOException {
-               InputStream inputStream = getClass().getResourceAsStream(resourceName);
-               Document document = Jsoup.parse(inputStream, "UTF-8", baseUri);
-               return document;
+               document = ComicLoader.loadDocument("abstruse-goose.html", "http://abstrusegoose.com/");
        }
 
        @Test
        public void extractsComicTitleCorrectly() {
                Optional<String> title = abstruseGooseComicFilter.extractTitle(document);
-               assertThat(title, is(of("Bizarro")));
+               assertThat(title, is(of("The Sudokomic Game")));
        }
 
        @Test
        public void extractComicImagesCorrectly() {
                List<String> images = abstruseGooseComicFilter.extractImageUrls(document);
-               assertThat(images, contains("http://abstrusegoose.com/strips/bizero.png"));
+               assertThat(images, contains("http://abstrusegoose.com/strips/another_fun_game_is_comic_tac_toe.png"));
        }
 
        @Test
        public void extractImageCommentsCorrectly() {
                List<String> comments = abstruseGooseComicFilter.extractImageComments(document);
-               assertThat(comments, contains("In the additive group of the integers, bizarro zero is... well... zero."));
+               assertThat(comments, contains("This is the best I could do on short notice."));
        }
 
 }
diff --git a/src/test/resources/comics/abstrusegoose.html b/src/test/resources/comics/abstrusegoose.html
deleted file mode 100644 (file)
index 7e06768..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8" />
-    <meta name="Description" content="Strip cartoon about math, science, and geek culture." />
-    <title>Abstruse Goose | Bizarro</title>
-    <link rel="stylesheet" href="styles/main.css" />
-    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="feed.xml" />
-    <link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="atomfeed.xml" />
-    <link rel="shortcut icon" href="images/favicon.ico" />
-
-    <script>
-      document.createElement(footer);
-      document.createElement(header);
-      document.createElement(nav);
-      document.createElement(section);
-    </script>
-  </head>
-<body>\r
-\r
-  <header>\r
-  <table>\r
-    <tr>\r
-      <td>\r
-        <a href="http://abstrusegoose.com/"><img src="http://abstrusegoose.com/images/AGlogo.PNG"></a>\r
-      </td>\r
-      <td>\r
-        <script type="text/javascript"><!--\r
-        google_ad_client = "ca-pub-0580318607844761";\r
-        /* 468x60, created 6/26/08 */\r
-        google_ad_slot = "7038958302";\r
-        google_ad_width = 468;\r
-        google_ad_height = 60;\r
-        //-->\r
-        </script>\r
-        <script type="text/javascript"\r
-        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\r
-        </script>\r
-      </td>\r
-    </tr>\r
-  </table>\r
-\r
-  <div id="menu_top"></div>\r
-\r
-  </header>\r
-  <section>\r
-  <p><a href="http://abstrusegoose.com/1">&laquo;&laquo; First</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/544">&laquo; Previous</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/pseudorandom.php" >Random</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Next &raquo;&nbsp;&nbsp;&nbsp;&nbsp;Current &raquo;&raquo;</p>  <h1 class="storytitle"><a href="http://abstrusegoose.com/545">Bizarro</a></h1><br>\r
-  <img src="http://abstrusegoose.com/strips/bizero.png" alt="bizero" width="744" height="567" title="In the additive group of the integers, bizarro zero is... well... zero."/>  <div id="blog_text"></div>\r
-  <p><a href="http://abstrusegoose.com/1">&laquo;&laquo; First</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/544">&laquo; Previous</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/pseudorandom.php" >Random</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Next &raquo;&nbsp;&nbsp;&nbsp;&nbsp;Current &raquo;&raquo;</p>  </section>\r
-  <footer>\r
-    <nav>\r
-      <a href="http://abstrusegoose.com">HOME</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
-      <a href="http://abstrusegoose.com/archive">ARCHIVE</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
-      <a href="http://abstrusegoose.com/feedthegoose">FEED THE GOOSE</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
-      <a href="http://www.cafepress.com/abstrusegoose">STORE</a>\r
-    </nav>\r
-\r
-   <script type="text/javascript"><!--\r
-     google_ad_client = "ca-pub-0580318607844761";\r
-    /* 728x90, created 6/26/08 */\r
-    google_ad_slot = "7299138344";\r
-    google_ad_width = 728;\r
-    google_ad_height = 90;\r
-    //-->\r
-    </script>\r
-    <script type="text/javascript"\r
-    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\r
-    </script>\r
-\r
-    <div id="melikes">\r
-    <p><b>melikes</b></p>\r
-    <a href="http://brownsharpie.courtneygibbons.org">Brown Sharpie</a>&nbsp;&nbsp;\r
-    <a href="http://www.explosm.net/comics/new">Cy&H</a>&nbsp;&nbsp;\r
-    <a href="http://www.exocomics.com">EXTRAORDINARY</a>&nbsp;&nbsp;\r
-    <a href="http://pbfcomics.com">PBF</a>&nbsp;&nbsp;\r
-    <a href="http://popstrip.com">popstrip</a>&nbsp;&nbsp;\r
-    <a href="http://spikedmath.com">spiked math</a>&nbsp;&nbsp;\r
-    <a href="http://www.xkcd.com">xkcd</a>\r
-    </div>\r
-\r
-    <div class="creativecommons">\r
-\r
-    <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/us/"><img alt="Creative Commons License" style="border-width:0" src="http://creativecommons.org/images/public/somerights20.png"/></a>&nbsp;<img src="images/designation.PNG">\r
-\r
-    <br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/us/">Creative Commons Attribution-Noncommercial 3.0 United States License</a>.\r
-\r
-    </div>\r
-\r
-    <div class="credit">\r
-    <p><br />A webcomic......... that is all.</p>\r
-    </div>\r
-\r
-    <div class="privacy">\r
-    <p><a href="http://abstrusegoose.com/about">about</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
-    <a href="http://abstrusegoose.com/faq">faq</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
-    <a href="http://abstrusegoose.com/privacy">privacy</a></p>\r
-    </div>\r
-\r
-  </footer>\r
-</body>\r
-</html>\r
-<!-- cached with Cache Goose -->
\ No newline at end of file
diff --git a/src/test/resources/net/pterodactylus/rhynodge/filters/comics/abstruse-goose.html b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/abstruse-goose.html
new file mode 100644 (file)
index 0000000..df29b65
--- /dev/null
@@ -0,0 +1,102 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <meta name="Description" content="Strip cartoon about math, science, and geek culture." />
+    <title>Abstruse Goose | The Sudokomic Game</title>
+    <link rel="stylesheet" href="styles/main.css" />
+    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="feed.xml" />
+    <link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="atomfeed.xml" />
+    <link rel="shortcut icon" href="images/favicon.ico" />
+
+    <script>
+      document.createElement(footer);
+      document.createElement(header);
+      document.createElement(nav);
+      document.createElement(section);
+    </script>
+  </head>
+<body>\r
+\r
+  <header>\r
+  <table>\r
+    <tr>\r
+      <td>\r
+        <a href="http://abstrusegoose.com/"><img src="http://abstrusegoose.com/images/AGlogo.PNG"></a>\r
+      </td>\r
+      <td>\r
+        <script type="text/javascript"><!--\r
+        google_ad_client = "ca-pub-0580318607844761";\r
+        /* 468x60, created 6/26/08 */\r
+        google_ad_slot = "7038958302";\r
+        google_ad_width = 468;\r
+        google_ad_height = 60;\r
+        //-->\r
+        </script>\r
+        <script type="text/javascript"\r
+        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\r
+        </script>\r
+      </td>\r
+    </tr>\r
+  </table>\r
+\r
+  <div id="menu_top"></div>\r
+\r
+  </header>\r
+  <section>\r
+  <p><a href="http://abstrusegoose.com/1">&laquo;&laquo; First</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/572">&laquo; Previous</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/pseudorandom.php" >Random</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Next &raquo;&nbsp;&nbsp;&nbsp;&nbsp;Current &raquo;&raquo;</p>  <h1 class="storytitle"><a href="http://abstrusegoose.com/575">The Sudokomic Game</a></h1><br>\r
+  <img src="http://abstrusegoose.com/strips/another_fun_game_is_comic_tac_toe.png" alt="another_fun_game_is_comic_tac_toe" width="743" height="634" title="This is the best I could do on short notice."/>  <div id="blog_text"></div>\r
+  <p><a href="http://abstrusegoose.com/1">&laquo;&laquo; First</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/572">&laquo; Previous</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="http://abstrusegoose.com/pseudorandom.php" >Random</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Next &raquo;&nbsp;&nbsp;&nbsp;&nbsp;Current &raquo;&raquo;</p>  </section>\r
+  <footer>\r
+    <nav>\r
+      <a href="http://abstrusegoose.com">HOME</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
+      <a href="http://abstrusegoose.com/archive">ARCHIVE</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
+      <a href="http://abstrusegoose.com/feedthegoose">FEED THE GOOSE</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
+      <a href="http://www.cafepress.com/abstrusegoose">STORE</a>\r
+    </nav>\r
+\r
+   <script type="text/javascript"><!--\r
+     google_ad_client = "ca-pub-0580318607844761";\r
+    /* 728x90, created 6/26/08 */\r
+    google_ad_slot = "7299138344";\r
+    google_ad_width = 728;\r
+    google_ad_height = 90;\r
+    //-->\r
+    </script>\r
+    <script type="text/javascript"\r
+    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\r
+    </script>\r
+\r
+    <div id="melikes">\r
+    <p><b>melikes</b></p>\r
+    <a href="http://brownsharpie.courtneygibbons.org">Brown Sharpie</a>&nbsp;&nbsp;\r
+    <a href="http://www.explosm.net/comics/new">Cy&H</a>&nbsp;&nbsp;\r
+    <a href="http://www.exocomics.com">EXTRAORDINARY</a>&nbsp;&nbsp;\r
+    <a href="http://pbfcomics.com">PBF</a>&nbsp;&nbsp;\r
+    <a href="http://popstrip.com">popstrip</a>&nbsp;&nbsp;\r
+    <a href="http://spikedmath.com">spiked math</a>&nbsp;&nbsp;\r
+    <a href="http://www.xkcd.com">xkcd</a>\r
+    </div>\r
+\r
+    <div class="creativecommons">\r
+\r
+    <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/us/"><img alt="Creative Commons License" style="border-width:0" src="http://creativecommons.org/images/public/somerights20.png"/></a>&nbsp;<img src="images/designation.PNG">\r
+\r
+    <br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/us/">Creative Commons Attribution-Noncommercial 3.0 United States License</a>.\r
+\r
+    </div>\r
+\r
+    <div class="credit">\r
+    <p><br />A webcomic......... that is all.</p>\r
+    </div>\r
+\r
+    <div class="privacy">\r
+    <p><a href="http://abstrusegoose.com/about">about</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
+    <a href="http://abstrusegoose.com/faq">faq</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
+    <a href="http://abstrusegoose.com/privacy">privacy</a></p>\r
+    </div>\r
+\r
+  </footer>\r
+</body>\r
+</html>\r
+<!-- cached with Cache Goose -->
\ No newline at end of file