aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2013-10-25 21:57:48 +0000
committerDominik Stadler <centic@apache.org>2013-10-25 21:57:48 +0000
commitc856b750aeae992878cda8f3693faf17fd2fab14 (patch)
tree473d46e0ec9c36ec3ccfe0c87f1bf13361558ece /src/testcases/org/apache/poi/hssf/dev/TestReSave.java
parentea257d494a00b552c2f9d5a104b0b089a14558c4 (diff)
downloadpoi-c856b750aeae992878cda8f3693faf17fd2fab14.tar.gz
poi-c856b750aeae992878cda8f3693faf17fd2fab14.zip
Add a number of tests for the dev-tools. The tests iterate over all .xls
files that are found under test-data, any newly added file or code-change which breaks one of the dev-tools will cause the tests to fail in the future. Known broken files can be excluded. Also fixes two points where some files could cause BiffViewer to fail. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1535885 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/dev/TestReSave.java')
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/TestReSave.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
new file mode 100644
index 0000000000..4cdf01591e
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
@@ -0,0 +1,50 @@
+package org.apache.poi.hssf.dev;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+
+public class TestReSave extends BaseXLSIteratingTest {
+ static {
+ // TODO: is it ok to fail these?
+ // Look at the output of the test for the detailed stacktrace of the failures...
+ EXCLUDED.add("password.xls");
+ EXCLUDED.add("43493.xls");
+ EXCLUDED.add("51832.xls");
+ EXCLUDED.add("49219.xls");
+ EXCLUDED.add("49931.xls");
+
+ SILENT_EXCLUDED.add("46904.xls");
+ };
+
+ @Override
+ void runOneFile(String dir, String file, List<String> failed) throws Exception {
+ // avoid running on files leftover from previous failed runs
+ if(file.endsWith("-saved.xls")) {
+ return;
+ }
+
+ PrintStream save = System.out;
+ try {
+ // redirect standard out during the test to avoid spamming the console with output
+ System.setOut(new PrintStream(NULL_OUTPUT_STREAM));
+
+ try {
+ ReSave.main(new String[] { new File(dir, file).getAbsolutePath() });
+ try {
+ // had one case where the re-saved could not be re-saved!
+ ReSave.main(new String[] { new File(dir, file.replace(".xls", "-saved.xls")).getAbsolutePath() });
+ } finally {
+ // clean up the re-re-saved file
+ new File(dir, file.replace(".xls", "-saved.xls").replace(".xls", "-saved.xls")).delete();
+ }
+ } finally {
+ // clean up the re-saved file
+ new File(dir, file.replace(".xls", "-saved.xls")).delete();
+ }
+
+ } finally {
+ System.setOut(save);
+ }
+ }
+}