diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 7c2fed7a83..a50d1832b7 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -138,15 +138,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { super(XSSFITestDataProvider.instance); } - /** - * test writing a file with large number of unique strings, - * open resulting file in Excel to check results! - */ - @Test - public void bug15375_2() throws IOException { - bug15375(1000); - } - /** * Named ranges had the right reference, but * the wrong sheet name diff --git a/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java b/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java index 0c93ffe5e1..9598783543 100644 --- a/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java +++ b/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java @@ -114,16 +114,16 @@ public final class TestEventRecordFactory { assertArrayEquals(rec1, rec2); } - /** + /* * tests that the create record function returns a properly * constructed record in the case of a continued record. * TODO - need a real world example to put in a unit test */ - @NotImplemented - @Test - @Disabled - public void testCreateContinuedRecord() { - } + // @NotImplemented + // @Test + // @Disabled + // public void testCreateContinuedRecord() { + // } /** diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index ff955df1e3..5bfdd5cb9f 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -46,12 +46,10 @@ import java.util.stream.IntStream; import javax.imageio.ImageIO; -import org.apache.poi.EncryptedDocumentException; import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.SummaryInformation; import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.hssf.OldExcelFormatException; import org.apache.poi.hssf.extractor.ExcelExtractor; import org.apache.poi.hssf.model.InternalSheet; import org.apache.poi.hssf.model.InternalWorkbook; @@ -93,6 +91,8 @@ import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; /** * Testcases for bugs entered in bugzilla @@ -144,34 +144,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { } - /** - * Test reading AND writing a complicated workbook - * Test opening resulting sheet in excel - */ - @Test - public void bug15228() throws Exception { - simpleTest("15228.xls"); - } - - @Test - public void bug13796() throws Exception { - simpleTest("13796.xls"); - } - - /** - * test reading of a formula with a name and a cell ref in one - **/ - @Test - public void bug14460() throws Exception { - simpleTest("14460.xls"); - } - - @Test - public void bug14330() throws Exception { - simpleTest("14330-1.xls"); - simpleTest("14330-2.xls"); - } - private static void setCellText(HSSFCell cell, String text) { cell.setCellValue(new HSSFRichTextString(text)); } @@ -182,8 +154,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { */ @Test public void bug15375() throws Exception { - try (HSSFWorkbook wb = openSampleWorkbook("15375.xls")) { - HSSFSheet sheet = wb.getSheetAt(0); + try (HSSFWorkbook wb1 = openSampleWorkbook("15375.xls")) { + HSSFSheet sheet = wb1.getSheetAt(0); HSSFRow row = sheet.getRow(5); HSSFCell cell = row.getCell(3); @@ -197,24 +169,17 @@ public final class TestBugs extends BaseTestBugzillaIssues { // change existing numeric cell value HSSFRow oRow = sheet.getRow(14); - HSSFCell oCell = oRow.getCell(4); - oCell.setCellValue(75); - oCell = oRow.getCell(5); - setCellText(oCell, "0.3"); + oRow.getCell(4).setCellValue(75); + setCellText(oRow.getCell(5), "0.3"); - writeOutAndReadBack(wb).close(); + try (HSSFWorkbook wb2 = writeOutAndReadBack(wb1)) { + HSSFRow oRow2 = wb2.getSheetAt(0).getRow(14); + assertEquals(75, oRow2.getCell(4).getNumericCellValue()); + assertEquals("0.3", oRow2.getCell(5).getStringCellValue()); + } } } - /** - * test writing a file with large number of unique strings, - * open resulting file in Excel to check results! - */ - @Test - public void bug15375_2() throws Exception { - bug15375(6000); - } - /** * Double byte strings */ @@ -223,75 +188,18 @@ public final class TestBugs extends BaseTestBugzillaIssues { simpleTest("15556.xls", wb -> assertNotNull(wb.getSheetAt(0).getRow(45))); } - /** - * Double byte strings - */ - @Test - public void bug22742() throws IOException { - simpleTest("22742.xls"); - } - - /** - * Double byte strings - */ - @Test - public void bug12561_1() throws IOException { - simpleTest("12561-1.xls"); - } - - /** - * Double byte strings - */ - @Test - public void bug12561_2() throws IOException { - simpleTest("12561-2.xls"); - } - - /** - * Double byte strings - * File supplied by jubeson - */ - @Test - public void bug12843_1() throws IOException { - simpleTest("12843-1.xls"); - } - - /** - * Double byte strings - * File supplied by Paul Chung - */ - @Test - public void bug12843_2() throws IOException { - simpleTest("12843-2.xls"); - } - - /** - * Reference to Name - */ - @Test - public void bug13224() throws IOException { - simpleTest("13224.xls"); - } - - /** - * Illegal argument exception - cannot store duplicate value in Map - */ - @Test - public void bug19599() throws IOException { - simpleTest("19599-1.xls"); - simpleTest("19599-2.xls"); - } - @Test public void bug24215() throws Exception { try (HSSFWorkbook wb = openSampleWorkbook("24215.xls")) { for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets(); sheetIndex++) { HSSFSheet sheet = wb.getSheetAt(sheetIndex); + assertNotNull(sheet); int rows = sheet.getLastRowNum(); for (int rowIndex = 0; rowIndex < rows; rowIndex++) { HSSFRow row = sheet.getRow(rowIndex); + assertNotNull(row); int cells = row.getLastCellNum(); for (int cellIndex = 0; cellIndex < cells; cellIndex++) { @@ -369,22 +277,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { assertEquals(a.getRichStringCellValue().getString(), b.getRichStringCellValue().getString()); } - /** - * Error in opening wb - */ - @Test - public void bug32822() throws IOException { - simpleTest("32822.xls"); - } - - /** - * fail to read wb with chart - */ - @Test - public void bug15573() throws IOException { - simpleTest("15573.xls"); - } - /** * names and macros */ @@ -403,49 +295,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { } } - @Test - public void bug33082() throws IOException { - simpleTest("33082.xls"); - } - - @Test - public void bug34775() throws IOException { - // NullPointerException -> identified bug 34775 - simpleTest("34775.xls"); - } - - /** - * Error when reading then writing ArrayValues in NameRecord's - */ - @Test - public void bug37630() throws IOException { - simpleTest("37630.xls"); - } - - /** - * Bug 25183: org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet - */ - @Test - public void bug25183() throws IOException { - simpleTest("25183.xls"); - } - - /** - * Bug 26100: 128-character message in IF statement cell causes HSSFWorkbook open failure - */ - @Test - public void bug26100() throws IOException { - simpleTest("26100.xls"); - } - - /** - * Bug 27933: Unable to use a template (xls) file containing a wmf graphic - */ - @Test - public void bug27933() throws IOException { - simpleTest("27933.xls"); - } - /** * Bug 29206: NPE on HSSFSheet.getRow for blank rows */ @@ -463,14 +312,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { } } - /** - * Bug 29675: POI 2.5 final corrupts output when starting workbook has a graphic - */ - @Test - public void bug29675() throws IOException { - simpleTest("29675.xls"); - } - /** * Bug 29942: Importing Excel files that have been created by Open Office on Linux */ @@ -490,19 +331,12 @@ public final class TestBugs extends BaseTestBugzillaIssues { } assertEquals(85, count); //should read 85 rows - writeOutAndReadBack(wb).close(); + try (HSSFWorkbook wb2 = writeOutAndReadBack(wb)) { + assertNotNull(wb2.getSheetAt(0)); + } } } - /** - * Bug 29982: Unable to read spreadsheet when dropdown list cell is selected - - * Unable to construct record instance - */ - @Test - public void bug29982() throws Exception { - simpleTest("29982.xls"); - } - /** * Bug 30540: HSSFSheet.setRowBreak throws NullPointerException */ @@ -521,22 +355,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { } } - /** - * Bug 31749: {Need help urgently}[This is critical] workbook.write() corrupts the file......? - */ - @Test - public void bug31749() throws IOException { - simpleTest("31749.xls"); - } - - /** - * Bug 31979: {urgent help needed .....}poi library does not support form objects properly. - */ - @Test - public void bug31979() throws IOException { - simpleTest("31979.xls"); - } - /** * Bug 35564: HSSFCell.java: NullPtrExc in isGridsPrinted() and getProtect() * when HSSFWorkbook is created from file @@ -558,14 +376,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { simpleTest("35565.xls", wb -> assertNotNull(wb.getSheetAt(0))); } - /** - * Bug 37376: Cannot open the saved Excel file if checkbox controls exceed certain limit - */ - @Test - public void bug37376() throws Exception { - simpleTest("37376.xls"); - } - /** * Bug 40285: CellIterator Skips First Column */ @@ -615,42 +425,12 @@ public final class TestBugs extends BaseTestBugzillaIssues { } } - @Test - public void bug40738() throws Exception { - simpleTest("SimpleWithAutofilter.xls"); - } - /** * Bug 44200: Sheet not cloneable when Note added to excel cell */ @Test public void bug44200() throws Exception { - simpleTest("44200.xls", wb -> wb.cloneSheet(0)); - } - - /** - * Bug 44201: Sheet not cloneable when validation added to excel cell - */ - @Test - public void bug44201() throws Exception { - simpleTest("44201.xls"); - } - - /** - * Bug 37684 : Unhandled Continue Record Error - */ - @Test - public void bug37684() throws Exception { - simpleTest("37684-1.xls"); - simpleTest("37684-2.xls"); - } - - /** - * Bug 41139: Constructing HSSFWorkbook is failed,threw threw ArrayIndexOutOfBoundsException for creating UnknownRecord - */ - @Test - public void bug41139() throws Exception { - simpleTest("41139.xls"); + simpleTest("44200.xls", wb -> assertDoesNotThrow(() -> wb.cloneSheet(0))); } /** @@ -662,25 +442,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { simpleTest("41546.xls", wb -> assertEquals(1, wb.getNumberOfSheets())); } - /** - * Bug 42564: Some files from Access were giving a RecordFormatException - * when reading the BOFRecord - */ - @Test - public void bug42564() throws Exception { - simpleTest("ex42564-21435.xls"); - } - - /** - * Bug 42564: Some files from Access also have issues - * with the NameRecord, once you get past the BOFRecord - * issue. - */ - @Test - public void bug42564Alt() throws Exception { - simpleTest("ex42564-21503.xls"); - } - /** * Bug 42618: RecordFormatException reading a file containing * =CHOOSE(2,A2,A3,A4) @@ -796,43 +557,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { } } - /** - * Bug 28774: Excel will crash when opening xls-files with images. - */ - @Test - public void bug28774() throws Exception { - simpleTest("28774.xls"); - } - - /** - * Had a problem apparently, not sure what as it - * works just fine... - */ - @Test - public void bug44891() throws Exception { - simpleTest("44891.xls"); - } - - /** - * Bug 44235: Ms Excel can't open save as excel file - *
- * Works fine with poi-3.1-beta1.
- */
- @Test
- public void bug44235() throws Exception {
- simpleTest("44235.xls");
- }
-
- @Test
- public void bug36947() throws Exception {
- simpleTest("36947.xls");
- }
-
- @Test
- public void bug39634() throws Exception {
- simpleTest("39634.xls");
- }
-
/**
* Problems with extracting check boxes from
* HSSFObjectData
@@ -1467,19 +1191,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
}
- /**
- * java.io.IOException: block[ 0 ] already removed
- * (is an excel 95 file though)
- */
- @Test
- public void bug46904a() {
- OldExcelFormatException ex = assertThrows(
- OldExcelFormatException.class,
- () -> simpleTest("46904.xls")
- );
- assertTrue(ex.getMessage().contains("The supplied spreadsheet seems to be Excel"));
- }
-
/**
* java.lang.NegativeArraySizeException reading long
* non-unicode data for a name record
@@ -1524,28 +1235,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
}
- /**
- * POI 3.5 beta 7 can not read excel file contain list box (Form Control)
- */
- @Test
- public void bug47701() throws IOException {
- simpleTest("47701.xls");
- }
-
- @Test
- public void bug48026() throws IOException {
- simpleTest("48026.xls");
- }
-
- @Test
- public void bug47251() throws IOException {
- // Firstly, try with one that triggers on InterfaceHdrRecord
- simpleTest("47251.xls");
-
- // Now with one that triggers on NoteRecord
- simpleTest("47251_1.xls");
- }
-
/**
* Round trip a file with an unusual UnicodeString/ExtRst record parts
*/
@@ -1915,19 +1604,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
}
- /**
- * IllegalStateException received when creating Data validation in sheet with macro
- */
- @Test
- public void bug50020() throws Exception {
- simpleTest("50020.xls");
- }
-
- @Test
- public void bug50426() throws Exception {
- simpleTest("50426.xls");
- }
-
/**
* Last row number when shifting rows
*/
@@ -2056,13 +1732,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
wb2.close();
}
- @Test
- public void bug50779() throws Exception {
- simpleTest("50779_1.xls");
-
- simpleTest("50779_2.xls");
- }
-
/**
* The spec says that ChartEndObjectRecord has 6 reserved
* bytes on the end, but we sometimes find files without...
@@ -2186,11 +1855,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
}
- @Test
- public void bug51670() throws Exception {
- simpleTest("51670.xls");
- }
-
/**
* Sum across multiple workbooks
* eg =SUM($Sheet2.A1:$Sheet3.A1)
@@ -2215,15 +1879,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
}
- /**
- * Normally encrypted files have BOF then FILEPASS, but
- * some may squeeze a WRITEPROTECT in the middle
- */
- @Test
- public void bug51832() {
- assertThrows(EncryptedDocumentException.class, () -> simpleTest("51832.xls"));
- }
-
@Test
public void bug49896() throws Exception {
String exp = "VLOOKUP(A2,'[C:Documents and Settings/Yegor/My Documents/csco.xls]Sheet1'!$A$2:$B$3,2,FALSE)"
@@ -2348,11 +2003,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
}
- @Test
- public void bug54016() throws Exception {
- simpleTest("54016.xls");
- }
-
/**
* Row style information is 12 not 16 bits
*/
@@ -2370,20 +2020,17 @@ public final class TestBugs extends BaseTestBugzillaIssues {
/**
* POI does now support the RC4 CryptoAPI encryption header structure
*/
- @Test
- public void bug35897() throws Exception {
- String[] encrypted = {
- "xor-encryption-abc.xls", "abc",
- "35897-type4.xls", "freedom"
- };
-
- for (int i=0; i