From 77436875d14ed6fd30cee9d35f155c870bcd4bdd Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Fri, 10 Jan 2014 23:14:03 +0000 Subject: [PATCH] Bug 35897 - Password protected files + Junit4 modifications, needed for expected exceptions git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1557281 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/record/FilePassRecord.java | 5 +- .../apache/poi/hssf/record/RecordFactory.java | 45 +- .../org/apache/poi/xssf/AllXSSFTests.java | 38 +- .../xssf/usermodel/AllXSSFUsermodelTests.java | 70 +-- .../poi/xssf/usermodel/TestXSSFBugs.java | 170 ++++-- src/testcases/org/apache/poi/AllPOITests.java | 26 +- .../org/apache/poi/hssf/HSSFTests.java | 34 +- .../apache/poi/hssf/dev/TestBiffViewer.java | 3 +- .../poi/hssf/usermodel/AllUserModelTests.java | 108 ++-- .../apache/poi/hssf/usermodel/TestBugs.java | 574 +++++++++++------- .../ss/usermodel/BaseTestBugzillaIssues.java | 42 +- test-data/spreadsheet/xor-encryption-abc.xls | Bin 0 -> 4096 bytes 12 files changed, 678 insertions(+), 437 deletions(-) create mode 100644 test-data/spreadsheet/xor-encryption-abc.xls diff --git a/src/java/org/apache/poi/hssf/record/FilePassRecord.java b/src/java/org/apache/poi/hssf/record/FilePassRecord.java index c281bf9635..6961ed7df9 100644 --- a/src/java/org/apache/poi/hssf/record/FilePassRecord.java +++ b/src/java/org/apache/poi/hssf/record/FilePassRecord.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record; +import org.apache.poi.EncryptedDocumentException; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; @@ -49,7 +50,7 @@ public final class FilePassRecord extends StandardRecord { switch (_encryptionType) { case ENCRYPTION_XOR: - throw new RecordFormatException("HSSF does not currently support XOR obfuscation"); + throw new EncryptedDocumentException("HSSF does not currently support XOR obfuscation"); case ENCRYPTION_OTHER: // handled below break; @@ -63,7 +64,7 @@ public final class FilePassRecord extends StandardRecord { break; case ENCRYPTION_OTHER_CAPI_2: case ENCRYPTION_OTHER_CAPI_3: - throw new RecordFormatException( + throw new EncryptedDocumentException( "HSSF does not currently support CryptoAPI encryption"); default: throw new RecordFormatException("Unknown encryption info " + _encryptionInfo); diff --git a/src/java/org/apache/poi/hssf/record/RecordFactory.java b/src/java/org/apache/poi/hssf/record/RecordFactory.java index 2db4996db2..3a1f7acca3 100644 --- a/src/java/org/apache/poi/hssf/record/RecordFactory.java +++ b/src/java/org/apache/poi/hssf/record/RecordFactory.java @@ -22,10 +22,40 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; -import org.apache.poi.hssf.record.chart.*; -import org.apache.poi.hssf.record.pivottable.*; +import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.hssf.record.chart.BeginRecord; +import org.apache.poi.hssf.record.chart.CatLabRecord; +import org.apache.poi.hssf.record.chart.ChartEndBlockRecord; +import org.apache.poi.hssf.record.chart.ChartEndObjectRecord; +import org.apache.poi.hssf.record.chart.ChartFRTInfoRecord; +import org.apache.poi.hssf.record.chart.ChartRecord; +import org.apache.poi.hssf.record.chart.ChartStartBlockRecord; +import org.apache.poi.hssf.record.chart.ChartStartObjectRecord; +import org.apache.poi.hssf.record.chart.ChartTitleFormatRecord; +import org.apache.poi.hssf.record.chart.DataFormatRecord; +import org.apache.poi.hssf.record.chart.EndRecord; +import org.apache.poi.hssf.record.chart.LegendRecord; +import org.apache.poi.hssf.record.chart.LinkedDataRecord; +import org.apache.poi.hssf.record.chart.SeriesRecord; +import org.apache.poi.hssf.record.chart.SeriesTextRecord; +import org.apache.poi.hssf.record.chart.SeriesToChartGroupRecord; +import org.apache.poi.hssf.record.chart.ValueRangeRecord; +import org.apache.poi.hssf.record.pivottable.DataItemRecord; +import org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord; +import org.apache.poi.hssf.record.pivottable.PageItemRecord; +import org.apache.poi.hssf.record.pivottable.StreamIDRecord; +import org.apache.poi.hssf.record.pivottable.ViewDefinitionRecord; +import org.apache.poi.hssf.record.pivottable.ViewFieldsRecord; +import org.apache.poi.hssf.record.pivottable.ViewSourceRecord; /** * Title: Record Factory

@@ -62,7 +92,14 @@ public final class RecordFactory { } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { - throw new RecordFormatException("Unable to construct record instance" , e.getTargetException()); + Throwable t = e.getTargetException(); + if (t instanceof RecordFormatException) { + throw (RecordFormatException)t; + } else if (t instanceof EncryptedDocumentException) { + throw (EncryptedDocumentException)t; + } else { + throw new RecordFormatException("Unable to construct record instance" , t); + } } } public Class getRecordClass() { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java b/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java index d227a49934..3079970f08 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java @@ -17,9 +17,6 @@ package org.apache.poi.xssf; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.poi.ss.format.TestCellFormatPart; import org.apache.poi.ss.util.TestCellReference; import org.apache.poi.xssf.eventusermodel.TestXSSFReader; @@ -31,27 +28,26 @@ import org.apache.poi.xssf.model.TestStylesTable; import org.apache.poi.xssf.usermodel.AllXSSFUsermodelTests; import org.apache.poi.xssf.util.TestCTColComparator; import org.apache.poi.xssf.util.TestNumericRanges; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + /** * Collects all tests for org.apache.poi.xssf and sub-packages. - * - * @author Josh Micich */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + AllXSSFUsermodelTests.class, + TestXSSFReader.class, + TestXSSFExcelExtractor.class, + TestLoadSaveXSSF.class, + TestCommentsTable.class, + TestSharedStringsTable.class, + TestStylesTable.class, + TestCellReference.class, + TestCTColComparator.class, + TestNumericRanges.class, + TestCellFormatPart.class +}) public final class AllXSSFTests { - - public static Test suite() { - TestSuite result = new TestSuite(AllXSSFTests.class.getName()); - result.addTest(AllXSSFUsermodelTests.suite()); - result.addTestSuite(TestXSSFReader.class); - result.addTestSuite(TestXSSFExcelExtractor.class); - result.addTestSuite(TestLoadSaveXSSF.class); - result.addTestSuite(TestCommentsTable.class); - result.addTestSuite(TestSharedStringsTable.class); - result.addTestSuite(TestStylesTable.class); - result.addTestSuite(TestCellReference.class); - result.addTestSuite(TestCTColComparator.class); - result.addTestSuite(TestNumericRanges.class); - result.addTestSuite(TestCellFormatPart.class); - return result; - } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java index 5c5f69e6e5..11308159ba 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java @@ -17,53 +17,45 @@ package org.apache.poi.xssf.usermodel; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.poi.xssf.usermodel.extensions.TestXSSFBorder; import org.apache.poi.xssf.usermodel.extensions.TestXSSFCellFill; import org.apache.poi.xssf.usermodel.extensions.TestXSSFSheetComments; import org.apache.poi.xssf.usermodel.helpers.TestColumnHelper; import org.apache.poi.xssf.usermodel.helpers.TestHeaderFooterHelper; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * Collects all tests for org.apache.poi.xssf.usermodel and sub-packages. - * - * @author Josh Micich */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + TestFormulaEvaluatorOnXSSF.class, + TestSheetHiding.class, + TestXSSFBugs.class, + TestXSSFDataFormat.class, + TestXSSFCellStyle.class, + TestXSSFComment.class, + TestXSSFDialogSheet.class, + TestXSSFDrawing.class, + TestXSSFFont.class, + TestXSSFFormulaEvaluation.class, + TestXSSFHeaderFooter.class, + TestXSSFHyperlink.class, + TestXSSFName.class, + TestXSSFPicture.class, + TestXSSFPictureData.class, + TestXSSFPrintSetup.class, + TestXSSFRichTextString.class, + TestXSSFRow.class, + TestXSSFSheet.class, + TestXSSFSheetUpdateArrayFormulas.class, + TestXSSFWorkbook.class, + TestXSSFBorder.class, + TestXSSFCellFill.class, + TestXSSFSheetComments.class, + TestColumnHelper.class, + TestHeaderFooterHelper.class +}) public final class AllXSSFUsermodelTests { - - public static Test suite() { - TestSuite result = new TestSuite(AllXSSFUsermodelTests.class.getName()); - result.addTestSuite(TestFormulaEvaluatorOnXSSF.class); - result.addTestSuite(TestSheetHiding.class); - result.addTestSuite(TestXSSFBugs.class); - result.addTestSuite(TestXSSFDataFormat.class); - result.addTestSuite(TestXSSFCellStyle.class); - result.addTestSuite(TestXSSFComment.class); - result.addTestSuite(TestXSSFDialogSheet.class); - result.addTestSuite(TestXSSFDrawing.class); - result.addTestSuite(TestXSSFFont.class); - result.addTestSuite(TestXSSFFormulaEvaluation.class); - result.addTestSuite(TestXSSFHeaderFooter.class); - result.addTestSuite(TestXSSFHyperlink.class); - result.addTestSuite(TestXSSFName.class); - result.addTestSuite(TestXSSFPicture.class); - result.addTestSuite(TestXSSFPictureData.class); - result.addTestSuite(TestXSSFPrintSetup.class); - result.addTestSuite(TestXSSFRichTextString.class); - result.addTestSuite(TestXSSFRow.class); - result.addTestSuite(TestXSSFSheet.class); - result.addTestSuite(TestXSSFSheetUpdateArrayFormulas.class); - result.addTestSuite(TestXSSFWorkbook.class); - - result.addTestSuite(TestXSSFBorder.class); - result.addTestSuite(TestXSSFCellFill.class); - result.addTestSuite(TestXSSFSheetComments.class); - - result.addTestSuite(TestColumnHelper.class); - result.addTestSuite(TestHeaderFooterHelper.class); - - return result; - } } 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 4fce9b3492..faf5825b0d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -17,6 +17,13 @@ package org.apache.poi.xssf.usermodel; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -35,13 +42,32 @@ import org.apache.poi.ss.formula.WorkbookEvaluator; import org.apache.poi.ss.formula.eval.ErrorEval; import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.functions.Function; -import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Comment; +import org.apache.poi.ss.usermodel.CreationHelper; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.FormulaError; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.CellReference; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.model.CalculationChain; import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill; +import org.junit.Ignore; +import org.junit.Test; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet; @@ -55,15 +81,17 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * test writing a file with large number of unique strings, * open resulting file in Excel to check results! */ - public void test15375_2() { - baseTest15375(1000); + @Test + public void bug15375_2() { + bug15375(1000); } /** * Named ranges had the right reference, but * the wrong sheet name */ - public void test45430() { + @Test + public void bug45430() { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45430.xlsx"); assertFalse(wb.isMacroEnabled()); assertEquals(3, wb.getNumberOfNames()); @@ -92,7 +120,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * We should carry vba macros over after save */ - public void test45431() throws Exception { + @Test + public void bug45431() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45431.xlsm"); OPCPackage pkg = wb.getPackage(); assertTrue(wb.isMacroEnabled()); @@ -138,7 +167,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertNotNull(drw); } - public void test47504() { + @Test + public void bug47504() { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47504.xlsx"); assertEquals(1, wb.getNumberOfSheets()); XSSFSheet sh = wb.getSheetAt(0); @@ -163,14 +193,16 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * Clearly Excel shouldn't do this, but test that we can * read the file despite the naughtyness */ - public void test49020() throws Exception { + @Test + public void bug49020() throws Exception { /*XSSFWorkbook wb =*/ XSSFTestDataSamples.openSampleWorkbook("BrNotClosed.xlsx"); } /** * ensure that CTPhoneticPr is loaded by the ooxml test suite so that it is included in poi-ooxml-schemas */ - public void test49325() throws Exception { + @Test + public void bug49325() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49325.xlsx"); CTWorksheet sh = wb.getSheetAt(0).getCTWorksheet(); assertNotNull(sh.getPhoneticPr()); @@ -180,7 +212,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * Names which are defined with a Sheet * should return that sheet index properly */ - public void test48923() throws Exception { + @Test + public void bug48923() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48923.xlsx"); assertEquals(4, wb.getNumberOfNames()); @@ -218,7 +251,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * * TODO: delete this test case when MROUND and VAR are implemented */ - public void test48539() throws Exception { + @Test + public void bug48539() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48539.xlsx"); assertEquals(3, wb.getNumberOfSheets()); @@ -250,7 +284,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * Foreground colours should be found even if * a theme is used */ - public void test48779() throws Exception { + @Test + public void bug48779() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx"); XSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0); XSSFCellStyle cs = cell.getCellStyle(); @@ -265,7 +300,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { XSSFCellFill fg = wb.getStylesSource().getFillAt(2); assertEquals(0, fg.getFillForegroundColor().getIndexed()); - assertEquals(0.0, fg.getFillForegroundColor().getTint()); + assertEquals(0.0, fg.getFillForegroundColor().getTint(), 0); assertEquals("FFFF0000", fg.getFillForegroundColor().getARGBHex()); assertEquals(64, fg.getFillBackgroundColor().getIndexed()); @@ -288,7 +323,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * With XSSF, that wasn't the case, but this verfies * that it now is again */ - public void test48718() throws Exception { + @Test + public void bug48718() throws Exception { // Verify the HSSF behaviour // Then ensure the same for XSSF Workbook[] wbs = new Workbook[] { @@ -320,28 +356,29 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * Ensure General and @ format are working properly * for integers */ - public void test47490() throws Exception { + @Test + public void bug47490() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx"); Sheet s = wb.getSheetAt(1); Row r; DataFormatter df = new DataFormatter(); r = s.getRow(1); - assertEquals(1.0, r.getCell(2).getNumericCellValue()); + assertEquals(1.0, r.getCell(2).getNumericCellValue(), 0); assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString()); assertEquals("1", df.formatCellValue(r.getCell(2))); assertEquals("1", df.formatRawCellContents(1.0, -1, "@")); assertEquals("1", df.formatRawCellContents(1.0, -1, "General")); r = s.getRow(2); - assertEquals(12.0, r.getCell(2).getNumericCellValue()); + assertEquals(12.0, r.getCell(2).getNumericCellValue(), 0); assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString()); assertEquals("12", df.formatCellValue(r.getCell(2))); assertEquals("12", df.formatRawCellContents(12.0, -1, "@")); assertEquals("12", df.formatRawCellContents(12.0, -1, "General")); r = s.getRow(3); - assertEquals(123.0, r.getCell(2).getNumericCellValue()); + assertEquals(123.0, r.getCell(2).getNumericCellValue(), 0); assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString()); assertEquals("123", df.formatCellValue(r.getCell(2))); assertEquals("123", df.formatRawCellContents(123.0, -1, "@")); @@ -353,7 +390,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * and with the docs on when fetching the wrong * kind of value from a Formula cell */ - public void test47815() { + @Test + public void bug47815() { Workbook[] wbs = new Workbook[] { new HSSFWorkbook(), new XSSFWorkbook() @@ -388,7 +426,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(Cell.CELL_TYPE_STRING, cfs.getCachedFormulaResultType()); // Different ways of retrieving - assertEquals(1.2, cn.getNumericCellValue()); + assertEquals(1.2, cn.getNumericCellValue(), 0); try { cn.getRichStringCellValue(); fail(); @@ -400,7 +438,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { fail(); } catch(IllegalStateException e) {} - assertEquals(1.2, cfn.getNumericCellValue()); + assertEquals(1.2, cfn.getNumericCellValue(), 0); try { cfn.getRichStringCellValue(); fail(); @@ -422,14 +460,16 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * * The OPC spec tolerates both of these peculiarities, so does POI */ - public void test49609() throws Exception { + @Test + public void bug49609() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49609.xlsx"); assertEquals("FAM", wb.getSheetName(0)); assertEquals("Cycle", wb.getSheetAt(0).getRow(0).getCell(1).getStringCellValue()); } - public void test49783() throws Exception { + @Test + public void bug49783() throws Exception { Workbook wb = XSSFTestDataSamples.openSampleWorkbook("49783.xlsx"); Sheet sheet = wb.getSheetAt(0); FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -460,7 +500,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * preserve spaces to the 2nd bit, lest we end up * with something like "helloworld" ! */ - public void test49941() throws Exception { + @Test + public void bug49941() throws Exception { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet s = wb.createSheet(); XSSFRow r = s.createRow(0); @@ -534,7 +575,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Repeatedly writing the same file which has styles */ - public void test49940() throws Exception { + @Test + public void bug49940() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx"); assertEquals(3, wb.getNumberOfSheets()); assertEquals(10, wb.getStylesSource().getNumCellStyles()); @@ -560,7 +602,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * Various ways of removing a cell formula should all zap * the calcChain entry. */ - public void test49966() throws Exception { + @Test + public void bug49966() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("shared_formulas.xlsx"); XSSFSheet sheet = wb.getSheetAt(0); @@ -599,7 +642,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { } - public void test49156() throws Exception { + @Test + public void bug49156() throws Exception { Workbook wb = XSSFTestDataSamples.openSampleWorkbook("49156.xlsx"); FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -616,31 +660,33 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Newlines are valid characters in a formula */ - public void test50440And51875() throws Exception { + @Test + public void bug50440And51875() throws Exception { Workbook wb = XSSFTestDataSamples.openSampleWorkbook("NewlineInFormulas.xlsx"); Sheet s = wb.getSheetAt(0); Cell c = s.getRow(0).getCell(0); assertEquals("SUM(\n1,2\n)", c.getCellFormula()); - assertEquals(3.0, c.getNumericCellValue()); + assertEquals(3.0, c.getNumericCellValue(), 0); FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); formulaEvaluator.evaluateFormulaCell(c); assertEquals("SUM(\n1,2\n)", c.getCellFormula()); - assertEquals(3.0, c.getNumericCellValue()); + assertEquals(3.0, c.getNumericCellValue(), 0); // For 51875 Cell b3 = s.getRow(2).getCell(1); formulaEvaluator.evaluateFormulaCell(b3); assertEquals("B1+B2", b3.getCellFormula()); // The newline is lost for shared formulas - assertEquals(3.0, b3.getNumericCellValue()); + assertEquals(3.0, b3.getNumericCellValue(), 0); } /** * Moving a cell comment from one cell to another */ - public void test50795() throws Exception { + @Test + public void bug50795() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50795.xlsx"); XSSFSheet sheet = wb.getSheetAt(0); XSSFRow row = sheet.getRow(0); @@ -695,7 +741,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * shades of white or black. * For those cases, ensure we don't break on reading the colour */ - public void test50299() throws Exception { + @Test + public void bug50299() throws Exception { Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx"); // Check all the colours @@ -724,7 +771,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Excel .xls style indexed colours in a .xlsx file */ - public void test50786() throws Exception { + @Test + public void bug50786() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50786-indexed_colours.xlsx"); XSSFSheet s = wb.getSheetAt(0); XSSFRow r = s.getRow(2); @@ -745,7 +793,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * If the border colours are set with themes, then we * should still be able to get colours */ - public void test50846() throws Exception { + @Test + public void bug50846() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50846-border_colours.xlsx"); XSSFSheet sheet = wb.getSheetAt(0); @@ -773,7 +822,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * then being set explicitly still should allow the * fetching of the RGB. */ - public void test50784() throws Exception { + @Test + public void bug50784() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50784-font_theme_colours.xlsx"); XSSFSheet s = wb.getSheetAt(0); XSSFRow r = s.getRow(0); @@ -802,7 +852,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * New lines were being eaten when setting a font on * a rich text string */ - public void test48877() throws Exception { + @Test + public void bug48877() throws Exception { String text = "Use \n with word wrap on to create a new line.\n" + "This line finishes with two trailing spaces. "; @@ -870,7 +921,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Adding sheets when one has a table, then re-ordering */ - public void test50867() throws Exception { + @Test + public void bug50867() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50867_with_table.xlsx"); assertEquals(3, wb.getNumberOfSheets()); @@ -987,7 +1039,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * any print settings that were there before */ @SuppressWarnings("deprecation") - public void test49253() throws Exception { + @Test + public void bug49253() throws Exception { XSSFWorkbook wb1 = new XSSFWorkbook(); XSSFWorkbook wb2 = new XSSFWorkbook(); @@ -1028,7 +1081,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Default Column style */ - public void test51037() throws Exception { + @Test + public void bug51037() throws Exception { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet s = wb.createSheet(); @@ -1104,7 +1158,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * Repeatedly writing a file. * Something with the SharedStringsTable currently breaks... */ - public void DISABLEDtest46662() throws Exception { + @Ignore + public void bug46662() throws Exception { // New file XSSFWorkbook wb = new XSSFWorkbook(); XSSFTestDataSamples.writeOutAndReadBack(wb); @@ -1124,7 +1179,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Colours and styles when the list has gaps in it */ - public void test51222() throws Exception { + @Test + public void bug51222() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51222.xlsx"); XSSFSheet s = wb.getSheetAt(0); @@ -1162,7 +1218,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { // assertEquals("FF1F497D", cA5_1F497D.getCellStyle().getFillForegroundXSSFColor().getARGBHex()); } - public void test51470() throws Exception { + @Test + public void bug51470() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51470.xlsx"); XSSFSheet sh0 = wb.getSheetAt(0); XSSFSheet sh1 = wb.cloneSheet(0); @@ -1178,7 +1235,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * Add comments to Sheet 1, when Sheet 2 already has * comments (so /xl/comments1.xml is taken) */ - public void test51850() { + @Test + public void bug51850() { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51850.xlsx"); XSSFSheet sh1 = wb.getSheetAt(0); XSSFSheet sh2 = wb.getSheetAt(1); @@ -1235,7 +1293,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Sheet names with a , in them */ - public void test51963() throws Exception { + @Test + public void bug51963() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51963.xlsx"); XSSFSheet sheet = wb.getSheetAt(0); assertEquals("Abc,1", sheet.getSheetName()); @@ -1255,7 +1314,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * eg =SUM($Sheet1.C1:$Sheet4.C1) * DISABLED As we can't currently evaluate these */ - public void DISABLEDtest48703() throws Exception { + @Ignore + public void bug48703() throws Exception { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48703.xlsx"); XSSFSheet sheet = wb.getSheetAt(0); @@ -1265,10 +1325,10 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { XSSFCell c1 = r1.getCell(1); XSSFCell c2 = r2.getCell(1); - assertEquals(20.0, c1.getNumericCellValue()); + assertEquals(20.0, c1.getNumericCellValue(), 0); assertEquals("SUM(Sheet1!C1,Sheet2!C1,Sheet3!C1,Sheet4!C1)", c1.getCellFormula()); - assertEquals(20.0, c2.getNumericCellValue()); + assertEquals(20.0, c2.getNumericCellValue(), 0); assertEquals("SUM(Sheet1:Sheet4!C1)", c2.getCellFormula()); // Try evaluating both @@ -1276,14 +1336,15 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { eval.evaluateFormulaCell(c1); eval.evaluateFormulaCell(c2); - assertEquals(20.0, c1.getNumericCellValue()); - assertEquals(20.0, c2.getNumericCellValue()); + assertEquals(20.0, c1.getNumericCellValue(), 0); + assertEquals(20.0, c2.getNumericCellValue(), 0); } /** * Bugzilla 51710: problems reading shared formuals from .xlsx */ - public void test51710() { + @Test + public void bug51710() { Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51710.xlsx"); final String[] columns = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N"}; @@ -1313,7 +1374,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { /** * Bug 53101: */ - public void test5301(){ + @Test + public void bug5301(){ Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("53101.xlsx"); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); @@ -1332,7 +1394,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(259.0, a1Value, 0.0); } - public void test54436(){ + @Test + public void bug54436(){ Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("54436.xlsx"); if(!WorkbookEvaluator.getSupportedFunctionNames().contains("GETPIVOTDATA")){ Function func = new Function() { @@ -1351,7 +1414,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * error message when called via WorkbookFactory. * (You need to supply a password explicitly for them) */ - public void test55692() throws Exception { + @Test + public void bug55692() throws Exception { InputStream inpA = POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"); InputStream inpB = POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"); InputStream inpC = POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"); diff --git a/src/testcases/org/apache/poi/AllPOITests.java b/src/testcases/org/apache/poi/AllPOITests.java index 191b719500..0fba8f8288 100644 --- a/src/testcases/org/apache/poi/AllPOITests.java +++ b/src/testcases/org/apache/poi/AllPOITests.java @@ -22,23 +22,19 @@ import org.apache.poi.hpsf.basic.AllPOIHPSFBasicTests; import org.apache.poi.hssf.HSSFTests; import org.apache.poi.poifs.AllPOIFSTests; import org.apache.poi.util.AllPOIUtilTests; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * Root Test Suite for entire POI project. (Includes all sub-packages of org.apache.poi)
- * - * @author Josh Micich */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + TestPOIDocumentMain.class, + AllPOIDDFTests.class, + AllPOIHPSFBasicTests.class, + HSSFTests.class, + AllPOIFSTests.class, + AllPOIUtilTests.class +}) public final class AllPOITests { - public static Test suite() { - TestSuite result = new TestSuite("Tests for org.apache.poi"); - result.addTestSuite(TestPOIDocumentMain.class); - result.addTest(AllPOIDDFTests.suite()); - result.addTest(AllPOIHPSFBasicTests.suite()); - result.addTest(HSSFTests.suite()); - result.addTest(AllPOIFSTests.suite()); - result.addTest(AllPOIUtilTests.suite()); - return result; - } } diff --git a/src/testcases/org/apache/poi/hssf/HSSFTests.java b/src/testcases/org/apache/poi/hssf/HSSFTests.java index 7e58985ebb..28602758e1 100644 --- a/src/testcases/org/apache/poi/hssf/HSSFTests.java +++ b/src/testcases/org/apache/poi/hssf/HSSFTests.java @@ -17,9 +17,6 @@ package org.apache.poi.hssf; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.poi.hssf.eventmodel.TestEventRecordFactory; import org.apache.poi.hssf.eventusermodel.AllEventUserModelTests; import org.apache.poi.hssf.extractor.TestExcelExtractor; @@ -29,26 +26,23 @@ import org.apache.poi.hssf.usermodel.AllUserModelTests; import org.apache.poi.hssf.util.AllHSSFUtilTests; import org.apache.poi.ss.formula.AllSSFormulaTests; import org.apache.poi.ss.util.AllSSUtilTests; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * Test Suite for all sub-packages of org.apache.poi.hssf
- * - * @author Andrew C. Oliver acoliver@apache.org */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + AllEventUserModelTests.class, + AllModelTests.class, + AllUserModelTests.class, + AllRecordTests.class, + AllHSSFUtilTests.class, + TestExcelExtractor.class, + TestEventRecordFactory.class, + AllSSFormulaTests.class, + AllSSUtilTests.class +}) public final class HSSFTests { - - public static Test suite() { - TestSuite suite = new TestSuite(HSSFTests.class.getName()); - - suite.addTest(AllEventUserModelTests.suite()); - suite.addTest(AllModelTests.suite()); - suite.addTest(AllUserModelTests.suite()); - suite.addTest(AllRecordTests.suite()); - suite.addTest(AllHSSFUtilTests.suite()); - suite.addTest(new TestSuite(TestExcelExtractor.class)); - suite.addTest(new TestSuite(TestEventRecordFactory.class)); - suite.addTest(AllSSFormulaTests.suite()); - suite.addTest(AllSSUtilTests.suite()); - return suite; - } } diff --git a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java index 6f73b7fa7c..a97aa2ddc8 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java @@ -19,7 +19,8 @@ public class TestBiffViewer extends BaseXLSIteratingTest { SILENT_EXCLUDED.add("51832.xls"); // password SILENT_EXCLUDED.add("43493.xls"); // HSSFWorkbook cannot open it as well SILENT_EXCLUDED.add("password.xls"); - SILENT_EXCLUDED.add("46904.xls"); + SILENT_EXCLUDED.add("46904.xls"); + SILENT_EXCLUDED.add("xor-encryption-abc.xls"); // unsupported XOR-encryption }; @Override diff --git a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java index 8363449bfa..933e7f6377 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java @@ -17,66 +17,60 @@ package org.apache.poi.hssf.usermodel; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * Collects all tests for the org.apache.poi.hssf.usermodel package. - * - * @author Josh Micich */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + TestBug42464.class, + TestBugs.class, + TestCellStyle.class, + TestCloneSheet.class, + TestDataValidation.class, + TestEscherGraphics.class, + TestEscherGraphics2d.class, + TestFontDetails.class, + TestFormulaEvaluatorBugs.class, + TestFormulaEvaluatorDocs.class, + TestFormulas.class, + TestHSSFCell.class, + TestHSSFClientAnchor.class, + TestHSSFComment.class, + TestHSSFConditionalFormatting.class, + TestHSSFDataFormat.class, + TestHSSFDataFormatter.class, + TestHSSFDateUtil.class, + TestHSSFFont.class, + TestHSSFFormulaEvaluator.class, + TestHSSFHeaderFooter.class, + TestHSSFHyperlink.class, + TestHSSFName.class, + TestHSSFOptimiser.class, + TestHSSFPalette.class, + TestHSSFPatriarch.class, + TestHSSFPicture.class, + TestHSSFPictureData.class, + TestHSSFRichTextString.class, + TestHSSFRow.class, + TestHSSFSheet.class, + TestHSSFSheetShiftRows.class, + TestHSSFSheetUpdateArrayFormulas.class, + TestHSSFTextbox.class, + TestHSSFWorkbook.class, + TestOLE2Embeding.class, + TestPOIFSProperties.class, + TestReadWriteChart.class, + TestRowStyle.class, + TestSanityChecker.class, + TestSheetHiding.class, + /* deliberately avoiding this one + TestUnfixedBugs.class,*/ + TestUnicodeWorkbook.class, + TestNonStandardWorkbookStreamNames.class, + TestWorkbook.class +}) public class AllUserModelTests { - - public static Test suite() { - TestSuite result = new TestSuite(AllUserModelTests.class.getName()); - - result.addTestSuite(TestBug42464.class); - result.addTestSuite(TestBugs.class); - result.addTestSuite(TestCellStyle.class); - result.addTestSuite(TestCloneSheet.class); - result.addTestSuite(TestDataValidation.class); - result.addTestSuite(TestEscherGraphics.class); - result.addTestSuite(TestEscherGraphics2d.class); - result.addTestSuite(TestFontDetails.class); - result.addTestSuite(TestFormulaEvaluatorBugs.class); - result.addTestSuite(TestFormulaEvaluatorDocs.class); - result.addTestSuite(TestFormulas.class); - result.addTestSuite(TestHSSFCell.class); - result.addTestSuite(TestHSSFClientAnchor.class); - result.addTestSuite(TestHSSFComment.class); - result.addTestSuite(TestHSSFConditionalFormatting.class); - result.addTestSuite(TestHSSFDataFormat.class); - result.addTestSuite(TestHSSFDataFormatter.class); - result.addTestSuite(TestHSSFDateUtil.class); - result.addTestSuite(TestHSSFFont.class); - result.addTestSuite(TestHSSFFormulaEvaluator.class); - result.addTestSuite(TestHSSFHeaderFooter.class); - result.addTestSuite(TestHSSFHyperlink.class); - result.addTestSuite(TestHSSFName.class); - result.addTestSuite(TestHSSFOptimiser.class); - result.addTestSuite(TestHSSFPalette.class); - result.addTestSuite(TestHSSFPatriarch.class); - result.addTestSuite(TestHSSFPicture.class); - result.addTestSuite(TestHSSFPictureData.class); - result.addTestSuite(TestHSSFRichTextString.class); - result.addTestSuite(TestHSSFRow.class); - result.addTestSuite(TestHSSFSheet.class); - result.addTestSuite(TestHSSFSheetShiftRows.class); - result.addTestSuite(TestHSSFSheetUpdateArrayFormulas.class); - result.addTestSuite(TestHSSFTextbox.class); - result.addTestSuite(TestHSSFWorkbook.class); - result.addTestSuite(TestOLE2Embeding.class); - result.addTestSuite(TestPOIFSProperties.class); - result.addTestSuite(TestReadWriteChart.class); - result.addTestSuite(TestRowStyle.class); - result.addTestSuite(TestSanityChecker.class); - result.addTestSuite(TestSheetHiding.class); - /* deliberately avoiding this one - result.addTestSuite(TestUnfixedBugs.class);*/ - result.addTestSuite(TestUnicodeWorkbook.class); - result.addTestSuite(TestNonStandardWorkbookStreamNames.class); - result.addTestSuite(TestWorkbook.class); - - return result; - } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index d5684d84aa..4e325f5101 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -17,7 +17,25 @@ package org.apache.poi.hssf.usermodel; -import junit.framework.AssertionFailedError; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; +import java.util.List; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.hssf.HSSFITestDataProvider; @@ -26,7 +44,12 @@ 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; -import org.apache.poi.hssf.record.*; +import org.apache.poi.hssf.record.CellValueRecordInterface; +import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord; +import org.apache.poi.hssf.record.NameRecord; +import org.apache.poi.hssf.record.Record; +import org.apache.poi.hssf.record.TabIdRecord; +import org.apache.poi.hssf.record.UnknownRecord; import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; import org.apache.poi.hssf.record.aggregates.PageSettingsBlock; import org.apache.poi.hssf.record.aggregates.RecordAggregate; @@ -36,11 +59,17 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.formula.ptg.Area3DPtg; import org.apache.poi.ss.formula.ptg.DeletedArea3DPtg; import org.apache.poi.ss.formula.ptg.Ptg; -import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.TempFile; - -import java.io.*; -import java.util.*; +import org.junit.Ignore; +import org.junit.Test; /** * Testcases for bugs entered in bugzilla @@ -66,6 +95,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { return HSSFITestDataProvider.instance.writeOutAndReadBack(original); } + @SuppressWarnings("unused") private static void writeTestOutputFileForViewing(HSSFWorkbook wb, String simpleFileName) { if (true) { // set to false to output test files return; @@ -88,7 +118,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** Test reading AND writing a complicated workbook *Test opening resulting sheet in excel*/ - public void test15228() { + @Test + public void bug15228() { HSSFWorkbook wb = openSample("15228.xls"); HSSFSheet s = wb.getSheetAt(0); HSSFRow r = s.createRow(0); @@ -97,7 +128,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { writeTestOutputFileForViewing(wb, "test15228"); } - public void test13796() { + @Test + public void bug13796() { HSSFWorkbook wb = openSample("13796.xls"); HSSFSheet s = wb.getSheetAt(0); HSSFRow r = s.createRow(0); @@ -109,7 +141,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** test hyperlinks * open resulting file in excel, and check that there is a link to Google */ - public void test15353() { + @Test + public void bug15353() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("My sheet"); @@ -122,12 +155,14 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** test reading of a formula with a name and a cell ref in one **/ - public void test14460() { + @Test + public void bug14460() { HSSFWorkbook wb = openSample("14460.xls"); wb.getSheetAt(0); } - public void test14330() { + @Test + public void bug14330() { HSSFWorkbook wb = openSample("14330-1.xls"); wb.getSheetAt(0); @@ -141,7 +176,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** test rewriting a file with large number of unique strings *open resulting file in Excel to check results!*/ - public void test15375() { + @Test + public void bug15375() { HSSFWorkbook wb = openSample("15375.xls"); HSSFSheet sheet = wb.getSheetAt(0); @@ -168,54 +204,67 @@ public final class TestBugs extends BaseTestBugzillaIssues { * test writing a file with large number of unique strings, * open resulting file in Excel to check results! */ - public void test15375_2() { - baseTest15375(6000); + @Test + public void bug15375_2() { + bug15375(6000); } /**Double byte strings*/ - public void test15556() { - + @Test + public void bug15556() { HSSFWorkbook wb = openSample("15556.xls"); HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row = sheet.getRow(45); assertNotNull("Read row fine!" , row); } + /**Double byte strings */ - public void test22742() { + @Test + public void bug22742() { openSample("22742.xls"); } + /**Double byte strings */ - public void test12561_1() { + @Test + public void bug12561_1() { openSample("12561-1.xls"); } + /** Double byte strings */ - public void test12561_2() { + @Test + public void bug12561_2() { openSample("12561-2.xls"); } + /** Double byte strings File supplied by jubeson*/ - public void test12843_1() { + @Test + public void bug12843_1() { openSample("12843-1.xls"); } /** Double byte strings File supplied by Paul Chung*/ - public void test12843_2() { + @Test + public void bug12843_2() { openSample("12843-2.xls"); } /** Reference to Name*/ - public void test13224() { + @Test + public void bug13224() { openSample("13224.xls"); } /** Illegal argument exception - cannot store duplicate value in Map*/ - public void test19599() { + @Test + public void bug19599() { openSample("19599-1.xls"); openSample("19599-2.xls"); } - public void test24215() { + @Test + public void bug24215() { HSSFWorkbook wb = openSample("24215.xls"); for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets();sheetIndex++) { @@ -237,7 +286,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * bug and testcase submitted by Sompop Kumnoonsate * The file contains THAI unicode characters. */ - public void testUnicodeStringFormulaRead() { + @Test + public void bugUnicodeStringFormulaRead() { HSSFWorkbook w = openSample("25695.xls"); @@ -294,6 +344,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { private static void confirmSameCellText(HSSFCell a, HSSFCell b) { assertEquals(a.getRichStringCellValue().getString(), b.getRichStringCellValue().getString()); } + private static String unicodeString(HSSFCell cell) { String ss = cell.getRichStringCellValue().getString(); char s[] = ss.toCharArray(); @@ -305,16 +356,20 @@ public final class TestBugs extends BaseTestBugzillaIssues { } /** Error in opening wb*/ - public void test32822() { + @Test + public void bug32822() { openSample("32822.xls"); } + /**fail to read wb with chart */ - public void test15573() { + @Test + public void bug15573() { openSample("15573.xls"); } /**names and macros */ - public void test27852() { + @Test + public void bug27852() { HSSFWorkbook wb = openSample("27852.xls"); for(int i = 0 ; i < wb.getNumberOfNames(); i++){ @@ -327,20 +382,23 @@ public final class TestBugs extends BaseTestBugzillaIssues { } } - public void test33082() { + @Test + public void bug33082() { openSample("33082.xls"); } - public void test34775() { + @Test + public void bug34775() { try { openSample("34775.xls"); } catch (NullPointerException e) { - throw new AssertionFailedError("identified bug 34775"); + fail("identified bug 34775"); } } /** Error when reading then writing ArrayValues in NameRecord's*/ - public void test37630() { + @Test + public void bug37630() { HSSFWorkbook wb = openSample("37630.xls"); writeOutAndReadBack(wb); } @@ -348,7 +406,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 25183: org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet */ - public void test25183() { + @Test + public void bug25183() { HSSFWorkbook wb = openSample("25183.xls"); writeOutAndReadBack(wb); } @@ -356,7 +415,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 26100: 128-character message in IF statement cell causes HSSFWorkbook open failure */ - public void test26100() { + @Test + public void bug26100() { HSSFWorkbook wb = openSample("26100.xls"); writeOutAndReadBack(wb); } @@ -364,7 +424,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 27933: Unable to use a template (xls) file containing a wmf graphic */ - public void test27933() { + @Test + public void bug27933() { HSSFWorkbook wb = openSample("27933.xls"); writeOutAndReadBack(wb); } @@ -372,7 +433,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 29206: NPE on HSSFSheet.getRow for blank rows */ - public void test29206() { + @Test + public void bug29206() { //the first check with blank workbook HSSFWorkbook wb = openSample("Simple.xls"); HSSFSheet sheet = wb.createSheet(); @@ -387,7 +449,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 29675: POI 2.5 final corrupts output when starting workbook has a graphic */ - public void test29675() { + @Test + public void bug29675() { HSSFWorkbook wb = openSample("29675.xls"); writeOutAndReadBack(wb); } @@ -395,7 +458,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 29942: Importing Excel files that have been created by Open Office on Linux */ - public void test29942() { + @Test + public void bug29942() { HSSFWorkbook wb = openSample("29942.xls"); HSSFSheet sheet = wb.getSheetAt(0); @@ -417,7 +481,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Bug 29982: Unable to read spreadsheet when dropdown list cell is selected - * Unable to construct record instance */ - public void test29982() { + @Test + public void bug29982() { HSSFWorkbook wb = openSample("29982.xls"); writeOutAndReadBack(wb); } @@ -425,7 +490,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 30540: HSSFSheet.setRowBreak throws NullPointerException */ - public void test30540() { + @Test + public void bug30540() { HSSFWorkbook wb = openSample("30540.xls"); HSSFSheet s = wb.getSheetAt(0); @@ -436,7 +502,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 31749: {Need help urgently}[This is critical] workbook.write() corrupts the file......? */ - public void test31749() { + @Test + public void bug31749() { HSSFWorkbook wb = openSample("31749.xls"); writeOutAndReadBack(wb); } @@ -444,7 +511,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 31979: {urgent help needed .....}poi library does not support form objects properly. */ - public void test31979() { + @Test + public void bug31979() { HSSFWorkbook wb = openSample("31979.xls"); writeOutAndReadBack(wb); } @@ -453,7 +521,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Bug 35564: HSSFCell.java: NullPtrExc in isGridsPrinted() and getProtect() * when HSSFWorkbook is created from file */ - public void test35564() { + @Test + public void bug35564() { HSSFWorkbook wb = openSample("35564.xls"); HSSFSheet sheet = wb.getSheetAt( 0 ); @@ -466,7 +535,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 35565: HSSFCell.java: NullPtrExc in getColumnBreaks() when HSSFWorkbook is created from file */ - public void test35565() { + @Test + public void bug35565() { HSSFWorkbook wb = openSample("35565.xls"); HSSFSheet sheet = wb.getSheetAt( 0 ); @@ -477,7 +547,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 37376: Cannot open the saved Excel file if checkbox controls exceed certain limit */ - public void test37376() { + @Test + public void bug37376() { HSSFWorkbook wb = openSample("37376.xls"); writeOutAndReadBack(wb); } @@ -485,17 +556,18 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 40285: CellIterator Skips First Column */ - public void test40285() { + @Test + public void bug40285() { HSSFWorkbook wb = openSample("40285.xls"); HSSFSheet sheet = wb.getSheetAt( 0 ); int rownum = 0; - for (Iterator it = sheet.rowIterator(); it.hasNext(); rownum++) { - HSSFRow row = (HSSFRow)it.next(); + for (Iterator it = sheet.rowIterator(); it.hasNext(); rownum++) { + Row row = it.next(); assertEquals(rownum, row.getRowNum()); int cellNum = 0; - for (Iterator it2 = row.cellIterator(); it2.hasNext(); cellNum++) { - HSSFCell cell = (HSSFCell)it2.next(); + for (Iterator it2 = row.cellIterator(); it2.hasNext(); cellNum++) { + Cell cell = it2.next(); assertEquals(cellNum, cell.getColumnIndex()); } } @@ -511,7 +583,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * 3. Try adding a row break (via sheet.setRowBreak()) to the sheet mentioned in step #1 * 4. Get a NullPointerException */ - public void test38266() { + @Test + public void bug38266() { String[] files = {"Simple.xls", "SimpleMultiCell.xls", "duprich1.xls"}; for (int i = 0; i < files.length; i++) { HSSFWorkbook wb = openSample(files[i]); @@ -527,7 +600,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { } } - public void test40738() { + @Test + public void bug40738() { HSSFWorkbook wb = openSample("SimpleWithAutofilter.xls"); writeOutAndReadBack(wb); } @@ -535,7 +609,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 44200: Sheet not cloneable when Note added to excel cell */ - public void test44200() { + @Test + public void bug44200() { HSSFWorkbook wb = openSample("44200.xls"); wb.cloneSheet(0); @@ -545,7 +620,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 44201: Sheet not cloneable when validation added to excel cell */ - public void test44201() { + @Test + public void bug44201() { HSSFWorkbook wb = openSample("44201.xls"); writeOutAndReadBack(wb); } @@ -553,11 +629,11 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 37684 : Unhandled Continue Record Error */ - public void test37684 () { + @Test + public void bug37684 () { HSSFWorkbook wb = openSample("37684-1.xls"); writeOutAndReadBack(wb); - wb = openSample("37684-2.xls"); writeOutAndReadBack(wb); } @@ -565,7 +641,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 41139: Constructing HSSFWorkbook is failed,threw threw ArrayIndexOutOfBoundsException for creating UnknownRecord */ - public void test41139() { + @Test + public void bug41139() { HSSFWorkbook wb = openSample("41139.xls"); writeOutAndReadBack(wb); } @@ -574,7 +651,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Bug 41546: Constructing HSSFWorkbook is failed, * Unknown Ptg in Formula: 0x1a (26) */ - public void test41546() { + @Test + public void bug41546() { HSSFWorkbook wb = openSample("41546.xls"); assertEquals(1, wb.getNumberOfSheets()); wb = writeOutAndReadBack(wb); @@ -585,7 +663,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Bug 42564: Some files from Access were giving a RecordFormatException * when reading the BOFRecord */ - public void test42564() { + @Test + public void bug42564() { HSSFWorkbook wb = openSample("ex42564-21435.xls"); writeOutAndReadBack(wb); } @@ -595,7 +674,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * with the NameRecord, once you get past the BOFRecord * issue. */ - public void test42564Alt() { + @Test + public void bug42564Alt() { HSSFWorkbook wb = openSample("ex42564-21503.xls"); writeOutAndReadBack(wb); } @@ -604,7 +684,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Bug 42618: RecordFormatException reading a file containing * =CHOOSE(2,A2,A3,A4) */ - public void test42618() { + @Test + public void bug42618() { HSSFWorkbook wb = openSample("SimpleWithChoose.xls"); wb = writeOutAndReadBack(wb); // Check we detect the string properly too @@ -624,8 +705,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { assertEquals("CHOOSE(2,A2,A3,A4)", c2.getCellFormula()); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Too few arguments") - && e.getMessage().indexOf("ConcatPtg") > 0) { - throw new AssertionFailedError("identified bug 44306"); + && e.getMessage().indexOf("ConcatPtg") > 0) { + fail("identified bug 44306"); } } } @@ -633,34 +714,34 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Something up with the FileSharingRecord */ - public void test43251() { + @Test + public void bug43251() { // Used to blow up with an IllegalArgumentException // when creating a FileSharingRecord - HSSFWorkbook wb; try { - wb = openSample("43251.xls"); + HSSFWorkbook wb = openSample("43251.xls"); + assertEquals(1, wb.getNumberOfSheets()); } catch (IllegalArgumentException e) { - throw new AssertionFailedError("identified bug 43251"); + fail("identified bug 43251"); } - - assertEquals(1, wb.getNumberOfSheets()); } /** * Crystal reports generates files with short * StyleRecords, which is against the spec */ - public void test44471() { + @Test + public void bug44471() { // Used to blow up with an ArrayIndexOutOfBounds // when creating a StyleRecord HSSFWorkbook wb; - try { - wb = openSample("OddStyleRecord.xls"); - } catch (ArrayIndexOutOfBoundsException e) { - throw new AssertionFailedError("Identified bug 44471"); - } + //try { + wb = openSample("OddStyleRecord.xls"); + //} catch (ArrayIndexOutOfBoundsException e) { + // throw new AssertionFailedError("Identified bug 44471"); + //} assertEquals(1, wb.getNumberOfSheets()); } @@ -669,7 +750,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Files with "read only recommended" were giving * grief on the FileSharingRecord */ - public void test44536() { + @Test + public void bug44536() { // Used to blow up with an IllegalArgumentException // when creating a FileSharingRecord @@ -688,18 +770,19 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Some files were having problems with the DVRecord, * probably due to dropdowns */ - public void test44593() { + @Test + public void bug44593() { // Used to blow up with an IllegalArgumentException // when creating a DVRecord // Now won't, but no idea if this means we have // rubbish in the DVRecord or not... HSSFWorkbook wb; - try { - wb = openSample("44593.xls"); - } catch (IllegalArgumentException e) { - throw new AssertionFailedError("Identified bug 44593"); - } + //try { + wb = openSample("44593.xls"); + //} catch (IllegalArgumentException e) { + // throw new AssertionFailedError("Identified bug 44593"); + //} assertEquals(2, wb.getNumberOfSheets()); } @@ -708,15 +791,16 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Used to give problems due to trying to read a zero * length string, but that's now properly handled */ - public void test44643() { + @Test + public void bug44643() { // Used to blow up with an IllegalArgumentException HSSFWorkbook wb; - try { - wb = openSample("44643.xls"); - } catch (IllegalArgumentException e) { - throw new AssertionFailedError("identified bug 44643"); - } + //try { + wb = openSample("44643.xls"); + //} catch (IllegalArgumentException e) { + // throw new AssertionFailedError("identified bug 44643"); + //} assertEquals(1, wb.getNumberOfSheets()); } @@ -725,7 +809,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * User reported the wrong number of rows from the * iterator, but we can't replicate that */ - public void test44693() { + @Test + public void bug44693() { HSSFWorkbook wb = openSample("44693.xls"); HSSFSheet s = wb.getSheetAt(0); @@ -737,8 +822,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { // Now check the iterator int rowsSeen = 0; - for(Iterator i = s.rowIterator(); i.hasNext(); ) { - HSSFRow r = (HSSFRow)i.next(); + for(Iterator i = s.rowIterator(); i.hasNext(); ) { + Row r = i.next(); assertNotNull(r); rowsSeen++; } @@ -748,7 +833,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Bug 28774: Excel will crash when opening xls-files with images. */ - public void test28774() { + @Test + public void bug28774() { HSSFWorkbook wb = openSample("28774.xls"); assertTrue("no errors reading sample xls", true); writeOutAndReadBack(wb); @@ -759,7 +845,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Had a problem apparently, not sure what as it * works just fine... */ - public void test44891() { + @Test + public void bug44891() { HSSFWorkbook wb = openSample("44891.xls"); assertTrue("no errors reading sample xls", true); writeOutAndReadBack(wb); @@ -771,21 +858,24 @@ public final class TestBugs extends BaseTestBugzillaIssues { * * Works fine with poi-3.1-beta1. */ - public void test44235() { + @Test + public void bug44235() { HSSFWorkbook wb = openSample("44235.xls"); assertTrue("no errors reading sample xls", true); writeOutAndReadBack(wb); assertTrue("no errors writing sample xls", true); } - public void test36947() { + @Test + public void bug36947() { HSSFWorkbook wb = openSample("36947.xls"); assertTrue("no errors reading sample xls", true); writeOutAndReadBack(wb); assertTrue("no errors writing sample xls", true); } - public void test39634() { + @Test + public void bug39634() { HSSFWorkbook wb = openSample("39634.xls"); assertTrue("no errors reading sample xls", true); writeOutAndReadBack(wb); @@ -797,11 +887,12 @@ public final class TestBugs extends BaseTestBugzillaIssues { * HSSFObjectData * @throws Exception */ - public void test44840() { + @Test + public void bug44840() { HSSFWorkbook wb = openSample("WithCheckBoxes.xls"); // Take a look at the embedded objects - List objects = wb.getAllEmbeddedObjects(); + List objects = wb.getAllEmbeddedObjects(); assertEquals(1, objects.size()); HSSFObjectData obj = (HSSFObjectData)objects.get(0); @@ -837,7 +928,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * breaking the build in named ranges * used for printing stuff. */ - public void test30978() { + @Test + public void bug30978() { HSSFWorkbook wb = openSample("30978-alt.xls"); assertEquals(1, wb.getNumberOfNames()); assertEquals(3, wb.getNumberOfSheets()); @@ -893,7 +985,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Test that fonts get added properly */ - public void test45338() { + @Test + public void bug45338() { HSSFWorkbook wb = new HSSFWorkbook(); assertEquals(4, wb.getNumberOfFonts()); @@ -978,7 +1071,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * From the mailing list - ensure we can handle a formula * containing a zip code, eg ="70164" */ - public void testZipCodeFormulas() { + @Test + public void bugZipCodeFormulas() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet(); s.createRow(0); @@ -1006,7 +1100,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { confirmCachedValue("test", c3); try { c3.getNumericCellValue(); - throw new AssertionFailedError("exception should have been thrown"); + fail("exception should have been thrown"); } catch (IllegalStateException e) { assertEquals("Cannot get a numeric value from a text formula cell", e.getMessage()); } @@ -1084,7 +1178,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * For now, blows up with an exception from ExtPtg * Expected ExpPtg to be converted from Shared to Non-Shared... */ - public void DISABLEDtest43623() { + @Ignore + public void test43623() { HSSFWorkbook wb = openSample("43623.xls"); assertEquals(1, wb.getNumberOfSheets()); @@ -1115,7 +1210,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * People are all getting confused about the last * row and cell number */ - public void test30635() { + @Test + public void bug30635() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet(); @@ -1163,7 +1259,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Data Tables - ptg 0x2 */ - public void test44958() { + @Test + public void bug44958() { HSSFWorkbook wb = openSample("44958.xls"); HSSFSheet s; HSSFRow r; @@ -1194,7 +1291,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * 45322: HSSFSheet.autoSizeColumn fails when style.getDataFormat() returns -1 */ - public void test45322() { + @Test + public void bug45322() { HSSFWorkbook wb = openSample("44958.xls"); HSSFSheet sh = wb.getSheetAt(0); for(short i=0; i < 30; i++) sh.autoSizeColumn(i); @@ -1204,7 +1302,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * We used to add too many UncalcRecords to sheets * with diagrams on. Don't any more */ - public void test45414() { + @Test + public void bug45414() { HSSFWorkbook wb = openSample("WithThreeCharts.xls"); wb.getSheetAt(0).setForceFormulaRecalculation(true); wb.getSheetAt(1).setForceFormulaRecalculation(false); @@ -1223,7 +1322,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Very hidden sheets not displaying as such */ - public void test45761() { + @Test + public void bug45761() { HSSFWorkbook wb = openSample("45761.xls"); assertEquals(3, wb.getNumberOfSheets()); @@ -1252,7 +1352,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * record was 256 bytes. This assumption appears to be wrong. Since the fix for bug 47244, * POI now supports header / footer text lengths beyond 256 bytes. */ - public void test45777() { + @Test + public void bug45777() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet(); @@ -1280,14 +1381,9 @@ public final class TestBugs extends BaseTestBugzillaIssues { try { s.getHeader().setCenter(s250); // 256 bytes required - } catch(IllegalArgumentException e) { - throw new AssertionFailedError("Identified bug 47244b - header can be more than 256 bytes"); - } - - try { s.getHeader().setCenter(s251); // 257 bytes required } catch(IllegalArgumentException e) { - throw new AssertionFailedError("Identified bug 47244b - header can be more than 256 bytes"); + fail("Identified bug 47244b - header can be more than 256 bytes"); } // Now try on footers @@ -1301,21 +1397,17 @@ public final class TestBugs extends BaseTestBugzillaIssues { try { s.getFooter().setCenter(s250); // 256 bytes required - } catch(IllegalArgumentException e) { - throw new AssertionFailedError("Identified bug 47244b - footer can be more than 256 bytes"); - } - - try { s.getFooter().setCenter(s251); // 257 bytes required } catch(IllegalArgumentException e) { - throw new AssertionFailedError("Identified bug 47244b - footer can be more than 256 bytes"); + fail("Identified bug 47244b - footer can be more than 256 bytes"); } } /** * Charts with long titles */ - public void test45784() { + @Test + public void bug45784() { // This used to break HSSFWorkbook wb = openSample("45784.xls"); assertEquals(1, wb.getNumberOfSheets()); @@ -1325,7 +1417,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Cell background colours */ - public void test45492() { + @Test + public void bug45492() { HSSFWorkbook wb = openSample("45492.xls"); HSSFSheet s = wb.getSheetAt(0); HSSFRow r = s.getRow(0); @@ -1361,7 +1454,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * ContinueRecord after EOF */ - public void test46137() { + @Test + public void bug46137() { // This used to break HSSFWorkbook wb = openSample("46137.xls"); assertEquals(7, wb.getNumberOfSheets()); @@ -1372,7 +1466,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Odd POIFS blocks issue: * block[ 44 ] already removed from org.apache.poi.poifs.storage.BlockListImpl.remove */ - public void test45290() { + @Test + public void bug45290() { HSSFWorkbook wb = openSample("45290.xls"); assertEquals(1, wb.getNumberOfSheets()); } @@ -1381,7 +1476,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * In POI-2.5 user reported exception when parsing a name with a custom VBA function: * =MY_VBA_FUNCTION("lskdjflsk") */ - public void test30070() { + @Test + public void bug30070() { HSSFWorkbook wb = openSample("30070.xls"); //contains custom VBA function 'Commission' HSSFSheet sh = wb.getSheetAt(0); HSSFCell cell = sh.getRow(0).getCell(1); @@ -1413,7 +1509,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Sheet1!$A$3 * */ - public void test27364() { + @Test + public void bug27364() { HSSFWorkbook wb = openSample("27364.xls"); HSSFSheet sheet = wb.getSheetAt(0); @@ -1426,7 +1523,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Similar to bug#27364: * HSSFCell.getCellFormula() fails with references to external workbooks */ - public void test31661() { + @Test + public void bug31661() { HSSFWorkbook wb = openSample("31661.xls"); HSSFSheet sheet = wb.getSheetAt(0); HSSFCell cell = sheet.getRow(11).getCell(10); //K11 @@ -1436,7 +1534,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Incorrect handling of non-ISO 8859-1 characters in Windows ANSII Code Page 1252 */ - public void test27394() { + @Test + public void bug27394() { HSSFWorkbook wb = openSample("27394.xls"); assertEquals("\u0161\u017E", wb.getSheetName(0)); assertEquals("\u0161\u017E\u010D\u0148\u0159", wb.getSheetName(1)); @@ -1449,7 +1548,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Multiple calls of HSSFWorkbook.write result in corrupted xls */ - public void test32191() throws IOException { + @Test + public void bug32191() throws IOException { HSSFWorkbook wb = openSample("27394.xls"); ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -1475,7 +1575,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * java.io.IOException: block[ 0 ] already removed * (is an excel 95 file though) */ - public void test46904() { + @Test + public void bug46904() { try { openSample("46904.xls"); fail(); @@ -1490,7 +1591,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * java.lang.NegativeArraySizeException reading long * non-unicode data for a name record */ - public void test47034() { + @Test + public void bug47034() { HSSFWorkbook wb = openSample("47034.xls"); assertEquals(893, wb.getNumberOfNames()); assertEquals("Matthew\\Matthew11_1\\Matthew2331_1\\Matthew2351_1\\Matthew2361_1___lab", wb.getNameName(300)); @@ -1500,7 +1602,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * HSSFRichTextString.length() returns negative for really long strings. * The test file was created in OpenOffice 3.0 as Excel does not allow cell text longer than 32,767 characters */ - public void test46368() { + @Test + public void bug46368() { HSSFWorkbook wb = openSample("46368.xls"); HSSFSheet s = wb.getSheetAt(0); HSSFCell cell1 = s.getRow(0).getCell(0); @@ -1513,7 +1616,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * Short records on certain sheets with charts in them */ - public void test48180() { + @Test + public void bug48180() { HSSFWorkbook wb = openSample("48180.xls"); HSSFSheet s = wb.getSheetAt(0); @@ -1527,22 +1631,26 @@ public final class TestBugs extends BaseTestBugzillaIssues { /** * POI 3.5 beta 7 can not read excel file contain list box (Form Control) */ - public void test47701() { + @Test + public void bug47701() { openSample("47701.xls"); } - public void test48026() { + @Test + public void bug48026() { openSample("48026.xls"); } - public void test47251() { + @Test + public void bug47251() { openSample("47251.xls"); } /** * Round trip a file with an unusual UnicodeString/ExtRst record parts */ - public void test47847() throws Exception { + @Test + public void bug47847() throws Exception { HSSFWorkbook wb = openSample("47847.xls"); assertEquals(3, wb.getNumberOfSheets()); @@ -1578,7 +1686,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Problem with cloning a sheet with a chart * contained in it. */ - public void test49096() throws Exception { + @Test + public void bug49096() throws Exception { HSSFWorkbook wb = openSample("49096.xls"); assertEquals(1, wb.getNumberOfSheets()); @@ -1597,7 +1706,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Also ensure that print setup refs are * by reference not value */ - public void test46664() throws Exception { + @Test + public void bug46664() throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("new_sheet"); HSSFRow row = sheet.createRow((short)0); @@ -1651,7 +1761,8 @@ public final class TestBugs extends BaseTestBugzillaIssues { * Problems with formula references to * sheets via URLs */ - public void test45970() throws Exception { + @Test + public void bug45970() throws Exception { HSSFWorkbook wb = openSample("FormulaRefs.xls"); assertEquals(3, wb.getNumberOfSheets()); @@ -1660,27 +1771,27 @@ public final class TestBugs extends BaseTestBugzillaIssues { row = s.getRow(0); assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(1); assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); assertEquals("B1", row.getCell(1).getCellFormula()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(2); assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); assertEquals("Sheet1!B1", row.getCell(1).getCellFormula()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(3); assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(4); assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); // Change 4 row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2"); @@ -1699,41 +1810,42 @@ public final class TestBugs extends BaseTestBugzillaIssues { row = s.getRow(0); assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(),0); row = s.getRow(1); assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); assertEquals("B1", row.getCell(1).getCellFormula()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(2); assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); assertEquals("Sheet1!B1", row.getCell(1).getCellFormula()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(3); assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula()); - assertEquals(112.0, row.getCell(1).getNumericCellValue()); + assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); -// TODO - Fix these so they work... -if(1==2) { - row = s.getRow(4); - assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); - assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula()); - assertEquals(123.0, row.getCell(1).getNumericCellValue()); - - row = s.getRow(5); - assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); - assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula()); - assertEquals(234.0, row.getCell(1).getNumericCellValue()); -} + // TODO - Fix these so they work... + if(1==2) { + row = s.getRow(4); + assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); + assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula()); + assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0); + + row = s.getRow(5); + assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType()); + assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula()); + assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0); + } } /** * Test for a file with NameRecord with NameCommentRecord comments */ - public void test49185() throws Exception { + @Test + public void bug49185() throws Exception { HSSFWorkbook wb = openSample("49185.xls"); Name name = wb.getName("foobarName"); assertEquals("This is a comment", name.getComment()); @@ -1760,7 +1872,8 @@ if(1==2) { /** * Vertically aligned text */ - public void test49524() throws Exception { + @Test + public void bug49524() throws Exception { HSSFWorkbook wb = openSample("49524.xls"); Sheet s = wb.getSheetAt(0); Row r = s.getRow(0); @@ -1797,7 +1910,8 @@ if(1==2) { /** * Setting the user style name on custom styles */ - public void test49689() throws Exception { + @Test + public void bug49689() throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet("Test"); HSSFRow r = s.createRow(0); @@ -1828,7 +1942,8 @@ if(1==2) { assertEquals("Testing 3", wb.getCellStyleAt((short)23).getUserStyleName()); } - public void test49751() { + @Test + public void bug49751() { HSSFWorkbook wb = openSample("49751.xls"); short numCellStyles = wb.getNumCellStyles(); List namedStyles = Arrays.asList( @@ -1854,7 +1969,8 @@ if(1==2) { /** * Regression with the PageSettingsBlock */ - public void test49931() throws Exception { + @Test + public void bug49931() throws Exception { HSSFWorkbook wb = openSample("49931.xls"); assertEquals(1, wb.getNumberOfSheets()); @@ -1864,7 +1980,8 @@ if(1==2) { /** * Missing left/right/centre options on a footer */ - public void test48325() throws Exception { + @Test + public void bug48325() throws Exception { HSSFWorkbook wb = openSample("48325.xls"); HSSFSheet sh = wb.getSheetAt(0); HSSFFooter f = sh.getFooter(); @@ -1882,12 +1999,14 @@ if(1==2) { /** * IllegalStateException received when creating Data validation in sheet with macro */ - public void test50020() throws Exception { + @Test + public void bug50020() throws Exception { HSSFWorkbook wb = openSample("50020.xls"); writeOutAndReadBack(wb); } - public void test50426() throws Exception { + @Test + public void bug50426() throws Exception { HSSFWorkbook wb = openSample("50426.xls"); writeOutAndReadBack(wb); } @@ -1895,7 +2014,8 @@ if(1==2) { /** * Last row number when shifting rows */ - public void test50416LastRowNumber() { + @Test + public void bug50416LastRowNumber() { // Create the workbook with 1 sheet which contains 3 rows HSSFWorkbook workbook = new HSSFWorkbook(); Sheet sheet = workbook.createSheet("Bug50416"); @@ -1950,16 +2070,17 @@ if(1==2) { * If you send a file between Excel and OpenOffice enough, something * will turn the "General" format into "GENERAL" */ - public void test50756() throws Exception { + @Test + public void bug50756() throws Exception { HSSFWorkbook wb = openSample("50756.xls"); HSSFSheet s = wb.getSheetAt(0); HSSFRow r17 = s.getRow(16); HSSFRow r18 = s.getRow(17); HSSFDataFormatter df = new HSSFDataFormatter(); - assertEquals(10.0, r17.getCell(1).getNumericCellValue()); - assertEquals(20.0, r17.getCell(2).getNumericCellValue()); - assertEquals(20.0, r17.getCell(3).getNumericCellValue()); + assertEquals(10.0, r17.getCell(1).getNumericCellValue(), 0); + assertEquals(20.0, r17.getCell(2).getNumericCellValue(), 0); + assertEquals(20.0, r17.getCell(3).getNumericCellValue(), 0); assertEquals("GENERAL", r17.getCell(1).getCellStyle().getDataFormatString()); assertEquals("GENERAL", r17.getCell(2).getCellStyle().getDataFormatString()); assertEquals("GENERAL", r17.getCell(3).getCellStyle().getDataFormatString()); @@ -1967,9 +2088,9 @@ if(1==2) { assertEquals("20", df.formatCellValue(r17.getCell(2))); assertEquals("20", df.formatCellValue(r17.getCell(3))); - assertEquals(16.0, r18.getCell(1).getNumericCellValue()); - assertEquals(35.0, r18.getCell(2).getNumericCellValue()); - assertEquals(123.0, r18.getCell(3).getNumericCellValue()); + assertEquals(16.0, r18.getCell(1).getNumericCellValue(), 0); + assertEquals(35.0, r18.getCell(2).getNumericCellValue(), 0); + assertEquals(123.0, r18.getCell(3).getNumericCellValue(), 0); assertEquals("GENERAL", r18.getCell(1).getCellStyle().getDataFormatString()); assertEquals("GENERAL", r18.getCell(2).getCellStyle().getDataFormatString()); assertEquals("GENERAL", r18.getCell(3).getCellStyle().getDataFormatString()); @@ -1984,7 +2105,8 @@ if(1==2) { * TODO Identify the cause and add extra asserts for * the bit excel cares about */ - public void test50833() throws Exception { + @Test + public void bug50833() throws Exception { HSSFWorkbook wb = openSample("50833.xls"); HSSFSheet s = wb.getSheetAt(0); assertEquals("Sheet1", s.getSheetName()); @@ -2012,7 +2134,8 @@ if(1==2) { // TODO Identify what excel doesn't like, and check for that } - public void test50779() throws Exception { + @Test + public void bug50779() throws Exception { HSSFWorkbook wb1 = openSample("50779_1.xls"); writeOutAndReadBack(wb1); @@ -2024,18 +2147,21 @@ if(1==2) { * The spec says that ChartEndObjectRecord has 6 reserved * bytes on the end, but we sometimes find files without... */ - public void test50939() throws Exception { + @Test + public void bug50939() throws Exception { HSSFWorkbook wb = openSample("50939.xls"); assertEquals(2, wb.getNumberOfSheets()); } - public void test49219() throws Exception { + @Test + public void bug49219() throws Exception { HSSFWorkbook wb = openSample("49219.xls"); assertEquals(1, wb.getNumberOfSheets()); assertEquals("DGATE", wb.getSheetAt(0).getRow(1).getCell(0).getStringCellValue()); } - public void test48968() throws Exception { + @Test + public void bug48968() throws Exception { HSSFWorkbook wb = openSample("48968.xls"); assertEquals(1, wb.getNumberOfSheets()); @@ -2054,20 +2180,20 @@ if(1==2) { // Check the cached values assertEquals("HOUR(A1)", s.getRow(5).getCell(0).getCellFormula()); - assertEquals(11.0, s.getRow(5).getCell(0).getNumericCellValue()); + assertEquals(11.0, s.getRow(5).getCell(0).getNumericCellValue(), 0); assertEquals("MINUTE(A1)", s.getRow(6).getCell(0).getCellFormula()); - assertEquals(39.0, s.getRow(6).getCell(0).getNumericCellValue()); + assertEquals(39.0, s.getRow(6).getCell(0).getNumericCellValue(), 0); assertEquals("SECOND(A1)", s.getRow(7).getCell(0).getCellFormula()); - assertEquals(54.0, s.getRow(7).getCell(0).getNumericCellValue()); + assertEquals(54.0, s.getRow(7).getCell(0).getNumericCellValue(), 0); // Re-evaulate and check HSSFFormulaEvaluator.evaluateAllFormulaCells(wb); assertEquals("HOUR(A1)", s.getRow(5).getCell(0).getCellFormula()); - assertEquals(11.0, s.getRow(5).getCell(0).getNumericCellValue()); + assertEquals(11.0, s.getRow(5).getCell(0).getNumericCellValue(), 0); assertEquals("MINUTE(A1)", s.getRow(6).getCell(0).getCellFormula()); - assertEquals(39.0, s.getRow(6).getCell(0).getNumericCellValue()); + assertEquals(39.0, s.getRow(6).getCell(0).getNumericCellValue(), 0); assertEquals("SECOND(A1)", s.getRow(7).getCell(0).getCellFormula()); - assertEquals(54.0, s.getRow(7).getCell(0).getNumericCellValue()); + assertEquals(54.0, s.getRow(7).getCell(0).getNumericCellValue(), 0); // Push the time forward a bit and check double date = s.getRow(0).getCell(0).getNumericCellValue(); @@ -2075,17 +2201,18 @@ if(1==2) { HSSFFormulaEvaluator.evaluateAllFormulaCells(wb); assertEquals("HOUR(A1)", s.getRow(5).getCell(0).getCellFormula()); - assertEquals(11.0+6.0, s.getRow(5).getCell(0).getNumericCellValue()); + assertEquals(11.0+6.0, s.getRow(5).getCell(0).getNumericCellValue(), 0); assertEquals("MINUTE(A1)", s.getRow(6).getCell(0).getCellFormula()); - assertEquals(39.0+14.0+1, s.getRow(6).getCell(0).getNumericCellValue()); + assertEquals(39.0+14.0+1, s.getRow(6).getCell(0).getNumericCellValue(), 0); assertEquals("SECOND(A1)", s.getRow(7).getCell(0).getCellFormula()); - assertEquals(54.0+24.0-60, s.getRow(7).getCell(0).getNumericCellValue()); + assertEquals(54.0+24.0-60, s.getRow(7).getCell(0).getNumericCellValue(), 0); } /** * HLookup and VLookup with optional arguments */ - public void test51024() throws Exception { + @Test + public void bug51024() throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet(); HSSFRow r1 = s.createRow(0); @@ -2123,7 +2250,8 @@ if(1==2) { * Mixture of Ascii and Unicode strings in a * NameComment record */ - public void test51143() throws Exception { + @Test + public void bug51143() throws Exception { HSSFWorkbook wb = openSample("51143.xls"); assertEquals(1, wb.getNumberOfSheets()); wb = writeOutAndReadBack(wb); @@ -2134,7 +2262,9 @@ if(1==2) { * File with exactly 256 data blocks (+header block) * shouldn't break on POIFS loading */ - public void test51461() throws Exception { + @SuppressWarnings("resource") + @Test + public void bug51461() throws Exception { byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51461.xls"); HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem( @@ -2149,7 +2279,9 @@ if(1==2) { /** * Large row numbers and NPOIFS vs POIFS */ - public void test51535() throws Exception { + @SuppressWarnings("resource") + @Test + public void bug51535() throws Exception { byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51535.xls"); HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem( @@ -2174,10 +2306,12 @@ if(1==2) { assertTrue(text.contains("Top Right Cell")); assertTrue(text.contains("Bottom Left Cell")); assertTrue(text.contains("Bottom Right Cell")); + ex.close(); } } - public void test51670() { + @Test + public void bug51670() { HSSFWorkbook wb = openSample("51670.xls"); writeOutAndReadBack(wb); } @@ -2187,7 +2321,8 @@ if(1==2) { * eg =SUM($Sheet2.A1:$Sheet3.A1) * DISABLED - We currently get the formula wrong, and mis-evaluate */ - public void DISABLEDtest48703() { + @Ignore + public void test48703() { HSSFWorkbook wb = openSample("48703.xls"); assertEquals(3, wb.getNumberOfSheets()); @@ -2197,19 +2332,20 @@ if(1==2) { Cell c = r.getCell(0); assertEquals("SUM(Sheet2!A1:Sheet3!A1)", c.getCellFormula()); - assertEquals(4.0, c.getNumericCellValue()); + assertEquals(4.0, c.getNumericCellValue(), 0); // Check the evaluated result HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb); eval.evaluateFormulaCell(c); - assertEquals(4.0, c.getNumericCellValue()); + assertEquals(4.0, c.getNumericCellValue(), 0); } /** * Normally encrypted files have BOF then FILEPASS, but * some may squeeze a WRITEPROTECT in the middle */ - public void test51832() { + @Test + public void bug51832() { try { openSample("51832.xls"); fail("Encrypted file"); @@ -2218,7 +2354,8 @@ if(1==2) { } } - public void test49896() { + @Test + public void bug49896() { HSSFWorkbook wb = openSample("49896.xls"); HSSFCell cell = wb.getSheetAt(0).getRow(1).getCell(1); String PATH_SEPARATOR = System.getProperty("file.separator"); @@ -2227,7 +2364,8 @@ if(1==2) { cell.getCellFormula()); } - public void test49529() throws Exception { + @Test + public void bug49529() throws Exception { // user code reported in Bugzilla #49529 HSSFWorkbook workbook = openSample("49529.xls"); workbook.getSheetAt(0).createDrawingPatriarch(); @@ -2239,7 +2377,8 @@ if(1==2) { writeOutAndReadBack(workbook); } - public void test51675(){ + @Test + public void bug51675(){ final List list = new ArrayList(); HSSFWorkbook workbook = openSample("51675.xls"); HSSFSheet sh = workbook.getSheetAt(0); @@ -2254,7 +2393,8 @@ if(1==2) { assertTrue(list.get(list.size()-2).intValue() == UnknownRecord.HEADER_FOOTER_089C); } - public void test52272(){ + @Test + public void bug52272(){ HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sh = wb.createSheet(); HSSFPatriarch p = sh.createDrawingPatriarch(); @@ -2266,7 +2406,8 @@ if(1==2) { assertNotNull(sh2.getDrawingPatriarch()); } - public void test53432(){ + @Test + public void bug53432(){ Workbook wb = new HSSFWorkbook(); //or new HSSFWorkbook(); wb.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG); assertEquals(wb.getAllPictures().size(), 1); @@ -2281,7 +2422,8 @@ if(1==2) { assertEquals(wb.getAllPictures().size(), 1); } - public void test46250(){ + @Test + public void bug46250(){ Workbook wb = openSample("46250.xls"); Sheet sh = wb.getSheet("Template"); Sheet cSh = wb.cloneSheet(wb.getSheetIndex(sh)); @@ -2295,7 +2437,8 @@ if(1==2) { wb = writeOutAndReadBack((HSSFWorkbook) wb); } - public void test53404(){ + @Test + public void bug53404(){ Workbook wb = openSample("53404.xls"); Sheet sheet = wb.getSheet("test-sheet"); int rowCount = sheet.getLastRowNum() + 1; @@ -2314,18 +2457,27 @@ if(1==2) { wb = writeOutAndReadBack((HSSFWorkbook) wb); } - public void test54016() { + @Test + public void bug54016() { // This used to break HSSFWorkbook wb = openSample("54016.xls"); wb = HSSFTestDataSamples.writeOutAndReadBack(wb); } /** Row style information is 12 not 16 bits */ - public void testFile() { - HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49237.xls"); + @Test + public void bug49237() { + HSSFWorkbook wb = openSample("49237.xls"); HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row = sheet.getRow(0); HSSFCellStyle rstyle = row.getRowStyle(); assertEquals(rstyle.getBorderBottom(), HSSFCellStyle.BORDER_DOUBLE); } + + @Test(expected=EncryptedDocumentException.class) + public void bug35897() throws Exception { + // password is abc + openSample("xor-encryption-abc.xls"); + } + } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index bf29c73210..bc489595de 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -17,19 +17,22 @@ package org.apache.poi.ss.usermodel; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.apache.poi.hssf.util.PaneInformation; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.util.CellRangeAddress; +import org.junit.Test; /** * A base class for bugzilla issues that can be described in terms of common ss interfaces. * * @author Yegor Kozlov */ -public abstract class BaseTestBugzillaIssues extends TestCase { +public abstract class BaseTestBugzillaIssues { private final ITestDataProvider _testDataProvider; @@ -43,7 +46,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { * * Also tests bug 15353 (problems with hyperlinks to Google) */ - public final void test23094() { + @Test + public final void bug23094() { Workbook wb = _testDataProvider.createWorkbook(); Sheet s = wb.createSheet(); Row r = s.createRow(0); @@ -64,7 +68,7 @@ public abstract class BaseTestBugzillaIssues extends TestCase { * open resulting file in Excel to check results! * @param num the number of strings to generate */ - public void baseTest15375(int num) { + public final void bug15375(int num) { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet(); CreationHelper factory = wb.getCreationHelper(); @@ -104,7 +108,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { /** * Merged regions were being removed from the parent in cloned sheets */ - public final void test22720() { + @Test + public final void bug22720() { Workbook workBook = _testDataProvider.createWorkbook(); workBook.createSheet("TEST"); Sheet template = workBook.getSheetAt(0); @@ -131,7 +136,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { } - public final void test28031() { + @Test + public final void bug28031() { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet(); wb.setSheetName(0, "Sheet1"); @@ -153,7 +159,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { * that contains macros and this formula: * {=SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""))>0,1))} */ - public final void test21334() { + @Test + public final void bug21334() { Workbook wb = _testDataProvider.createWorkbook(); Sheet sh = wb.createSheet(); Cell cell = sh.createRow(0).createCell(0); @@ -167,7 +174,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { /** another test for the number of unique strings issue *test opening the resulting file in Excel*/ - public final void test22568() { + @Test + public final void bug22568() { int r=2000;int c=3; Workbook wb = _testDataProvider.createWorkbook(); @@ -216,14 +224,16 @@ public abstract class BaseTestBugzillaIssues extends TestCase { /** * Bug 42448: Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69 */ - public final void test42448(){ + @Test + public final void bug42448(){ Workbook wb = _testDataProvider.createWorkbook(); Cell cell = wb.createSheet().createRow(0).createCell(0); cell.setCellFormula("SUMPRODUCT(A!C7:A!C67, B8:B68) / B69"); assertTrue("no errors parsing formula", true); } - public final void test18800() { + @Test + public final void bug18800() { Workbook book = _testDataProvider.createWorkbook(); book.createSheet("TEST"); Sheet sheet = book.cloneSheet(0); @@ -251,7 +261,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { } } - public final void testBug43093() { + @Test + public final void bug43093() { Workbook xlw = _testDataProvider.createWorkbook(); addNewSheetWithCellsA1toD4(xlw, 1); @@ -270,7 +281,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { assertEquals(d, (311+312+321+322), 0.0000001); } - public final void testMaxFunctionArguments_bug46729(){ + @Test + public final void bug46729_testMaxFunctionArguments(){ String[] func = {"COUNT", "AVERAGE", "MAX", "MIN", "OR", "SUBTOTAL", "SKEW"}; SpreadsheetVersion ssVersion = _testDataProvider.getSpreadsheetVersion(); @@ -308,7 +320,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { return fmla.toString(); } - public final void testAutoSize_bug506819() { + @Test + public final void bug506819_testAutoSize() { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet("Sheet1"); Row row = sheet.createRow(0); @@ -331,7 +344,8 @@ public abstract class BaseTestBugzillaIssues extends TestCase { /** * CreateFreezePane column/row order check */ - public void test49381() throws Exception { + @Test + public void bug49381() throws Exception { Workbook wb = _testDataProvider.createWorkbook(); int colSplit = 1; int rowSplit = 2; diff --git a/test-data/spreadsheet/xor-encryption-abc.xls b/test-data/spreadsheet/xor-encryption-abc.xls new file mode 100644 index 0000000000000000000000000000000000000000..193e47d90078fdda0aba60c8e0c57fbafccf3858 GIT binary patch literal 4096 zcmeHJeQZ-z6hG}&*1@`UAFQq>iX;zIqAyFBSzs9B7$h2FfVOvAVocD7q*aOJJzj0p zpsu!#k-%uxw;{@3K9u+o3$!{DBua3>y2K!Qi4japSTz1&+(?S9{_cCLzzBrtKVtft zbM8Ioo_D^_>mB>5{`B4t{AXy!a|>0_RI!@oT*P-^?<&z=qDt%qZ>m@<3bv5Nw)|X2 z8K`!nkaJw*Yx%P3i^JHWsIpbb`_}l6-%Cz9esYDwNnPd&YM^b#u(rnA^Y!l8udt^%W&%igk6iVA0$m7;#cvMMk7V~dPlk<%h`>Zg zm~ojW(U+P8T2eK1jPw{fLK|fpS98!|&~anni6fv#)zENUZm#b!BK@804CMEj2W5`) zR1S1rg1)fKb?EOG`h~u*+$K6q8AZl$-Wr!jVBdrH6Xv)Y0?k*}7@k!UOXSDZibvye z=dU%!Tfbn=@?0GnM&Ey&Ho9};?CrQ)Rq_Yr&Xqkzs*$ssTDcm^$1Hz-Ya9nXqQ?rUdeE4PZaF{s)BwKk8LhzHbyQ;dd*Abso4Um;Akt4AZrYED>)2XQ{{Y{b1!Sg( zc|XMl@J+d26LKYfl+DF|gZ-`XUij8j5Y2Nok*!nGCy>41xhV5z6w?DuF1-dg#Oi>% z%zEIo;f1xI{5RgwabnNl!{B7J+kv^d1X$8v04^{I6-D&=^Pu)mG~u62Rg&|uq>apr z;6+&dokbw_-0U$=QbYZ^Pb>qknKOEu;flh;_4q+GQ@2-(=pL z-O)#P+0nlITt?gNUPR+}UWmLDovks-daVqK^B}xPYvio8EPrJ2UEsT&Udyju#9+Op z8%*$ekp=)BrqyT0k8DHwUT*Gyoa_O@R4;W`GZH1E2*^ zx*uX&e*R+_SWBDmQ)vNp(UVv=)6=u^u$f$r(sft#(gL^WCZfX@rd9TGIo>Lo3=f0# z%@m>amLCzDISbrC&cE#oKd$xFz_k5qmA{JIKeB%neX~9KSN1QSe=(;e__I{h^7_Bd Fz+Z>xd{F=Z literal 0 HcmV?d00001