diff options
author | PJ Fanning <fanningpj@apache.org> | 2024-07-01 21:36:31 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2024-07-01 21:36:31 +0000 |
commit | f8a990051bc3be17161d7916c496c941cb231eae (patch) | |
tree | 31c2defb7a482155cfe944d683a0e07a265db4e1 /poi-ooxml/src/test | |
parent | d879a94a156b69e5d0ddc1cf23716ed3905edc69 (diff) | |
download | poi-f8a990051bc3be17161d7916c496c941cb231eae.tar.gz poi-f8a990051bc3be17161d7916c496c941cb231eae.zip |
throw exception if xlsx contains duplicate file names
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918800 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src/test')
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java index 744887ff40..bd36492535 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java @@ -27,6 +27,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ooxml.POIXMLProperties; import org.apache.poi.ooxml.TrackingInputStream; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.openxml4j.exceptions.InvalidOperationException; import org.apache.poi.openxml4j.opc.ContentTypes; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; @@ -1448,6 +1449,18 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { } @Test + void testDuplicateFileReadAsFile() { + assertThrows(InvalidOperationException.class, () -> { + try ( + OPCPackage pkg = OPCPackage.open(getSampleFile("duplicate-file.xlsx"), PackageAccess.READ); + XSSFWorkbook wb = new XSSFWorkbook(pkg) + ) { + // expect exception here + } + }); + } + + @Test void testWorkbookCloseClosesInputStream() throws Exception { try (TrackingInputStream stream = new TrackingInputStream( HSSFTestDataSamples.openSampleFileStream("github-321.xlsx"))) { |