private String resultDir;
private List<BasicOutput.OutputType> realTypes;
private Map<String, List<String>> skipCompare;
+ private Map<String, List<String>> skipCompareCross;
- public ConversionTest(final String testUri, final String expectedDir,
- final String resultDir, String[] args) {
- super("Conversion", args);
+ public ConversionTest(String testName, final String testUri,
+ final String expectedDir, final String resultDir, String[] args) {
+ super("Conversion - " + testName, args);
this.testUri = testUri;
this.expectedDir = expectedDir;
}
}
- addTest(new TestCase("Read the test file") {
- @Override
- public void test() throws Exception {
- assertEquals("The test file \"" + testUri
- + "\" cannot be found", true,
- new File(testUri).exists());
- }
- });
+ if (!testUri.startsWith("http://") && !testUri.startsWith("https://")) {
+ addTest(new TestCase("Read the test file") {
+ @Override
+ public void test() throws Exception {
+ assertEquals("The test file \"" + testUri
+ + "\" cannot be found", true,
+ new File(testUri).exists());
+ }
+ });
+ }
addTest(new TestCase("Assure directories exist") {
@Override
@Override
protected void start() throws Exception {
skipCompare = new HashMap<String, List<String>>();
+ skipCompareCross = new HashMap<String, List<String>>();
+
skipCompare.put("epb.ncx",
Arrays.asList(" <meta name=\"dtb:uid\" content="));
skipCompare.put("epb.opf", Arrays.asList(" <dc:subject>",
" <dc:identifier id=\"BookId\" opf:scheme=\"URI\">"));
skipCompare.put(".info",
- Arrays.asList("CREATION_DATE=", "SUBJECT=", "URL=", "UUID="));
+ Arrays.asList("CREATION_DATE=", "URL=\"file:/", "UUID="));
skipCompare.put("URL", Arrays.asList("file:/"));
+
+ for (String key : skipCompare.keySet()) {
+ skipCompareCross.put(key, skipCompare.get(key));
+ }
+
+ skipCompareCross.put(".info", Arrays.asList(""));
+ skipCompareCross.put("epb.opf", Arrays.asList(" <dc:"));
+ skipCompareCross.put("title.xhtml",
+ Arrays.asList(" <div class=\"type\">"));
+ skipCompareCross.put("index.html",
+ Arrays.asList(" <div class=\"type\">"));
+ skipCompareCross.put("URL", Arrays.asList(""));
}
@Override
for (BasicOutput.OutputType crossType : realTypes) {
File crossDir = Test.tempFiles
.createTempDir("cross-result");
+
generate(this, target.getAbsolutePath(), crossDir,
crossType);
compareFiles(this, new File(resultDir), crossDir,
private void compareFiles(TestCase testCase, File expectedDir,
File resultDir, final BasicOutput.OutputType limitTiFiles,
final String errMess) throws Exception {
+
+ Map<String, List<String>> skipCompare = errMess.startsWith("Cross") ? this.skipCompareCross
+ : this.skipCompare;
+
FilenameFilter filter = null;
if (limitTiFiles != null) {
filter = new FilenameFilter() {
package be.nikiroo.fanfix.test;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.Properties;
import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.bundles.Config;
import be.nikiroo.fanfix.bundles.ConfigBundle;
import be.nikiroo.utils.IOUtils;
import be.nikiroo.utils.TempFiles;
addSeries(new BasicSupportUtilitiesTest(args));
addSeries(new BasicSupportDeprecatedTest(args));
addSeries(new LibraryTest(args));
-
+
File sources = new File("test/");
if (sources.isDirectory()) {
for (File file : sources.listFiles()) {
continue;
}
- addSeries(new ConversionTest(uri, expectedDir, resultDir, args));
+ addSeries(new ConversionTest(file.getName(), uri, expectedDir,
+ resultDir, args));
}
}
}
}
localCache.mkdirs();
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(new File(tmpConfig,
- "config.properties"));
- Properties props = new Properties();
- props.setProperty("CACHE_DIR", localCache.getAbsolutePath());
- props.store(out, null);
- } finally {
- if (out != null) {
- out.close();
- }
- }
-
ConfigBundle config = new ConfigBundle();
Bundles.setDirectory(tmpConfig.getAbsolutePath());
+ config.setString(Config.CACHE_DIR, localCache.getAbsolutePath());
+ config.setInteger(Config.CACHE_MAX_TIME_STABLE, -1);
+ config.setInteger(Config.CACHE_MAX_TIME_CHANGING, -1);
config.updateFile(tmpConfig.getPath());
-
System.setProperty("CONFIG_DIR", tmpConfig.getAbsolutePath());
+ Instance.init(true);
+ Instance.getCache().setOffline(offline);
+
TestLauncher tests = new Test(args);
tests.setDetails(verbose);
result = tests.launch();
IOUtils.deltree(tmpConfig);
- IOUtils.deltree(localCache);
} finally {
// Test temp files
tempFiles.close();