diff options
author | Dominik Stadler <centic@apache.org> | 2021-01-30 18:41:57 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2021-01-30 18:41:57 +0000 |
commit | 615de587f7413f59a336c7f7adc52b8408e7b85b (patch) | |
tree | 5e694b7984bcc46fa3a6162734b9ba7cbfb8dccd /src/testcases | |
parent | 1d26df99ee6e300d14ead30cf830fbab5162721e (diff) | |
download | poi-615de587f7413f59a336c7f7adc52b8408e7b85b.tar.gz poi-615de587f7413f59a336c7f7adc52b8408e7b85b.zip |
Enable storing an SXSSF workbook twice
Verify this via a unit-test for all types of workbooks
Add a test to verify the contents is byte-for-byte equal
Also remove an overwritten test which works the same now for all three workbook-types
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886060 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index d8adc7c529..d5881c2a05 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -17,6 +17,7 @@ package org.apache.poi.ss.usermodel; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -30,6 +31,7 @@ import java.awt.font.FontRenderContext; import java.awt.font.TextAttribute; import java.awt.font.TextLayout; import java.awt.geom.Rectangle2D; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.text.AttributedString; import java.util.HashMap; @@ -106,7 +108,6 @@ public abstract class BaseTestBugzillaIssues { /** * test writing a file with large number of unique strings, * open resulting file in Excel to check results! - * @param num the number of strings to generate */ @Test public final void bug15375_2() throws IOException { @@ -1804,4 +1805,32 @@ public abstract class BaseTestBugzillaIssues { FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator(); assertEquals(expectedResultOrNull, eval.evaluate(intF).formatAsString()); } + + @Test + void testWriteDocumentTwice() throws Exception { + try (Workbook wb = _testDataProvider.createWorkbook()) { + Sheet sheet = wb.createSheet("RawData"); + Row row = sheet.createRow(0); + Cell cell; + + cell = row.createCell(0); + cell.setCellValue("Ernie & Bert"); + + cell = row.createCell(1); + // Set a precalculated formula value containing a special character. + cell.setCellValue("Ernie & Bert are cool!"); + cell.setCellFormula("A1 & \" are cool!\""); + + try (ByteArrayOutputStream out1 = new ByteArrayOutputStream(); + ByteArrayOutputStream out2 = new ByteArrayOutputStream()) { + wb.write(out1); + wb.write(out2); + + out1.flush(); + out2.flush(); + + assertArrayEquals(out1.toByteArray(), out2.toByteArray()); + } + } + } }
\ No newline at end of file |