diff options
author | Yegor Kozlov <yegor@apache.org> | 2009-12-15 09:30:30 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2009-12-15 09:30:30 +0000 |
commit | 9a492d227eaff4d44699dc1061f3600aa3c678f5 (patch) | |
tree | 1969a4a378977be7ac900df6f36663076bcb3c73 /src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java | |
parent | 07d15660b9977ad88df372b65af48488003fe683 (diff) | |
download | poi-9a492d227eaff4d44699dc1061f3600aa3c678f5.tar.gz poi-9a492d227eaff4d44699dc1061f3600aa3c678f5.zip |
preserve POIFS StorageClsid when re-writing existing workbooks, this property is important for embedded objects, see Bugzilla 47920
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@890714 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index ab7cca3186..39a911c53e 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -17,9 +17,7 @@ package org.apache.poi.hssf.usermodel; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; +import java.io.*; import java.util.List; import junit.framework.AssertionFailedError; @@ -37,6 +35,9 @@ import org.apache.poi.hssf.record.formula.Area3DPtg; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.TempFile; import org.apache.poi.ss.usermodel.BaseTestWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.POIDataSamples; +import org.apache.poi.hpsf.ClassID; /** * Tests for {@link HSSFWorkbook} @@ -505,4 +506,21 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { nr = wb.getWorkbook().getNameRecord(2); assertEquals("Sheet2!E:F,Sheet2!$A$9:$IV$12", HSSFFormulaParser.toFormulaString(wb, nr.getNameDefinition())); // E:F,9:12 } + + /** + * Test that the storage clsid property is preserved + */ + public void test47920() throws IOException { + POIFSFileSystem fs1 = new POIFSFileSystem(POIDataSamples.getSpreadSheetInstance().openResourceAsStream("47920.xls")); + HSSFWorkbook wb = new HSSFWorkbook(fs1); + ClassID clsid1 = fs1.getRoot().getStorageClsid(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(4096); + wb.write(out); + byte[] bytes = out.toByteArray(); + POIFSFileSystem fs2 = new POIFSFileSystem(new ByteArrayInputStream(bytes)); + ClassID clsid2 = fs2.getRoot().getStorageClsid(); + + assertTrue(clsid1.equals(clsid2)); + } } |