]> source.dussan.org Git - poi.git/commitdiff
Adjust integration tests, fix compilation warnings, make the check on "EXPECTED_EXTRA...
authorDominik Stadler <centic@apache.org>
Thu, 31 Mar 2016 13:56:27 +0000 (13:56 +0000)
committerDominik Stadler <centic@apache.org>
Thu, 31 Mar 2016 13:56:27 +0000 (13:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1737242 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java
src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java
src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java

index d7d5b6a3ff006488f765fd0c7917ac4038de2477..eeccc0510bf282689f8878077d1a5f97068dbc1f 100644 (file)
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertNotNull;
 \r
 import java.io.File;\r
 import java.io.FileInputStream;\r
-import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
 import java.util.HashSet;\r
@@ -32,7 +31,6 @@ import org.apache.poi.POIOLE2TextExtractor;
 import org.apache.poi.POITextExtractor;\r
 import org.apache.poi.extractor.ExtractorFactory;\r
 import org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor;\r
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;\r
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;\r
 import org.apache.xmlbeans.XmlException;\r
 \r
@@ -52,9 +50,7 @@ public abstract class AbstractFileHandler implements FileHandler {
         EXPECTED_EXTRACTOR_FAILURES.add("hmef/bug52400-winmail-simple.dat");\r
         EXPECTED_EXTRACTOR_FAILURES.add("hmef/bug52400-winmail-with-attachments.dat");\r
         EXPECTED_EXTRACTOR_FAILURES.add("hpsf/Test0313rur.adm");\r
-        EXPECTED_EXTRACTOR_FAILURES.add("hsmf/attachment_msg_pdf.msg");\r
         EXPECTED_EXTRACTOR_FAILURES.add("poifs/Notes.ole2");\r
-        EXPECTED_EXTRACTOR_FAILURES.add("slideshow/testPPT.thmx");\r
     }\r
 \r
     public void handleExtracting(File file) throws Exception {\r
@@ -94,7 +90,7 @@ public abstract class AbstractFileHandler implements FileHandler {
             assertNotNull(metadataExtractor.getText());\r
 \r
             assertFalse("Expected Extraction to fail for file " + file + " and handler " + this + ", but did not fail!", \r
-                    EXPECTED_EXTRACTOR_FAILURES.contains(file));\r
+                    EXPECTED_EXTRACTOR_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName()));\r
             \r
             assertEquals("File should not be modified by extractor", length, file.length());\r
             assertEquals("File should not be modified by extractor", modified, file.lastModified());\r
@@ -114,7 +110,7 @@ public abstract class AbstractFileHandler implements FileHandler {
                }\r
             }\r
         } catch (IllegalArgumentException e) {\r
-            if(!EXPECTED_EXTRACTOR_FAILURES.contains(file)) {\r
+            if(!EXPECTED_EXTRACTOR_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) {\r
                 throw e;\r
             }\r
         } finally {\r
@@ -122,9 +118,7 @@ public abstract class AbstractFileHandler implements FileHandler {
         }\r
     }\r
 \r
-    private void handleExtractingAsStream(File file) throws FileNotFoundException,\r
-            IOException, InvalidFormatException, OpenXML4JException,\r
-            XmlException {\r
+    private void handleExtractingAsStream(File file) throws IOException, OpenXML4JException, XmlException {\r
         InputStream stream = new FileInputStream(file);\r
         try {\r
             POITextExtractor streamExtractor = ExtractorFactory.createExtractor(stream);\r
index dd579c4dba891a98a0ff9e3f3e89bad5672ff78b..005dd1ade6e245ce77fc517ba4175ce6ca65db22 100644 (file)
@@ -28,7 +28,7 @@ public class HSSFFileHandler extends SpreadsheetHandler {
        @Override
     public void handleFile(InputStream stream) throws Exception {
                HSSFWorkbook wb = new HSSFWorkbook(stream);
-               handleWorkbook(wb, ".xls");
+               handleWorkbook(wb);
                
                // TODO: some documents fail currently...
         //HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
index 49a74d06d133d29bc0ab0f89d9122332258b439b..adf8f16e736bb82934da7a8bf24e162c5292573a 100644 (file)
@@ -20,7 +20,6 @@ import static org.junit.Assert.assertNotNull;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -32,18 +31,18 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.util.RecordFormatException;
 
 public abstract class SpreadsheetHandler extends AbstractFileHandler {
-       public void handleWorkbook(Workbook wb, String extension) throws IOException {
+       public void handleWorkbook(Workbook wb) throws IOException {
                // try to access some of the content
                readContent(wb);
                
                // write out the file
-               ByteArrayOutputStream out = writeToArray(wb);
+               writeToArray(wb);
                
                // access some more content (we had cases where writing corrupts the data in memory)
                readContent(wb);
 
                // write once more
-               out = writeToArray(wb);
+               ByteArrayOutputStream out = writeToArray(wb);
 
                // read in the writen file
                Workbook read;
@@ -61,8 +60,7 @@ public abstract class SpreadsheetHandler extends AbstractFileHandler {
                read.close();
        }
 
-       private ByteArrayOutputStream writeToArray(Workbook wb)
-                       throws FileNotFoundException, IOException {
+       private ByteArrayOutputStream writeToArray(Workbook wb) throws IOException {
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                try {
                        wb.write(stream);
@@ -88,7 +86,7 @@ public abstract class SpreadsheetHandler extends AbstractFileHandler {
                        
                        for(Row row : sheet) {
                            for(Cell cell : row) {
-                               cell.toString();
+                               assertNotNull(cell.toString());
                            }
                        }
                }
index cf893949f06d1194da35bcc34b6a65c27b97e115..8dfa65fb2c576f27c47f9a34ff13e1094ed3ed9d 100644 (file)
@@ -30,7 +30,6 @@ import java.util.Iterator;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerException;
 
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.util.IOUtils;
@@ -55,7 +54,7 @@ public class XSSFFileHandler extends SpreadsheetHandler {
         wb = new XSSFWorkbook(new ByteArrayInputStream(bytes));
 
         // use the combined handler for HSSF/XSSF
-        handleWorkbook(wb, ".xlsx");
+        handleWorkbook(wb);
         
         // TODO: some documents fail currently...
         //XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb);
@@ -73,8 +72,7 @@ public class XSSFFileHandler extends SpreadsheetHandler {
     }
 
 
-    private void checkXSSFReader(OPCPackage p)
-            throws IOException, OpenXML4JException, InvalidFormatException {
+    private void checkXSSFReader(OPCPackage p) throws IOException, OpenXML4JException {
         XSSFReader reader = new XSSFReader(p);
         
         // these can be null...