diff options
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/dev')
7 files changed, 31 insertions, 33 deletions
diff --git a/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java b/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java index a8b30a001c..262aafdb3b 100644 --- a/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java +++ b/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.FileInputStream; -import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -29,7 +28,6 @@ import java.util.Map; import org.apache.poi.POIDataSamples; import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.util.NullOutputStream; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -46,8 +44,6 @@ import org.junit.runners.Parameterized.Parameters; */ @RunWith(Parameterized.class) public abstract class BaseTestIteratingXLS { - protected static final OutputStream NULL_OUTPUT_STREAM = new NullOutputStream(); - @Rule public ExpectedException thrown = ExpectedException.none(); @@ -74,9 +70,9 @@ public abstract class BaseTestIteratingXLS { assertNotNull("Did not find any xls files in directory " + dir, files); for(String file : files) { - list.add(new Object[] { new File(dir, file) }); + list.add(new Object[]{new File(dir, file)}); + } } - } @Parameter public File file; diff --git a/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java b/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java index 12d7c6fbaf..406266d902 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java @@ -23,6 +23,7 @@ import java.io.InputStream; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.hssf.OldExcelFormatException; import org.apache.poi.hssf.record.RecordInputStream; +import org.apache.poi.util.NullOutputStream; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; @@ -30,10 +31,10 @@ public class TestBiffDrawingToXml extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); - EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header + EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header EXCLUDED.put("51832.xls", EncryptedDocumentException.class); - EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); - EXCLUDED.put("password.xls", EncryptedDocumentException.class); + EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); + EXCLUDED.put("password.xls", EncryptedDocumentException.class); EXCLUDED.put("46904.xls", OldExcelFormatException.class); EXCLUDED.put("59074.xls", OldExcelFormatException.class); EXCLUDED.put("testEXCEL_2.xls", OldExcelFormatException.class); // Biff 2 / Excel 2, pre-OLE2 @@ -47,11 +48,11 @@ public class TestBiffDrawingToXml extends BaseTestIteratingXLS { EXCLUDED.put("61300.xls", RecordFormatException.class); EXCLUDED.put("64130.xls", OldExcelFormatException.class); // BIFF 5 } - + @Override void runOneFile(File pFile) throws Exception { try (InputStream wb = new FileInputStream(pFile)) { - BiffDrawingToXml.writeToFile(NULL_OUTPUT_STREAM, wb, false, new String[0]); + BiffDrawingToXml.writeToFile(new NullOutputStream(), wb, false, new String[0]); } } } diff --git a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java index d4fd62fa99..75adb444a4 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java @@ -28,6 +28,7 @@ import org.apache.poi.hssf.OldExcelFormatException; import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.LocaleUtil; +import org.apache.poi.util.NullOutputStream; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; import org.junit.Ignore; @@ -62,7 +63,7 @@ public class TestBiffViewer extends BaseTestIteratingXLS { try (POIFSFileSystem fs = new POIFSFileSystem(fileIn, true); InputStream is = BiffViewer.getPOIFSInputStream(fs)) { // use a NullOutputStream to not write the bytes anywhere for best runtime - PrintWriter dummy = new PrintWriter(new OutputStreamWriter(NULL_OUTPUT_STREAM, LocaleUtil.CHARSET_1252)); + PrintWriter dummy = new PrintWriter(new OutputStreamWriter(new NullOutputStream(), LocaleUtil.CHARSET_1252)); BiffViewer.runBiffViewer(dummy, is, true, true, true, false); } } diff --git a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java index d32e0b71eb..20a7a635c9 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java @@ -23,7 +23,7 @@ import java.io.PrintStream; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.hssf.OldExcelFormatException; import org.apache.poi.hssf.record.RecordInputStream; -import org.apache.poi.util.LocaleUtil; +import org.apache.poi.util.NullPrintStream; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; @@ -31,10 +31,10 @@ public class TestEFBiffViewer extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); - EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header + EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header EXCLUDED.put("51832.xls", EncryptedDocumentException.class); - EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); - EXCLUDED.put("password.xls", EncryptedDocumentException.class); + EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); + EXCLUDED.put("password.xls", EncryptedDocumentException.class); EXCLUDED.put("46904.xls", OldExcelFormatException.class); EXCLUDED.put("59074.xls", OldExcelFormatException.class); EXCLUDED.put("testEXCEL_2.xls", OldExcelFormatException.class); // Biff 2 / Excel 2, pre-OLE2 @@ -45,17 +45,17 @@ public class TestEFBiffViewer extends BaseTestIteratingXLS { EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95 EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class); - EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun" + // EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun" EXCLUDED.put("61300.xls", RecordFormatException.class); EXCLUDED.put("64130.xls", OldExcelFormatException.class); //Biff 5 } - + @Override void runOneFile(File fileIn) throws IOException { 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,true,LocaleUtil.CHARSET_1252.name())); + System.setOut(new NullPrintStream()); EFBiffViewer.main(new String[] { fileIn.getAbsolutePath() }); } finally { diff --git a/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java index b922230994..a3eae963c8 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java @@ -24,7 +24,7 @@ import java.io.PrintStream; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.hssf.OldExcelFormatException; import org.apache.poi.hssf.record.RecordInputStream; -import org.apache.poi.util.LocaleUtil; +import org.apache.poi.util.NullPrintStream; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; @@ -32,10 +32,10 @@ public class TestFormulaViewer extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); - EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header + EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header EXCLUDED.put("51832.xls", EncryptedDocumentException.class); - EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); - EXCLUDED.put("password.xls", EncryptedDocumentException.class); + EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); + EXCLUDED.put("password.xls", EncryptedDocumentException.class); EXCLUDED.put("46904.xls", OldExcelFormatException.class); EXCLUDED.put("59074.xls", OldExcelFormatException.class); EXCLUDED.put("testEXCEL_2.xls", OldExcelFormatException.class); // Biff 2 / Excel 2, pre-OLE2 @@ -49,13 +49,13 @@ public class TestFormulaViewer extends BaseTestIteratingXLS { EXCLUDED.put("61300.xls", RecordFormatException.class); EXCLUDED.put("64130.xls", OldExcelFormatException.class); //Biff 5 } - + @Override void runOneFile(File fileIn) throws Exception { 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,true,LocaleUtil.CHARSET_1252.name())); + System.setOut(new NullPrintStream()); FormulaViewer viewer = new FormulaViewer(); viewer.setFile(fileIn.getAbsolutePath()); diff --git a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java index 890ef1e837..8ab108378f 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java @@ -25,7 +25,7 @@ import org.apache.poi.EncryptedDocumentException; import org.apache.poi.POIDataSamples; import org.apache.poi.hssf.OldExcelFormatException; import org.apache.poi.hssf.record.RecordInputStream; -import org.apache.poi.util.LocaleUtil; +import org.apache.poi.util.NullPrintStream; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; import org.junit.Ignore; @@ -35,10 +35,10 @@ public class TestReSave extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); - EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header + EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header EXCLUDED.put("51832.xls", EncryptedDocumentException.class); - EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); - EXCLUDED.put("password.xls", EncryptedDocumentException.class); + EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class); + EXCLUDED.put("password.xls", EncryptedDocumentException.class); EXCLUDED.put("46904.xls", OldExcelFormatException.class); EXCLUDED.put("59074.xls", OldExcelFormatException.class); EXCLUDED.put("testEXCEL_2.xls", OldExcelFormatException.class); // Biff 2 / Excel 2, pre-OLE2 @@ -64,12 +64,12 @@ public class TestReSave extends BaseTestIteratingXLS { 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,true,LocaleUtil.CHARSET_1252.name())); + System.setOut(new NullPrintStream()); File reSavedFile = new File(fileIn.getParentFile(), fileIn.getName().replace(".xls", "-saved.xls")); try { ReSave.main(new String[] { fileIn.getAbsolutePath() }); - + // also try BiffViewer on the saved file new TestBiffViewer().runOneFile(reSavedFile); diff --git a/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java b/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java index 934eb5b89d..3a1b9bb2fe 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java @@ -21,7 +21,7 @@ import java.io.IOException; import java.io.PrintStream; import org.apache.poi.hssf.OldExcelFormatException; -import org.apache.poi.util.LocaleUtil; +import org.apache.poi.util.NullPrintStream; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; @@ -46,7 +46,7 @@ public class TestRecordLister extends BaseTestIteratingXLS { 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,true,LocaleUtil.CHARSET_1252.name())); + System.setOut(new NullPrintStream()); RecordLister viewer = new RecordLister(); viewer.setFile(fileIn.getAbsolutePath()); |