import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
private File testFile;
private File expectedDir;
private File resultDir;
+ private List<BasicOutput.OutputType> realTypes;
+ private Map<String, List<String>> skipCompare;
public ConversionTest(String[] args) {
super("Conversion", args);
+ // Special mode SYSOUT is not a file type (System.out)
+ realTypes = new ArrayList<BasicOutput.OutputType>();
+ for (BasicOutput.OutputType type : BasicOutput.OutputType.values()) {
+ if (!BasicOutput.OutputType.SYSOUT.equals(type)) {
+ realTypes.add(type);
+ }
+ }
+
addTest(new TestCase("Read the test file") {
@Override
public void test() throws Exception {
}
});
- for (BasicOutput.OutputType type : BasicOutput.OutputType.values()) {
- // NOT for special mode SYSOUT
- if (!BasicOutput.OutputType.SYSOUT.equals(type)) {
- addTest(getTestFor(type));
- }
+ for (BasicOutput.OutputType type : realTypes) {
+ addTest(getTestFor(type));
}
}
resultDir = new File("test/result/");
tempFiles = new TempFiles("Fanfix-ConversionTest");
+
+ skipCompare = 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="));
+ skipCompare.put("URL", Arrays.asList("file:/"));
}
@Override
// Check conversion:
compareFiles(this, expectedDir, resultDir, type, null);
- // Cross-checks:
-
// LATEX not supported as input
- if (!BasicOutput.OutputType.LATEX.equals(type)) {
- for (BasicOutput.OutputType crossType : BasicOutput.OutputType
- .values()) {
- // NOT for special mode SYSOUT
- if (!BasicOutput.OutputType.SYSOUT.equals(crossType)) {
- File crossDir = tempFiles
- .createTempDir("cross-result");
- generate(this, target, crossDir, crossType);
- compareFiles(this, crossDir, resultDir, crossType,
- crossType);
- }
- }
+ if (BasicOutput.OutputType.LATEX.equals(type)) {
+ return;
+ }
+
+ // Cross-checks:
+ for (BasicOutput.OutputType crossType : realTypes) {
+ File crossDir = tempFiles.createTempDir("cross-result");
+ generate(this, target, crossDir, crossType);
+ compareFiles(this, resultDir, crossDir, crossType,
+ crossType);
}
}
};
String resultLine = resultLines.get(j);
boolean skip = false;
- for (String skipStart : new String[] { "CREATION_DATE=",
- "SUBJECT=", "URL=", "UUID=" }) {
- if (name.endsWith(".info")
- && expectedLine.startsWith(skipStart)
- && resultLine.startsWith(skipStart)) {
- // TODO: check the format?
- skip = true;
+ for (Entry<String, List<String>> skipThose : skipCompare
+ .entrySet()) {
+ for (String skipStart : skipThose.getValue()) {
+ if (name.endsWith(skipThose.getKey())
+ && expectedLine.startsWith(skipStart)
+ && resultLine.startsWith(skipStart)) {
+ skip = true;
+ }
}
}