poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1722408 - in /poi/trunk/src/integrationtest/org/apache/poi: TestAllFiles.java stress/XSSFFileHandler.java
Date Wed, 30 Dec 2015 20:31:31 GMT
Author: centic
Date: Wed Dec 30 20:31:30 2015
New Revision: 1722408

URL: http://svn.apache.org/viewvc?rev=1722408&view=rev
Log:
Add null-handler in integration-tests for two Visio files which are not handled (yet) and
adjust memory handling somewhat

Modified:
    poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java
    poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java

Modified: poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java?rev=1722408&r1=1722407&r2=1722408&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java Wed Dec 30 20:31:30 2015
@@ -68,8 +68,10 @@ import org.junit.runners.Parameterized.P
 public class TestAllFiles {
     private static final File ROOT_DIR = new File("test-data");
 
+    static final String[] SCAN_EXCLUDES = new String[] { "**/.svn/**", "lost+found" };
+    
     // map file extensions to the actual mappers
-    private static final Map<String, FileHandler> HANDLERS = new HashMap<String,
FileHandler>();
+    static final Map<String, FileHandler> HANDLERS = new HashMap<String, FileHandler>();
     static {
         // Excel
         HANDLERS.put(".xls", new HSSFFileHandler());
@@ -113,6 +115,10 @@ public class TestAllFiles {
         HANDLERS.put(".vstm", new XDGFFileHandler());
         HANDLERS.put(".vstx", new XDGFFileHandler());
 
+        // Visio - not handled yet
+        HANDLERS.put(".vst", new NullFileHandler());
+        HANDLERS.put(".vss", new NullFileHandler());
+
         // POIFS
         HANDLERS.put(".ole2", new POIFSFileHandler());
 
@@ -268,7 +274,7 @@ public class TestAllFiles {
     public static Iterable<Object[]> files() {
         DirectoryScanner scanner = new DirectoryScanner();
         scanner.setBasedir(ROOT_DIR);
-        scanner.setExcludes(new String[] { "**/.svn/**" });
+        scanner.setExcludes(SCAN_EXCLUDES);
 
         scanner.scan();
 
@@ -343,13 +349,13 @@ public class TestAllFiles {
         }
     }
 
-    private static String getExtension(String file) {
+    static String getExtension(String file) {
         int pos = file.lastIndexOf('.');
         if(pos == -1 || pos == file.length()-1) {
             return file;
         }
 
-        return file.substring(pos);
+        return file.substring(pos).toLowerCase();
     }
 
     private static class NullFileHandler implements FileHandler {

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java?rev=1722408&r1=1722407&r2=1722408&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java Wed Dec 30 20:31:30
2015
@@ -47,10 +47,18 @@ public class XSSFFileHandler extends Spr
         // ignore password protected files
         if (POIXMLDocumentHandler.isEncrypted(stream)) return;
 
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        IOUtils.copy(stream, out);
+        final XSSFWorkbook wb;
 
-        XSSFWorkbook wb = new XSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
+        // make sure the potentially large byte-array is freed up quickly again
+        {
+	        ByteArrayOutputStream out = new ByteArrayOutputStream();
+	        IOUtils.copy(stream, out);
+	        final byte[] bytes = out.toByteArray();
+	
+	        checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(bytes)));
+
+	        wb = new XSSFWorkbook(new ByteArrayInputStream(bytes));
+        }
         
         // use the combined handler for HSSF/XSSF
         handleWorkbook(wb, ".xlsx");
@@ -64,8 +72,6 @@ public class XSSFFileHandler extends Spr
         
         // and finally ensure that exporting to XML works
         exportToXML(wb);
-        
-        checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(out.toByteArray())));
     }
 
 



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


Mime
View raw message