You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2020/05/14 19:42:06 UTC

svn commit: r1877747 - /poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java

Author: fanningpj
Date: Thu May 14 19:42:06 2020
New Revision: 1877747

URL: http://svn.apache.org/viewvc?rev=1877747&view=rev
Log:
[bug-64441] add test case

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java?rev=1877747&r1=1877746&r2=1877747&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java Thu May 14 19:42:06 2020
@@ -28,6 +28,10 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
 
 import org.apache.poi.EmptyFileException;
 import org.apache.poi.EncryptedDocumentException;
@@ -437,10 +441,37 @@ public final class TestWorkbookFactory {
         closeOrRevert(wb);
     }
 
+    @Test
+    public void testOpenManyHSSF() throws Exception {
+        final int size = 1000;
+        ExecutorService executorService = Executors.newFixedThreadPool(10);
+        ArrayList<Future<Boolean>> futures = new ArrayList(size);
+        for (int i = 0; i < size; i++) {
+            futures.add(executorService.submit(() -> openHSSFFile()));
+        }
+        for (Future<Boolean> future: futures) {
+            assertTrue(future.get());
+        }
+    }
+
     @Test(expected = IOException.class)
     public void testInvalidFormatException() throws IOException {
         String filename = "OPCCompliance_DerivedPartNameFAIL.docx";
         WorkbookFactory.create(POIDataSamples.getOpenXML4JInstance().openResourceAsStream(filename));
     }
 
+    private boolean openHSSFFile() {
+        try {
+            // POIFS -> hssf
+            Workbook wb = WorkbookFactory.create(
+                    new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream(xls))
+            );
+            assertNotNull(wb);
+            assertTrue(wb instanceof HSSFWorkbook);
+            assertCloseDoesNotModifyFile(xls, wb);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org