diff options
author | Yegor Kozlov <yegor@apache.org> | 2007-09-08 16:34:10 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2007-09-08 16:34:10 +0000 |
commit | 0c24b8f16c012820934c60b3072948e27830d393 (patch) | |
tree | cbaa8b8fddc0a3f50bb057d3f456a562c57817fe /src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java | |
parent | f9bda3915e057f0c93aba5c6d1e1e3b73bbaf438 (diff) | |
download | poi-0c24b8f16c012820934c60b3072948e27830d393.tar.gz poi-0c24b8f16c012820934c60b3072948e27830d393.zip |
Support for getting OLE objects from HSSFWorkbook. See bug 43222 for details.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@573878 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java b/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java index e0828c71c0..dd57531304 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java @@ -19,25 +19,43 @@ package org.apache.poi.hssf.usermodel; import java.io.File; import java.io.FileInputStream; +import java.util.List; import junit.framework.TestCase; public class TestOLE2Embeding extends TestCase { - public void testEmbeding() throws Exception { - String dirname = System.getProperty("HSSF.testdata.path"); - String filename = dirname + "/ole2-embedding.xls"; + public void testEmbeding() throws Exception { + String dirname = System.getProperty("HSSF.testdata.path"); + String filename = dirname + "/ole2-embedding.xls"; + + File file = new File(filename); + FileInputStream in = new FileInputStream(file); + HSSFWorkbook workbook; + + // This used to break, until bug #43116 was fixed + workbook = new HSSFWorkbook(in); + + in.close(); + + // Check we can get at the Escher layer still + workbook.getAllPictures(); + } + + public void testEmbeddedObjects() throws Exception { + String dirname = System.getProperty("HSSF.testdata.path"); + String filename = dirname + "/ole2-embedding.xls"; + + File file = new File(filename); + HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file)); + List objects = workbook.getAllEmbeddedObjects(); + assertEquals("Wrong number of objects", 2, objects.size()); + assertEquals("Wrong name for first object", "MBD06CAB431", + ((HSSFObjectData) + objects.get(0)).getDirectory().getName()); + assertEquals("Wrong name for second object", "MBD06CAC85A", + ((HSSFObjectData) + objects.get(1)).getDirectory().getName()); + } - File file = new File(filename); - FileInputStream in = new FileInputStream(file); - HSSFWorkbook workbook; - - // This used to break, until bug #43116 was fixed - workbook = new HSSFWorkbook(in); - - in.close(); - - // Check we can get at the Escher layer still - workbook.getAllPictures(); - } } |