From feafcb8f48e24a6b1967e4cbf9e50d8f1b3224fd Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Sat, 26 Dec 2009 02:17:34 +0000 Subject: Replaced getInstance methods with field for instances of ITestDataProvider. Some simplification in hierarchy of related tests. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893929 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/HSSFITestDataProvider.java | 3 - .../poi/hssf/eventmodel/TestAbortableListener.java | 96 ++++++++++++---------- .../org/apache/poi/hssf/usermodel/TestBugs.java | 15 ++-- .../apache/poi/hssf/usermodel/TestHSSFCell.java | 25 +++--- .../apache/poi/hssf/usermodel/TestHSSFComment.java | 31 ++----- .../poi/hssf/usermodel/TestHSSFDataFormat.java | 15 +--- .../apache/poi/hssf/usermodel/TestHSSFFont.java | 5 +- .../poi/hssf/usermodel/TestHSSFHyperlink.java | 21 +++-- .../apache/poi/hssf/usermodel/TestHSSFName.java | 19 ++--- .../apache/poi/hssf/usermodel/TestHSSFPicture.java | 5 +- .../org/apache/poi/hssf/usermodel/TestHSSFRow.java | 7 +- .../apache/poi/hssf/usermodel/TestHSSFSheet.java | 31 +++---- .../TestHSSFSheetUpdateArrayFormulas.java | 2 +- .../poi/hssf/usermodel/TestHSSFWorkbook.java | 55 ++++++------- 14 files changed, 147 insertions(+), 183 deletions(-) (limited to 'src/testcases/org/apache/poi/hssf') diff --git a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java index b4d1b9d86e..668b73b9d6 100644 --- a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java +++ b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java @@ -32,9 +32,6 @@ public final class HSSFITestDataProvider implements ITestDataProvider { private HSSFITestDataProvider(){ // enforce singleton } - public static HSSFITestDataProvider getInstance(){ - return instance; - } public HSSFWorkbook openSampleWorkbook(String sampleFileName) { return HSSFTestDataSamples.openSampleWorkbook(sampleFileName); } diff --git a/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java b/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java index 1a1253e343..12097aa3c7 100644 --- a/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java +++ b/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java @@ -14,9 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ + package org.apache.poi.hssf.eventmodel; import java.io.ByteArrayInputStream; +import java.io.IOException; import junit.framework.TestCase; @@ -29,69 +31,77 @@ import org.apache.poi.hssf.record.EOFRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -public class TestAbortableListener extends TestCase { - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); - } - +/** + * Tests for {@link AbortableHSSFListener} + */ +public final class TestAbortableListener extends TestCase { + + private POIFSFileSystem openSample() { + ByteArrayInputStream is = new ByteArrayInputStream(HSSFITestDataProvider.instance + .getTestDataFileContent("SimpleWithColours.xls")); + try { + return new POIFSFileSystem(is); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + public void testAbortingBasics() throws Exception { AbortableCountingListener l = new AbortableCountingListener(1000); - + HSSFRequest req = new HSSFRequest(); req.addListenerForAllRecords(l); - + HSSFEventFactory f = new HSSFEventFactory(); - - assertEquals(0, l.seen); - assertEquals(null, l.lastseen); - - POIFSFileSystem fs = new POIFSFileSystem(new ByteArrayInputStream( - getTestDataProvider().getTestDataFileContent("SimpleWithColours.xls") - )); + + assertEquals(0, l.countSeen); + assertEquals(null, l.lastRecordSeen); + + POIFSFileSystem fs = openSample(); short res = f.abortableProcessWorkbookEvents(req, fs); - + assertEquals(0, res); - assertEquals(175, l.seen); - assertEquals(EOFRecord.sid, l.lastseen.getSid()); + assertEquals(175, l.countSeen); + assertEquals(EOFRecord.sid, l.lastRecordSeen.getSid()); } - + + public void testAbortStops() throws Exception { AbortableCountingListener l = new AbortableCountingListener(1); - + HSSFRequest req = new HSSFRequest(); req.addListenerForAllRecords(l); - + HSSFEventFactory f = new HSSFEventFactory(); - - assertEquals(0, l.seen); - assertEquals(null, l.lastseen); - - POIFSFileSystem fs = new POIFSFileSystem(new ByteArrayInputStream( - getTestDataProvider().getTestDataFileContent("SimpleWithColours.xls") - )); + + assertEquals(0, l.countSeen); + assertEquals(null, l.lastRecordSeen); + + POIFSFileSystem fs = openSample(); short res = f.abortableProcessWorkbookEvents(req, fs); - + assertEquals(1234, res); - assertEquals(1, l.seen); - assertEquals(BOFRecord.sid, l.lastseen.getSid()); + assertEquals(1, l.countSeen); + assertEquals(BOFRecord.sid, l.lastRecordSeen.getSid()); } - - public static class AbortableCountingListener extends AbortableHSSFListener { - private int abortAfter; - private int seen; - private Record lastseen; - + + private static final class AbortableCountingListener extends AbortableHSSFListener { + private int abortAfterIndex; + public int countSeen; + public Record lastRecordSeen; + public AbortableCountingListener(int abortAfter) { - this.abortAfter = abortAfter; - this.seen = 0; - this.lastseen = null; + abortAfterIndex = abortAfter; + countSeen = 0; + lastRecordSeen = null; } public short abortableProcessRecord(Record record) { - seen++; - lastseen = record; - - if(seen == abortAfter) + countSeen++; + lastRecordSeen = record; + + if(countSeen == abortAfterIndex) { return 1234; + } return 0; } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index c0f639d412..740cd8e599 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -53,17 +53,16 @@ import org.apache.poi.util.TempFile; */ public final class TestBugs extends BaseTestBugzillaIssues { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestBugs() { + super(HSSFITestDataProvider.instance); } - private HSSFWorkbook openSample(String sampleFileName) { - return getTestDataProvider().openSampleWorkbook(sampleFileName); + private static HSSFWorkbook openSample(String sampleFileName) { + return HSSFITestDataProvider.instance.openSampleWorkbook(sampleFileName); } - private HSSFWorkbook writeOutAndReadBack(HSSFWorkbook original) { - return getTestDataProvider().writeOutAndReadBack(original); + private static HSSFWorkbook writeOutAndReadBack(HSSFWorkbook original) { + return HSSFITestDataProvider.instance.writeOutAndReadBack(original); } private static void writeTestOutputFileForViewing(HSSFWorkbook wb, String simpleFileName) { @@ -1520,7 +1519,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { assertEquals("test ", cell1.getStringCellValue().toString()); HSSFCell cell2 = s.getRow(0).getCell(1); - assertEquals(1.0, cell2.getNumericCellValue()); + assertEquals(1.0, cell2.getNumericCellValue(), 0.0); } /** diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java index da22747fc3..77e95c622a 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java @@ -23,6 +23,7 @@ import java.util.GregorianCalendar; import junit.framework.AssertionFailedError; import org.apache.poi.hssf.HSSFITestDataProvider; +import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.model.InternalSheet; import org.apache.poi.hssf.record.DBCellRecord; import org.apache.poi.hssf.record.FormulaRecord; @@ -41,10 +42,8 @@ import org.apache.poi.ss.usermodel.ErrorConstants; */ public final class TestHSSFCell extends BaseTestCell { - private static final HSSFITestDataProvider _hssfDP = HSSFITestDataProvider.getInstance(); - public TestHSSFCell() { - super(HSSFITestDataProvider.getInstance()); + super(HSSFITestDataProvider.instance); } /** * Checks that the recognition of files using 1904 date windowing @@ -56,7 +55,7 @@ public final class TestHSSFCell extends BaseTestCell { Date date = cal.getTime(); // first check a file with 1900 Date Windowing - HSSFWorkbook workbook = _hssfDP.openSampleWorkbook("1900DateWindowing.xls"); + HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("1900DateWindowing.xls"); HSSFSheet sheet = workbook.getSheetAt(0); assertEquals("Date from file using 1900 Date Windowing", @@ -64,7 +63,7 @@ public final class TestHSSFCell extends BaseTestCell { sheet.getRow(0).getCell(0).getDateCellValue().getTime()); // now check a file with 1904 Date Windowing - workbook = _hssfDP.openSampleWorkbook("1904DateWindowing.xls"); + workbook = HSSFTestDataSamples.openSampleWorkbook("1904DateWindowing.xls"); sheet = workbook.getSheetAt(0); assertEquals("Date from file using 1904 Date Windowing", @@ -86,19 +85,19 @@ public final class TestHSSFCell extends BaseTestCell { // first check a file with 1900 Date Windowing HSSFWorkbook wb; - wb = _hssfDP.openSampleWorkbook("1900DateWindowing.xls"); + wb = HSSFTestDataSamples.openSampleWorkbook("1900DateWindowing.xls"); setCell(wb, 0, 1, date); - wb = _hssfDP.writeOutAndReadBack(wb); + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); assertEquals("Date from file using 1900 Date Windowing", date.getTime(), readCell(wb, 0, 1).getTime()); // now check a file with 1904 Date Windowing - wb = _hssfDP.openSampleWorkbook("1904DateWindowing.xls"); + wb = HSSFTestDataSamples.openSampleWorkbook("1904DateWindowing.xls"); setCell(wb, 0, 1, date); - wb = _hssfDP.writeOutAndReadBack(wb); + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); assertEquals("Date from file using 1900 Date Windowing", date.getTime(), readCell(wb, 0, 1).getTime()); @@ -127,7 +126,7 @@ public final class TestHSSFCell extends BaseTestCell { */ public void testActiveCell() { //read in sample - HSSFWorkbook book = _hssfDP.openSampleWorkbook("Simple.xls"); + HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("Simple.xls"); //check initial position HSSFSheet umSheet = book.getSheetAt(0); @@ -146,7 +145,7 @@ public final class TestHSSFCell extends BaseTestCell { 3, s.getActiveCellRow()); //write book to temp file; read and verify that position is serialized - book = _hssfDP.writeOutAndReadBack(book); + book = HSSFTestDataSamples.writeOutAndReadBack(book); umSheet = book.getSheetAt(0); s = umSheet.getSheet(); @@ -162,7 +161,7 @@ public final class TestHSSFCell extends BaseTestCell { */ public void testWithHyperlink() { - HSSFWorkbook wb = _hssfDP.openSampleWorkbook("WithHyperlink.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithHyperlink.xls"); HSSFSheet sheet = wb.getSheetAt(0); HSSFCell cell = sheet.getRow(4).getCell(0); @@ -180,7 +179,7 @@ public final class TestHSSFCell extends BaseTestCell { */ public void testWithTwoHyperlinks() { - HSSFWorkbook wb = _hssfDP.openSampleWorkbook("WithTwoHyperLinks.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithTwoHyperLinks.xls"); HSSFSheet sheet = wb.getSheetAt(0); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java index 0130f9471d..7d04110b12 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java @@ -16,10 +16,8 @@ ==================================================================== */ package org.apache.poi.hssf.usermodel; -import java.io.IOException; - -import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFITestDataProvider; +import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ss.usermodel.BaseTestCellComment; /** @@ -29,39 +27,20 @@ import org.apache.poi.ss.usermodel.BaseTestCellComment; */ public final class TestHSSFComment extends BaseTestCellComment { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFComment() { + super(HSSFITestDataProvider.instance); } - public static void testDefaultShapeType() throws Exception { + public void testDefaultShapeType() { HSSFComment comment = new HSSFComment((HSSFShape)null, (HSSFAnchor)null); assertEquals(HSSFSimpleShape.OBJECT_TYPE_COMMENT, comment.getShapeType()); } - /** - * test that we can read cell comments from an existing workbook. - */ - public void testReadComments() { - readComments("SimpleWithComments.xls"); - } - - /** - * test that we can modify existing cell comments - */ - public void testModifyComments() throws IOException { - modifyComments("SimpleWithComments.xls"); - } - - public void testDeleteComments() throws Exception { - deleteComments("SimpleWithComments.xls"); - } - /** * HSSFCell#findCellComment should NOT rely on the order of records * when matching cells and their cell comments. The correct algorithm is to map */ - public static void test47924() { + public void test47924() { HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("47924.xls"); HSSFSheet sheet = wb.getSheetAt(0); HSSFCell cell; diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java index 8bbbc06d50..c04f162205 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java @@ -18,23 +18,14 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.HSSFITestDataProvider; -import org.apache.poi.ss.usermodel.*; -import org.apache.poi.ss.ITestDataProvider; +import org.apache.poi.ss.usermodel.BaseTestDataFormat; /** * Tests for {@link HSSFDataFormat} - * */ public final class TestHSSFDataFormat extends BaseTestDataFormat { - @Override - protected ITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); - } - /** - * Test setting and getting boolean values. - */ - public void testBuiltinFormats() { - baseBuiltinFormats(); + public TestHSSFDataFormat() { + super(HSSFITestDataProvider.instance); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java index 8350654494..7f0aa7048a 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java @@ -28,9 +28,8 @@ import org.apache.poi.ss.usermodel.Font; */ public final class TestHSSFFont extends BaseTestFont { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFFont() { + super(HSSFITestDataProvider.instance); } public void testDefaultFont() { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java index f863dd980d..8a5d601369 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java @@ -28,16 +28,15 @@ import org.apache.poi.ss.usermodel.BaseTestHyperlink; */ public final class TestHSSFHyperlink extends BaseTestHyperlink { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFHyperlink() { + super(HSSFITestDataProvider.instance); } /** * Test that we can read hyperlinks. */ public void testRead() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("HyperlinksOnManySheets.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("HyperlinksOnManySheets.xls"); HSSFSheet sheet; HSSFCell cell; @@ -77,7 +76,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { } public void testModify() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("HyperlinksOnManySheets.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("HyperlinksOnManySheets.xls"); HSSFSheet sheet; HSSFCell cell; @@ -89,7 +88,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { //modify the link link.setAddress("www.apache.org"); - wb = getTestDataProvider().writeOutAndReadBack(wb); + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); sheet = wb.getSheet("WebLinks"); cell = sheet.getRow(4).getCell(0); link = cell.getHyperlink(); @@ -106,7 +105,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { * link.setAddress("'Target Sheet-1'!A1"); //common between XSSF and HSSF */ public void testCreateDocumentLink() { - HSSFWorkbook wb = getTestDataProvider().createWorkbook(); + HSSFWorkbook wb = new HSSFWorkbook(); //link to a place in this workbook HSSFHyperlink link; @@ -131,7 +130,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { link.setAddress("'Hyperlinks'!A1"); cell.setHyperlink(link); - wb = getTestDataProvider().writeOutAndReadBack(wb); + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); sheet = wb.getSheet("Hyperlinks"); cell = sheet.getRow(0).getCell(0); @@ -167,7 +166,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { } public void testCreate() { - HSSFWorkbook wb = getTestDataProvider().createWorkbook(); + HSSFWorkbook wb = new HSSFWorkbook(); HSSFHyperlink link; HSSFCell cell; @@ -179,7 +178,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { link.setAddress("testfolder\\test.PDF"); cell.setHyperlink(link); - wb = getTestDataProvider().writeOutAndReadBack(wb); + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); sheet = wb.getSheet("Hyperlinks"); cell = sheet.getRow(1).getCell(0); @@ -193,7 +192,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { * see bugs #46445 and #29957 */ public void testShiftRows(){ - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("46445.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("46445.xls"); HSSFSheet sheet = wb.getSheetAt(0); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java index 88a2c0cf16..6d45cde4f0 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java @@ -45,7 +45,7 @@ public final class TestHSSFName extends BaseTestNamedRange { * For manipulating the internals of {@link HSSFName} during testing.
* Some tests need a {@link NameRecord} with unusual state, not normally producible by POI. * This method achieves the aims at low cost without augmenting the POI usermodel api. - * @return a reference to the wrapped {@link NameRecord} + * @return a reference to the wrapped {@link NameRecord} */ public static NameRecord getNameRecord(HSSFName definedName) { @@ -63,11 +63,10 @@ public final class TestHSSFName extends BaseTestNamedRange { } catch (IllegalAccessException e) { throw new RuntimeException(e); } - } + } - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFName() { + super(HSSFITestDataProvider.instance); } public void testRepeatingRowsAndColumsNames() { @@ -128,7 +127,7 @@ public final class TestHSSFName extends BaseTestNamedRange { } public void testNamedRange() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("Simple.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("Simple.xls"); //Creating new Named Range HSSFName newNamedRange = wb.createName(); @@ -162,7 +161,7 @@ public final class TestHSSFName extends BaseTestNamedRange { * Addresses Bug #9632 */ public void testNamedRead() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("namedinput.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("namedinput.xls"); //Get index of the named range with the name = "NamedRangeName" , which was defined in input.xls as A1:D10 int NamedRangeIndex = wb.getNameIndex("NamedRangeName"); @@ -188,7 +187,7 @@ public final class TestHSSFName extends BaseTestNamedRange { * Addresses Bug #16411 */ public void testNamedReadModify() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("namedinput.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("namedinput.xls"); HSSFName name = wb.getNameAt(0); String sheetName = wb.getSheetName(0); @@ -206,7 +205,7 @@ public final class TestHSSFName extends BaseTestNamedRange { * Test to see if the print area can be retrieved from an excel created file */ public void testPrintAreaFileRead() { - HSSFWorkbook workbook = getTestDataProvider().openSampleWorkbook("SimpleWithPrintArea.xls"); + HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPrintArea.xls"); String sheetName = workbook.getSheetName(0); String reference = sheetName+"!$A$1:$C$5"; @@ -252,4 +251,4 @@ public final class TestHSSFName extends BaseTestNamedRange { } } -} \ No newline at end of file +} diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java index 8f39857694..9e51917a5f 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java @@ -28,9 +28,8 @@ import org.apache.poi.ss.usermodel.BaseTestPicture; */ public final class TestHSSFPicture extends BaseTestPicture { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFPicture() { + super(HSSFITestDataProvider.instance); } public void testResize() { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java index 31173bba2a..55ee037042 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java @@ -32,9 +32,8 @@ import org.apache.poi.ss.SpreadsheetVersion; */ public final class TestHSSFRow extends BaseTestRow { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFRow() { + super(HSSFITestDataProvider.instance); } public void testRowBounds() { @@ -56,7 +55,7 @@ public final class TestHSSFRow extends BaseTestRow { BlankRecord br = new BlankRecord(); br.setRow(ROW_IX); - br.setColumn((short)COL_IX); + br.setColumn((short)COL_IX); sheet.getSheet().addValueRecord(ROW_IX, br); HSSFRow row = new HSSFRow(workbook, sheet, rowRec); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 1dc6e1ac18..09fdc73b8e 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -20,7 +20,6 @@ package org.apache.poi.hssf.usermodel; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.util.Arrays; import junit.framework.AssertionFailedError; @@ -43,9 +42,6 @@ import org.apache.poi.hssf.record.WindowTwoRecord; import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock; import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector; import org.apache.poi.ss.usermodel.BaseTestSheet; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.util.TempFile; @@ -59,9 +55,8 @@ import org.apache.poi.util.TempFile; */ public final class TestHSSFSheet extends BaseTestSheet { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFSheet() { + super(HSSFITestDataProvider.instance); } public void testTestGetSetMargin() { @@ -161,7 +156,7 @@ public final class TestHSSFSheet extends BaseTestSheet { * Setting landscape and portrait stuff on existing sheets */ public void testPrintSetupLandscapeExisting() { - HSSFWorkbook workbook = getTestDataProvider().openSampleWorkbook("SimpleWithPageBreaks.xls"); + HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls"); assertEquals(3, workbook.getNumberOfSheets()); @@ -242,7 +237,7 @@ public final class TestHSSFSheet extends BaseTestSheet { } public void testGroupRowsExisting() { - HSSFWorkbook workbook = getTestDataProvider().openSampleWorkbook("NoGutsRecords.xls"); + HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("NoGutsRecords.xls"); HSSFSheet s = workbook.getSheetAt(0); HSSFRow r1 = s.getRow(0); @@ -293,8 +288,8 @@ public final class TestHSSFSheet extends BaseTestSheet { } public void testGetDrawings() { - HSSFWorkbook wb1c = getTestDataProvider().openSampleWorkbook("WithChart.xls"); - HSSFWorkbook wb2c = getTestDataProvider().openSampleWorkbook("WithTwoCharts.xls"); + HSSFWorkbook wb1c = HSSFTestDataSamples.openSampleWorkbook("WithChart.xls"); + HSSFWorkbook wb2c = HSSFTestDataSamples.openSampleWorkbook("WithTwoCharts.xls"); // 1 chart sheet -> data on 1st, chart on 2nd assertNotNull(wb1c.getSheetAt(0).getDrawingPatriarch()); @@ -438,7 +433,7 @@ public final class TestHSSFSheet extends BaseTestSheet { * */ public void testPageBreakFiles() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("SimpleWithPageBreaks.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls"); HSSFSheet sheet = wb.getSheetAt(0); assertNotNull(sheet); @@ -466,7 +461,7 @@ public final class TestHSSFSheet extends BaseTestSheet { } public void testDBCSName () { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("DBCSSheetName.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DBCSSheetName.xls"); wb.getSheetAt(1); assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" ); assertEquals("DBCS Sheet Name 1", wb.getSheetName(0),"\u091c\u093e"); @@ -478,7 +473,7 @@ public final class TestHSSFSheet extends BaseTestSheet { * of the sheet when it is first opened. */ public void testTopRow() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("SimpleWithPageBreaks.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls"); HSSFSheet sheet = wb.getSheetAt(0); assertNotNull(sheet); @@ -519,7 +514,7 @@ public final class TestHSSFSheet extends BaseTestSheet { workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook); //try adding empty rows in an existing worksheet - workbook = getTestDataProvider().openSampleWorkbook("Simple.xls"); + workbook = HSSFTestDataSamples.openSampleWorkbook("Simple.xls"); sheet = workbook.getSheetAt(0); for (int i = 3; i < 10; i++) sheet.createRow(i); @@ -528,7 +523,7 @@ public final class TestHSSFSheet extends BaseTestSheet { } public void testAutoSizeColumn() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("43902.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("43902.xls"); String sheetName = "my sheet"; HSSFSheet sheet = wb.getSheet(sheetName); @@ -572,7 +567,7 @@ public final class TestHSSFSheet extends BaseTestSheet { * Setting ForceFormulaRecalculation on sheets */ public void testForceRecalculation() throws Exception { - HSSFWorkbook workbook = getTestDataProvider().openSampleWorkbook("UncalcedRecord.xls"); + HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("UncalcedRecord.xls"); HSSFSheet sheet = workbook.getSheetAt(0); HSSFSheet sheet2 = workbook.getSheetAt(0); @@ -640,7 +635,7 @@ public final class TestHSSFSheet extends BaseTestSheet { public void testColumnWidth() { //check we can correctly read column widths from a reference workbook - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("colwidth.xls"); + HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("colwidth.xls"); //reference values int[] ref = {365, 548, 731, 914, 1097, 1280, 1462, 1645, 1828, 2011, 2194, 2377, 2560, 2742, 2925, 3108, 3291, 3474, 3657}; diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java index 625ffdb694..eff7157eb6 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java @@ -40,7 +40,7 @@ import org.apache.poi.ss.util.CellRangeAddress; public final class TestHSSFSheetUpdateArrayFormulas extends BaseTestSheetUpdateArrayFormulas { public TestHSSFSheetUpdateArrayFormulas() { - super(HSSFITestDataProvider.getInstance()); + super(HSSFITestDataProvider.instance); } // Test methods common with XSSF are in superclass diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index 43fc595ff2..6493eef47f 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -44,16 +44,15 @@ import org.apache.poi.hpsf.ClassID; * Tests for {@link HSSFWorkbook} */ public final class TestHSSFWorkbook extends BaseTestWorkbook { - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); + public TestHSSFWorkbook() { + super(HSSFITestDataProvider.instance); } /** * gives test code access to the {@link InternalWorkbook} within {@link HSSFWorkbook} */ public static InternalWorkbook getInternalWorkbook(HSSFWorkbook wb) { - return wb.getWorkbook(); + return wb.getWorkbook(); } public void testSetRepeatingRowsAndColumns() { @@ -81,28 +80,28 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { * Tests for {@link HSSFWorkbook#isHidden()} etc */ public void testHidden() { - HSSFWorkbook wb = new HSSFWorkbook(); + HSSFWorkbook wb = new HSSFWorkbook(); - WindowOneRecord w1 = wb.getWorkbook().getWindowOne(); + WindowOneRecord w1 = wb.getWorkbook().getWindowOne(); - assertEquals(false, wb.isHidden()); - assertEquals(false, w1.getHidden()); + assertEquals(false, wb.isHidden()); + assertEquals(false, w1.getHidden()); - wb.setHidden(true); - assertEquals(true, wb.isHidden()); - assertEquals(true, w1.getHidden()); + wb.setHidden(true); + assertEquals(true, wb.isHidden()); + assertEquals(true, w1.getHidden()); - wb = HSSFTestDataSamples.writeOutAndReadBack(wb); - w1 = wb.getWorkbook().getWindowOne(); + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); + w1 = wb.getWorkbook().getWindowOne(); - wb.setHidden(true); - assertEquals(true, wb.isHidden()); - assertEquals(true, w1.getHidden()); + wb.setHidden(true); + assertEquals(true, wb.isHidden()); + assertEquals(true, w1.getHidden()); - wb.setHidden(false); - assertEquals(false, wb.isHidden()); - assertEquals(false, w1.getHidden()); - } + wb.setHidden(false); + assertEquals(false, wb.isHidden()); + assertEquals(false, w1.getHidden()); + } public void testSheetClone() { // First up, try a simple file @@ -116,7 +115,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { assertEquals(3, b.getNumberOfSheets()); // Now try a problem one with drawing records in it - b = getTestDataProvider().openSampleWorkbook("SheetWithDrawing.xls"); + b = HSSFTestDataSamples.openSampleWorkbook("SheetWithDrawing.xls"); assertEquals(1, b.getNumberOfSheets()); b.cloneSheet(0); assertEquals(2, b.getNumberOfSheets()); @@ -127,7 +126,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { HSSFSheet s; // Single chart, two sheets - b = getTestDataProvider().openSampleWorkbook("44010-SingleChart.xls"); + b = HSSFTestDataSamples.openSampleWorkbook("44010-SingleChart.xls"); assertEquals(2, b.getNumberOfSheets()); assertEquals("Graph2", b.getSheetName(1)); s = b.getSheetAt(1); @@ -143,9 +142,9 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { // We've now called getDrawingPatriarch() so // everything will be all screwy // So, start again - b = getTestDataProvider().openSampleWorkbook("44010-SingleChart.xls"); + b = HSSFTestDataSamples.openSampleWorkbook("44010-SingleChart.xls"); - b = getTestDataProvider().writeOutAndReadBack(b); + b = HSSFTestDataSamples.writeOutAndReadBack(b); assertEquals(2, b.getNumberOfSheets()); s = b.getSheetAt(1); assertEquals(0, s.getFirstRowNum()); @@ -153,7 +152,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { // Two charts, three sheets - b = getTestDataProvider().openSampleWorkbook("44010-TwoCharts.xls"); + b = HSSFTestDataSamples.openSampleWorkbook("44010-TwoCharts.xls"); assertEquals(3, b.getNumberOfSheets()); s = b.getSheetAt(1); @@ -173,9 +172,9 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { // We've now called getDrawingPatriarch() so // everything will be all screwy // So, start again - b = getTestDataProvider().openSampleWorkbook("44010-TwoCharts.xls"); + b = HSSFTestDataSamples.openSampleWorkbook("44010-TwoCharts.xls"); - b = getTestDataProvider().writeOutAndReadBack(b); + b = HSSFTestDataSamples.writeOutAndReadBack(b); assertEquals(3, b.getNumberOfSheets()); s = b.getSheetAt(1); @@ -375,7 +374,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { * that point to deleted sheets */ public void testNamesToDeleteSheets() { - HSSFWorkbook b = getTestDataProvider().openSampleWorkbook("30978-deleted.xls"); + HSSFWorkbook b = HSSFTestDataSamples.openSampleWorkbook("30978-deleted.xls"); assertEquals(3, b.getNumberOfNames()); // Sheet 2 is deleted -- cgit v1.2.3