]> source.dussan.org Git - poi.git/commitdiff
Adjust error-message on old files and simplify code slightly
authorDominik Stadler <centic@apache.org>
Wed, 30 Dec 2020 17:03:30 +0000 (17:03 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 30 Dec 2020 17:03:30 +0000 (17:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884950 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java

index 617355ec478fd8ece3d5b741dd7aa4b4c9dc3a2b..a9d5f8e6db1b47b86f80ffc9a1999181ce1e7c92 100644 (file)
@@ -39,7 +39,7 @@ import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
  */
 public class BaseIntegrationTest {
        private final File rootDir;
-       private String file;
+       private final String file;
        private FileHandler handler;
 
        public BaseIntegrationTest(File rootDir, String file, FileHandler handler) {
@@ -61,7 +61,7 @@ public class BaseIntegrationTest {
                        handleWrongOLE2XMLExtension(inputFile, e);
                } catch (OldFileFormatException e) {
                        // Not even text extraction is supported for these: handler.handleExtracting(inputFile);
-                       assumeFalse( true, "File " + file + " excluded because it is unsupported old Excel format" );
+                       assumeFalse( true, "File " + file + " excluded because it is an unsupported old format" );
                } catch (EncryptedDocumentException e) {
                        // Do not try to read encrypted files
                        assumeFalse( true, "File " + file + " excluded because it is password-encrypted" );
@@ -123,42 +123,35 @@ public class BaseIntegrationTest {
 
                if(message != null && (message.equals("The document is really a XLS file"))) {
                        handler = TestAllFiles.HANDLERS.get(".xls");
-                       handleFile(inputFile);
                } else if(message != null && (message.equals("The document is really a PPT file"))) {
                        handler = TestAllFiles.HANDLERS.get(".ppt");
-                       handleFile(inputFile);
                } else if(message != null && (message.equals("The document is really a DOC file"))) {
                        handler = TestAllFiles.HANDLERS.get(".doc");
-                       handleFile(inputFile);
                } else if(message != null && (message.equals("The document is really a VSD file"))) {
                        handler = TestAllFiles.HANDLERS.get(".vsd");
-                       handleFile(inputFile);
 
                // use XWPF instead of HWPF and XSSF instead of HSSF as the file seems to have the wrong extension
                } else if (handler instanceof HWPFFileHandler) {
             handler = TestAllFiles.HANDLERS.get(".docx");
-            handleFile(inputFile);
         } else if (handler instanceof HSSFFileHandler) {
             handler = TestAllFiles.HANDLERS.get(".xlsx");
-            handleFile(inputFile);
         } else if (handler instanceof HSLFFileHandler) {
                        handler = TestAllFiles.HANDLERS.get(".pptx");
-                       handleFile(inputFile);
 
                // and the other way around, use HWPF instead of XWPF and so forth
                } else if(handler instanceof XWPFFileHandler) {
                        handler = TestAllFiles.HANDLERS.get(".doc");
-                       handleFile(inputFile);
                } else if(handler instanceof XSSFFileHandler) {
                        handler = TestAllFiles.HANDLERS.get(".xls");
-                       handleFile(inputFile);
                } else if(handler instanceof XSLFFileHandler) {
                        handler = TestAllFiles.HANDLERS.get(".ppt");
-                       handleFile(inputFile);
         } else {
                        // nothing matched => throw the exception to the outside
-            throw e;
-        }
+                       throw e;
+               }
+
+               // we found a different handler to try processing again
+               handleFile(inputFile);
        }
 
        private void handleFile(File inputFile) throws Exception {