]> source.dussan.org Git - poi.git/commitdiff
Improve error message if we encounter invalid/unexpected files in integration tests
authorDominik Stadler <centic@apache.org>
Mon, 19 Jun 2017 11:05:20 +0000 (11:05 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 19 Jun 2017 11:05:20 +0000 (11:05 +0000)
Adjust some tests slightly

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1799178 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/TestAllFiles.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java

index 14e346bd3f84f5ab4e35bfefe39ef064b094525f..86a5c06ca677156f95d0a07db39b3758fd843c88 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import java.io.BufferedInputStream;
 import java.io.File;
@@ -386,6 +387,10 @@ public class TestAllFiles {
     
     @Test
     public void testAllFiles() throws Exception {
+        if(handler == null) {
+            fail("Did not find a handler for file " + file);
+        }
+
         System.out.println("Reading " + file + " with " + handler.getClass());
         assertNotNull("Unknown file extension for file: " + file + ": " + getExtension(file), handler);
         File inputFile = new File(ROOT_DIR, file);
index af58706a7a7b5dc9683e639661611f301e029308..2cdc7b565877f369c0a3a135c1be91a006100832 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.fail;
 import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
@@ -91,6 +90,7 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
             super.bug60197_NamedRangesReferToCorrectSheetWhenSheetOrderIsChanged();
         } catch (final RuntimeException e) {
             final Throwable cause = e.getCause();
+            //noinspection StatementWithEmptyBody
             if (cause instanceof IOException && cause.getMessage().equals("Stream closed")) {
                 // expected on the second time that _testDataProvider.writeOutAndReadBack(SXSSFWorkbook) is called
                 // if the test makes it this far, then we know that XSSFName sheet indices are updated when sheet
index fd3b1a66de5aa83ee2ec847e064eb7e448afbab7..f6f8892587bbb776eb3bb5571f750231e08f9560 100644 (file)
@@ -179,7 +179,7 @@ public final class TestHSSFCell extends BaseTestCell {
                wb2.close();
        }
 
-       
+
        @Test
        public void testActiveCellBug56114() throws IOException {
            Workbook wb = new HSSFWorkbook();
@@ -197,15 +197,17 @@ public final class TestHSSFCell extends BaseTestCell {
         assertEquals(0, ((HSSFSheet)wb.getSheetAt(0)).getSheet().getActiveCellCol());
 
            cell.setAsActiveCell();
+           cell.setCellValue("this should be active");
         
         assertEquals(1, ((HSSFSheet)wb.getSheetAt(0)).getSheet().getActiveCellRow());
         assertEquals(3, ((HSSFSheet)wb.getSheetAt(0)).getSheet().getActiveCellCol());
 
-//         FileOutputStream fos = new FileOutputStream("/tmp/56114.xls");
-//
-//         wb.write(fos);
-//
-//         fos.close();
+           /*OutputStream fos = new FileOutputStream("c:/temp/56114.xls");
+               try {
+                       wb.write(fos);
+               } finally {
+                       fos.close();
+               }*/
                    
            Workbook wbBack = _testDataProvider.writeOutAndReadBack(wb);
            wb.close();
@@ -217,12 +219,13 @@ public final class TestHSSFCell extends BaseTestCell {
         
         assertEquals(3, ((HSSFSheet)wbBack.getSheetAt(0)).getSheet().getActiveCellRow());
         assertEquals(3, ((HSSFSheet)wbBack.getSheetAt(0)).getSheet().getActiveCellCol());
-           
-//         fos = new FileOutputStream("/tmp/56114a.xls");
-//
-//         wbBack.write(fos);
-//
-//         fos.close();
+
+               /*fos = new FileOutputStream("c:/temp/56114a.xls");
+               try {
+                       wb.write(fos);
+               } finally {
+                       fos.close();
+               }*/
                    
         Workbook wbBack2 = _testDataProvider.writeOutAndReadBack(wbBack);
         wbBack.close();
@@ -336,7 +339,6 @@ public final class TestHSSFCell extends BaseTestCell {
         * the {@link StringRecord} following the {@link FormulaRecord} after the result type had been
         * changed to number/boolean/error.  Excel silently ignores the extra record, but some POI
         * versions (prior to bug 46213 / r717883) crash instead.
-        * @throws IOException 
         */
        @Test
        public void testCachedTypeChange() throws IOException {