X-Git-Url: http://git.nikiroo.be/?p=gofetch.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Ftest%2FTestBase.java;h=1da6b48a6a2f7451bb13425bb4a9d4125665f1bc;hp=e8bfde089785b1ce73408430aa5c4a850320f169;hb=1aaa6ba3686a5a14f2957b6b8d02ffc0903f6832;hpb=a71d4075a8591b0655277b1a0e606ee48d228869
diff --git a/src/be/nikiroo/gofetch/test/TestBase.java b/src/be/nikiroo/gofetch/test/TestBase.java
index e8bfde0..1da6b48 100644
--- a/src/be/nikiroo/gofetch/test/TestBase.java
+++ b/src/be/nikiroo/gofetch/test/TestBase.java
@@ -19,6 +19,13 @@ import be.nikiroo.utils.test.TestLauncher;
/**
* Base class for {@link BasicSupport}s testing.
+ *
+ * It will use the paths:
+ *
+ * - test/XXX/source: the html source files
+ * - test/XXX/expected: the expected output
+ * - test/XXX/actual: the actual output of the last test
+ *
*
* @author niki
*/
@@ -28,15 +35,16 @@ abstract class TestBase extends TestLauncher {
addTest(support);
}
- static protected InputStream doOpen(Map map, URL url)
- throws IOException {
+ static protected InputStream doOpen(BasicSupport support,
+ 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);
+ return new FileInputStream("test/source/" + support.getType() + "/"
+ + file);
}
@@ -47,10 +55,15 @@ abstract class TestBase extends TestLauncher {
File expected = new File("test/expected/" + support.getType());
File actual = new File("test/result/" + support.getType());
+ IOUtils.deltree(actual);
+ expected.mkdirs();
+ actual.mkdirs();
+
Output gopher = new Gopher(support.getType(), "", "", 70);
Output html = new Html(support.getType(), "", "", 80);
for (Story story : support.list()) {
+ support.fetch(story);
IOUtils.writeSmallFile(new File(actual, story.getId()
+ ".header"), gopher.exportHeader(story));
IOUtils.writeSmallFile(