diff options
author | Josh Micich <josh@apache.org> | 2009-04-11 17:53:39 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2009-04-11 17:53:39 +0000 |
commit | 3514cbb38c2ac8e5a74fc7f312f955cb155c834e (patch) | |
tree | 366e6790a0a7056d57fc772a13c9a1739e6cee0d /src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java | |
parent | 6299c25b80aa5b704c60c07a229dbb90ac8cc10d (diff) | |
download | poi-3514cbb38c2ac8e5a74fc7f312f955cb155c834e.tar.gz poi-3514cbb38c2ac8e5a74fc7f312f955cb155c834e.zip |
Improvements to Test[HX]SSFCell. Small fix to XSSFCell to get one more common test working.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@764225 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java | 76 |
1 files changed, 20 insertions, 56 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java index 2e95772216..fdad33fec2 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java @@ -21,14 +21,15 @@ import java.util.Date; import java.util.GregorianCalendar; import junit.framework.AssertionFailedError; + import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.record.DBCellRecord; import org.apache.poi.hssf.record.FormulaRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.StringRecord; -import org.apache.poi.ss.usermodel.ErrorConstants; import org.apache.poi.ss.usermodel.BaseTestCell; +import org.apache.poi.ss.usermodel.ErrorConstants; /** * Tests various functionality having to do with {@link HSSFCell}. For instance support for @@ -38,12 +39,12 @@ import org.apache.poi.ss.usermodel.BaseTestCell; * @author Alex Jacoby (ajacoby at gmail.com) */ public final class TestHSSFCell extends BaseTestCell { - - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); - } - + + private static final HSSFITestDataProvider _hssfDP = HSSFITestDataProvider.getInstance(); + + public TestHSSFCell() { + super(HSSFITestDataProvider.getInstance()); + } /** * Checks that the recognition of files using 1904 date windowing * is working properly. Conversion of the date is also an issue, @@ -54,7 +55,7 @@ public final class TestHSSFCell extends BaseTestCell { Date date = cal.getTime(); // first check a file with 1900 Date Windowing - HSSFWorkbook workbook = getTestDataProvider().openSampleWorkbook("1900DateWindowing.xls"); + HSSFWorkbook workbook = _hssfDP.openSampleWorkbook("1900DateWindowing.xls"); HSSFSheet sheet = workbook.getSheetAt(0); assertEquals("Date from file using 1900 Date Windowing", @@ -62,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 = getTestDataProvider().openSampleWorkbook("1904DateWindowing.xls"); + workbook = _hssfDP.openSampleWorkbook("1904DateWindowing.xls"); sheet = workbook.getSheetAt(0); assertEquals("Date from file using 1904 Date Windowing", @@ -70,6 +71,8 @@ public final class TestHSSFCell extends BaseTestCell { sheet.getRow(0).getCell(0).getDateCellValue().getTime()); } + + /** * Checks that dates are properly written to both types of files: * those with 1900 and 1904 date windowing. Note that if the @@ -82,19 +85,19 @@ public final class TestHSSFCell extends BaseTestCell { // first check a file with 1900 Date Windowing HSSFWorkbook wb; - wb = getTestDataProvider().openSampleWorkbook("1900DateWindowing.xls"); + wb = _hssfDP.openSampleWorkbook("1900DateWindowing.xls"); setCell(wb, 0, 1, date); - wb = getTestDataProvider().writeOutAndReadBack(wb); + wb = _hssfDP.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 = getTestDataProvider().openSampleWorkbook("1904DateWindowing.xls"); + wb = _hssfDP.openSampleWorkbook("1904DateWindowing.xls"); setCell(wb, 0, 1, date); - wb = getTestDataProvider().writeOutAndReadBack(wb); + wb = _hssfDP.writeOutAndReadBack(wb); assertEquals("Date from file using 1900 Date Windowing", date.getTime(), readCell(wb, 0, 1).getTime()); @@ -123,7 +126,7 @@ public final class TestHSSFCell extends BaseTestCell { */ public void testActiveCell() { //read in sample - HSSFWorkbook book = getTestDataProvider().openSampleWorkbook("Simple.xls"); + HSSFWorkbook book = _hssfDP.openSampleWorkbook("Simple.xls"); //check initial position HSSFSheet umSheet = book.getSheetAt(0); @@ -142,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 = getTestDataProvider().writeOutAndReadBack(book); + book = _hssfDP.writeOutAndReadBack(book); umSheet = book.getSheetAt(0); s = umSheet.getSheet(); @@ -158,7 +161,7 @@ public final class TestHSSFCell extends BaseTestCell { */ public void testWithHyperlink() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("WithHyperlink.xls"); + HSSFWorkbook wb = _hssfDP.openSampleWorkbook("WithHyperlink.xls"); HSSFSheet sheet = wb.getSheetAt(0); HSSFCell cell = sheet.getRow(4).getCell(0); @@ -176,7 +179,7 @@ public final class TestHSSFCell extends BaseTestCell { */ public void testWithTwoHyperlinks() { - HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("WithTwoHyperLinks.xls"); + HSSFWorkbook wb = _hssfDP.openSampleWorkbook("WithTwoHyperLinks.xls"); HSSFSheet sheet = wb.getSheetAt(0); @@ -196,17 +199,6 @@ public final class TestHSSFCell extends BaseTestCell { assertEquals(8, link2.getFirstRow()); assertEquals(1, link2.getFirstColumn()); } - - public void testSetStringInFormulaCell_bug44606() { - HSSFWorkbook wb = getTestDataProvider().createWorkbook(); - HSSFCell cell = wb.createSheet("Sheet1").createRow(0).createCell(0); - cell.setCellFormula("B1&C1"); - try { - cell.setCellValue(new HSSFRichTextString("hello")); - } catch (ClassCastException e) { - throw new AssertionFailedError("Identified bug 44606"); - } - } /** * Test to ensure we can only assign cell styles that belong @@ -253,34 +245,6 @@ public final class TestHSSFCell extends BaseTestCell { } } - public void testChangeTypeStringToBool() { - HSSFCell cell = new HSSFWorkbook().createSheet("Sheet1").createRow(0).createCell(0); - baseTestChangeTypeStringToBool(cell); - } - - public void testChangeTypeBoolToString() { - HSSFCell cell = new HSSFWorkbook().createSheet("Sheet1").createRow(0).createCell(0); - baseTestChangeTypeBoolToString(cell); - } - - public void testChangeTypeErrorToNumber_bug46479() { - HSSFCell cell = new HSSFWorkbook().createSheet("Sheet1").createRow(0).createCell(0); - baseTestChangeTypeErrorToNumber(cell); - } - - public void testChangeTypeErrorToBoolean_bug46479() { - HSSFCell cell = new HSSFWorkbook().createSheet("Sheet1").createRow(0).createCell(0); - baseTestChangeTypeErrorToBoolean(cell); - } - - /** - * Test for bug in convertCellValueToBoolean to make sure that formula results get converted - */ - public void testChangeTypeFormulaToBoolean_bug46479() { - HSSFCell cell = new HSSFWorkbook().createSheet("Sheet1").createRow(0).createCell(0); - baseTestChangeTypeFormulaToBoolean(cell); - } - /** * Test for small bug observable around r736460 (prior to version 3.5). POI fails to remove * the {@link StringRecord} following the {@link FormulaRecord} after the result type had been |