From a71d4075a8591b0655277b1a0e606ee48d228869 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 23 Sep 2018 05:23:20 +0200 Subject: [PATCH] Add tests (WIP) --- configure.sh | 2 +- ...es.jar => nikiroo-utils-4.4.2-sources.jar} | Bin 295708 -> 296606 bytes .../nikiroo/gofetch/support/BasicSupport.java | 29 ++++++-- src/be/nikiroo/gofetch/support/Phoronix.java | 2 +- .../nikiroo/gofetch/support/TheRegister.java | 2 +- src/be/nikiroo/gofetch/test/Test.java | 19 +++++ src/be/nikiroo/gofetch/test/TestBase.java | 69 ++++++++++++++++++ src/be/nikiroo/gofetch/test/TestLWN.java | 35 +++++++++ 8 files changed, 150 insertions(+), 8 deletions(-) rename libs/{nikiroo-utils-4.4.0-sources.jar => nikiroo-utils-4.4.2-sources.jar} (94%) create mode 100644 src/be/nikiroo/gofetch/test/Test.java create mode 100644 src/be/nikiroo/gofetch/test/TestBase.java create mode 100644 src/be/nikiroo/gofetch/test/TestLWN.java diff --git a/configure.sh b/configure.sh index b2317b2..ffb153c 100755 --- a/configure.sh +++ b/configure.sh @@ -57,7 +57,7 @@ fi; echo "MAIN = be/nikiroo/gofetch/Main" > Makefile echo "MORE = " >> Makefile -echo "TEST = " >> Makefile +echo "TEST = be/nikiroo/gofetch/test/Test" >> Makefile echo "TEST_PARAMS = $cols $ok $ko" >> Makefile echo "NAME = gofetch" >> Makefile echo "PREFIX = $PREFIX" >> Makefile diff --git a/libs/nikiroo-utils-4.4.0-sources.jar b/libs/nikiroo-utils-4.4.2-sources.jar similarity index 94% rename from libs/nikiroo-utils-4.4.0-sources.jar rename to libs/nikiroo-utils-4.4.2-sources.jar index 63f158ee48f9e6193e25703c056f6f3409d08f2b..a2869e605140a1bc1f7da7108456ecec03a024fc 100644 GIT binary patch delta 7639 zcmZ8`1zZ$S_xA42&`5W8Nl7Chf*?pEAl)b+-Oa9qgoL0nC@Clb}`|5vxKlX6XdG5Jq=H5B;oU_@tsdAI4$PBarkOo0W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}RJCPFBIB=_TZ^?;Bi~)}_Bf!bY0ech+y03bH zlQRU$ApU>UYu*#pIg!?I_yD)ag3i%~pj(R=6zVbfPDlSi`p)ko$Ce;&FsVmlm{I!| zItL8M@nGxrrF{U{nhJ@&$_VD`unIc7QN5G7rIWCKUIUqX{7_ssP7YX#E2YJ~P zUG)C03%URC$D0mD9y7u`$k9mfr3TgsIT-NKzzVp5AA&B8{vt zHPT0fOCu9R$-4u4a8`sd3T6W~L_z%sRdD>rv?nr)kYK>Xu<#)1QLqxv|Nb8axY~dH zPJ<3S24+PlqhV^|+oTE{K@WiM=nf((&tEtcDrOIP0MU(x+4sf~c zNN)7riM|&Nwjcc?-~=c77m-&c^cPq@2F8JCWE%qnS)zM_G)b5Nk@p6N9Gs|{@6AK) zz!OdoX8t`<6jDUA4AI@#nY^#m;1;y8piq4OxXXQHe=mhtaN$85kN!Cl$pS8buf+d` zwov7L articles = getArticles(doc); for (Element article : articles) { @@ -273,7 +275,7 @@ public abstract class BasicSupport { String fullContent = ""; URL url = new URL(story.getUrlInternal()); - InputStream in = downloader.open(url); + InputStream in = open(url); try { Document doc = DataUtil.load(in, "UTF-8", url.toString()); Element article = getFullArticle(doc); @@ -346,6 +348,23 @@ public abstract class BasicSupport { */ abstract protected ElementProcessor getElementProcessorFullArticle(); + /** + * Open a network resource. + *

+ * You need to close the returned {@link InputStream} when done. + * + * @param url + * the source to open + * + * @return the content + * + * @throws IOException + * in case of I/O error + */ + protected InputStream open(URL url) throws IOException { + return downloader.open(url); + } + /** * Convert the comment elements into {@link Comment}s * diff --git a/src/be/nikiroo/gofetch/support/Phoronix.java b/src/be/nikiroo/gofetch/support/Phoronix.java index 8f257fb..74096ad 100644 --- a/src/be/nikiroo/gofetch/support/Phoronix.java +++ b/src/be/nikiroo/gofetch/support/Phoronix.java @@ -146,7 +146,7 @@ class Phoronix extends BasicSupport { Element a = linkToComments.getElementsByTag("a").first(); if (a != null) { String url = a.absUrl("href"); - InputStream in = downloader.open(new URL(url)); + InputStream in = open(new URL(url)); try { doc = DataUtil.load(in, "UTF-8", url.toString()); return doc.getElementsByClass("b-post"); diff --git a/src/be/nikiroo/gofetch/support/TheRegister.java b/src/be/nikiroo/gofetch/support/TheRegister.java index 1195d3d..478381d 100644 --- a/src/be/nikiroo/gofetch/support/TheRegister.java +++ b/src/be/nikiroo/gofetch/support/TheRegister.java @@ -149,7 +149,7 @@ public class TheRegister extends BasicSupport { try { URL url = new URL("https://forums.theregister.co.uk/forum/1" + intUrl.getPath()); - InputStream in = downloader.open(url); + InputStream in = open(url); try { doc = DataUtil.load(in, "UTF-8", url.toString()); Element posts = doc.getElementById("forum_posts"); diff --git a/src/be/nikiroo/gofetch/test/Test.java b/src/be/nikiroo/gofetch/test/Test.java new file mode 100644 index 0000000..7ece14a --- /dev/null +++ b/src/be/nikiroo/gofetch/test/Test.java @@ -0,0 +1,19 @@ +package be.nikiroo.gofetch.test; + +import be.nikiroo.utils.test.TestLauncher; + +/** + * Tests for GoFetch. + * + * @author niki + */ +public class Test extends TestLauncher { + public Test(String[] args) { + super("GoFetch", args); + addSeries(new TestLWN(args)); + } + + public static void main(String[] args) { + System.exit(new Test(args).launch()); + } +} diff --git a/src/be/nikiroo/gofetch/test/TestBase.java b/src/be/nikiroo/gofetch/test/TestBase.java new file mode 100644 index 0000000..e8bfde0 --- /dev/null +++ b/src/be/nikiroo/gofetch/test/TestBase.java @@ -0,0 +1,69 @@ +package be.nikiroo.gofetch.test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Map; + +import be.nikiroo.gofetch.data.Story; +import be.nikiroo.gofetch.output.Gopher; +import be.nikiroo.gofetch.output.Html; +import be.nikiroo.gofetch.output.Output; +import be.nikiroo.gofetch.support.BasicSupport; +import be.nikiroo.utils.IOUtils; +import be.nikiroo.utils.test.TestCase; +import be.nikiroo.utils.test.TestLauncher; + +/** + * Base class for {@link BasicSupport}s testing. + * + * @author niki + */ +abstract class TestBase extends TestLauncher { + public TestBase(BasicSupport support, String[] args) { + super(support.getType().toString(), args); + addTest(support); + } + + static protected InputStream doOpen(Map map, URL url) + throws IOException { + File file = map.get(url); + if (file == null) { + throw new FileNotFoundException("Test file not found for URL: " + + url); + } + + return new FileInputStream(file); + + } + + private void addTest(final BasicSupport support) { + addTest(new TestCase("Processing example data") { + @Override + public void test() throws Exception { + File expected = new File("test/expected/" + support.getType()); + File actual = new File("test/result/" + support.getType()); + + Output gopher = new Gopher(support.getType(), "", "", 70); + Output html = new Html(support.getType(), "", "", 80); + + for (Story story : support.list()) { + IOUtils.writeSmallFile(new File(actual, story.getId() + + ".header"), gopher.exportHeader(story)); + IOUtils.writeSmallFile( + new File(actual, story.getId() + ""), + gopher.export(story)); + IOUtils.writeSmallFile(new File(actual, story.getId() + + ".header.html"), html.exportHeader(story)); + IOUtils.writeSmallFile(new File(actual, story.getId() + + ".html"), html.export(story)); + } + + assertEquals(expected, actual); + } + }); + } +} diff --git a/src/be/nikiroo/gofetch/test/TestLWN.java b/src/be/nikiroo/gofetch/test/TestLWN.java new file mode 100644 index 0000000..597e761 --- /dev/null +++ b/src/be/nikiroo/gofetch/test/TestLWN.java @@ -0,0 +1,35 @@ +package be.nikiroo.gofetch.test; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import be.nikiroo.gofetch.support.LWN; +import be.nikiroo.gofetch.support.Type; + +public class TestLWN extends TestBase { + + static private Map getMap() throws MalformedURLException { + Map map = new HashMap(); + map.put(new URL("http://fanfan.be/"), new File("/tmp/none")); + return map; + } + + public TestLWN(String[] args) { + super(new LWN() { + @Override + protected InputStream open(URL url) throws IOException { + return doOpen(getMap(), url); + } + + @Override + public Type getType() { + return Type.LWN; + } + }, args); + } +} -- 2.27.0