aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi/openxml4j
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2018-03-04 13:33:38 +0000
committerDominik Stadler <centic@apache.org>2018-03-04 13:33:38 +0000
commitc6df73b0f00e0399f078a684ea973efd5fb657bb (patch)
treee436e5da3c14fec0fabfa793905e47e871036baf /src/ooxml/testcases/org/apache/poi/openxml4j
parent86a286013d9378bf00e766931c2f92dc81c02aab (diff)
downloadpoi-c6df73b0f00e0399f078a684ea973efd5fb657bb.tar.gz
poi-c6df73b0f00e0399f078a684ea973efd5fb657bb.zip
Add unit test which verifies that ThresholdInputStream can be used. This currently fails with Java 10 because the reflection relies on internals of class ZipFile that were changed.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825818 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/openxml4j')
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java b/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java
new file mode 100644
index 0000000000..4752912bb2
--- /dev/null
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java
@@ -0,0 +1,32 @@
+package org.apache.poi.openxml4j.util;
+
+import org.apache.poi.openxml4j.opc.internal.ZipHelper;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.junit.Test;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+
+import static org.junit.Assert.assertTrue;
+
+public class TestZipSecureFile {
+ @Test
+ public void testThresholdInputStream() throws Exception {
+ // This fails in Java 10 because our reflection injection of the ThresholdInputStream causes a
+ // ClassCastException in ZipFile now
+ ZipSecureFile.ThresholdInputStream zis = ZipHelper.openZipStream(new FileInputStream(XSSFTestDataSamples.getSampleFile("template.xlsx")));
+ ZipInputStreamZipEntrySource thresholdInputStream = new ZipInputStreamZipEntrySource(zis);
+
+ ZipSecureFile secureFile = new ZipSecureFile(XSSFTestDataSamples.getSampleFile("template.xlsx"));
+
+ Enumeration<? extends ZipEntry> entries = thresholdInputStream.getEntries();
+ while (entries.hasMoreElements()) {
+ ZipEntry entry = entries.nextElement();
+
+ InputStream inputStream = secureFile.getInputStream(entry);
+ assertTrue(inputStream.available() > 0);
+ }
+ }
+} \ No newline at end of file