Author: centic
Date: Sun Mar 4 13:33:38 2018
New Revision: 1825818
URL: http://svn.apache.org/viewvc?rev=1825818&view=rev
Log:
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.
Added:
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/util/
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java
Added:
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java?rev=1825818&view=auto
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java
(added)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java
Sun Mar 4 13:33:38 2018
@@ -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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]