diff options
author | Josh Micich <josh@apache.org> | 2009-12-09 00:12:32 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2009-12-09 00:12:32 +0000 |
commit | 47e084cfcd203026b6b72160f73306c314b21b60 (patch) | |
tree | e4b847549831d6dc6d03066c11fd9ea4698f749a /src/testcases/org/apache/poi/hssf | |
parent | 78df947523f5cc72fc88cf12e22ed2ffb3abdf8a (diff) | |
download | poi-47e084cfcd203026b6b72160f73306c314b21b60.tar.gz poi-47e084cfcd203026b6b72160f73306c314b21b60.zip |
Removed unused imports under src/java and src/testcases. Other minor fixes.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@888653 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf')
4 files changed, 58 insertions, 65 deletions
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java index 0e9634e626..e0d6bfc994 100644 --- a/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java +++ b/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java @@ -17,18 +17,17 @@ package org.apache.poi.hssf.extractor; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import junit.framework.TestCase; +import org.apache.poi.POIDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.apache.poi.POIDataSamples; /** * @@ -243,10 +242,10 @@ public final class TestExcelExtractor extends TestCase { * Excel embeded in excel */ public void testWithEmbededInOwn() throws Exception { - POIDataSamples ssSamples = POIDataSamples.getSpreadSheetInstance(); + POIDataSamples ssSamples = POIDataSamples.getSpreadSheetInstance(); POIFSFileSystem fs = new POIFSFileSystem( - ssSamples.openResourceAsStream("excel_with_embeded.xls") - ); + ssSamples.openResourceAsStream("excel_with_embeded.xls") + ); DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B5"); DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B4"); diff --git a/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java index e0b4eb133d..1e29295a59 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java @@ -18,19 +18,17 @@ package org.apache.poi.hssf.record; -import junit.framework.TestCase; - -import java.util.Arrays; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.util.Arrays; + +import junit.framework.TestCase; +import org.apache.poi.hssf.record.formula.AreaPtg; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.HexRead; -import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianInputStream; import org.apache.poi.util.LittleEndianOutputStream; -import org.apache.poi.hssf.record.formula.Ptg; -import org.apache.poi.hssf.record.formula.AreaPtg; -import org.apache.poi.ss.util.CellRangeAddress; /** * Tests the serialization and deserialization of the LbsDataSubRecord class works correctly. @@ -167,4 +165,4 @@ public final class TestLbsDataSubRecord extends TestCase { assertTrue(Arrays.equals(data, baos.toByteArray())); } -}
\ No newline at end of file +} diff --git a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestOffset.java b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestOffset.java index 49cc6d597d..7002408f2e 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestOffset.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestOffset.java @@ -22,7 +22,6 @@ import junit.framework.TestCase; import org.apache.poi.hssf.record.formula.eval.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; -import org.apache.poi.hssf.record.formula.eval.ValueEval; import org.apache.poi.hssf.record.formula.functions.Offset.LinearOffsetRange; /** diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java index 540e71038d..cf800cb41c 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java @@ -19,7 +19,6 @@ package org.apache.poi.hssf.usermodel; import java.util.Date; import java.util.GregorianCalendar; -import java.io.FileOutputStream; import junit.framework.AssertionFailedError; @@ -29,10 +28,9 @@ 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.SpreadsheetVersion; import org.apache.poi.ss.usermodel.BaseTestCell; import org.apache.poi.ss.usermodel.ErrorConstants; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.SpreadsheetVersion; /** * Tests various functionality having to do with {@link HSSFCell}. For instance support for @@ -42,9 +40,9 @@ import org.apache.poi.ss.SpreadsheetVersion; * @author Alex Jacoby (ajacoby at gmail.com) */ public final class TestHSSFCell extends BaseTestCell { - + private static final HSSFITestDataProvider _hssfDP = HSSFITestDataProvider.getInstance(); - + public TestHSSFCell() { super(HSSFITestDataProvider.getInstance()); } @@ -64,7 +62,7 @@ public final class TestHSSFCell extends BaseTestCell { assertEquals("Date from file using 1900 Date Windowing", date.getTime(), sheet.getRow(0).getCell(0).getDateCellValue().getTime()); - + // now check a file with 1904 Date Windowing workbook = _hssfDP.openSampleWorkbook("1904DateWindowing.xls"); sheet = workbook.getSheetAt(0); @@ -89,17 +87,17 @@ public final class TestHSSFCell extends BaseTestCell { // first check a file with 1900 Date Windowing HSSFWorkbook wb; wb = _hssfDP.openSampleWorkbook("1900DateWindowing.xls"); - + setCell(wb, 0, 1, date); 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 = _hssfDP.openSampleWorkbook("1904DateWindowing.xls"); - setCell(wb, 0, 1, date); + setCell(wb, 0, 1, date); wb = _hssfDP.writeOutAndReadBack(wb); assertEquals("Date from file using 1900 Date Windowing", date.getTime(), @@ -110,27 +108,27 @@ public final class TestHSSFCell extends BaseTestCell { HSSFSheet sheet = workbook.getSheetAt(0); HSSFRow row = sheet.getRow(rowIdx); HSSFCell cell = row.getCell(colIdx); - + if (cell == null) { cell = row.createCell(colIdx); } cell.setCellValue(date); } - + private static Date readCell(HSSFWorkbook workbook, int rowIdx, int colIdx) { HSSFSheet sheet = workbook.getSheetAt(0); HSSFRow row = sheet.getRow(rowIdx); HSSFCell cell = row.getCell(colIdx); return cell.getDateCellValue(); } - + /** * Tests that the active cell can be correctly read and set */ public void testActiveCell() { //read in sample HSSFWorkbook book = _hssfDP.openSampleWorkbook("Simple.xls"); - + //check initial position HSSFSheet umSheet = book.getSheetAt(0); Sheet s = umSheet.getSheet(); @@ -138,7 +136,7 @@ public final class TestHSSFCell extends BaseTestCell { (short) 0, s.getActiveCellCol()); assertEquals("Initial active cell should be on row 1", 1, s.getActiveCellRow()); - + //modify position through HSSFCell HSSFCell cell = umSheet.createRow(3).createCell(2); cell.setAsActiveCell(); @@ -146,13 +144,13 @@ public final class TestHSSFCell extends BaseTestCell { (short) 2, s.getActiveCellCol()); assertEquals("After modify, active cell should be on row 3", 3, s.getActiveCellRow()); - + //write book to temp file; read and verify that position is serialized book = _hssfDP.writeOutAndReadBack(book); umSheet = book.getSheetAt(0); s = umSheet.getSheet(); - + assertEquals("After serialize, active cell should be in col 2", (short) 2, s.getActiveCellCol()); assertEquals("After serialize, active cell should be on row 3", @@ -176,14 +174,14 @@ public final class TestHSSFCell extends BaseTestCell { assertEquals(4, link.getFirstRow()); assertEquals(0, link.getFirstColumn()); } - + /** * Test reading hyperlinks */ public void testWithTwoHyperlinks() { HSSFWorkbook wb = _hssfDP.openSampleWorkbook("WithTwoHyperLinks.xls"); - + HSSFSheet sheet = wb.getSheetAt(0); HSSFCell cell1 = sheet.getRow(4).getCell(0); @@ -250,7 +248,7 @@ public final class TestHSSFCell extends BaseTestCell { /** * 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 + * the {@link StringRecord} following the {@link FormulaRecord} after the result type had been * changed to number/boolean/error. Excel silently ignores the extra record, but some POI * versions (prior to bug 46213 / r717883) crash instead. */ @@ -266,13 +264,13 @@ public final class TestHSSFCell extends BaseTestCell { throw new AssertionFailedError("Identified bug - leftover StringRecord"); } confirmStringRecord(sheet, false); - + // string to error code cell.setCellValue("abc"); confirmStringRecord(sheet, true); cell.setCellErrorValue((byte)ErrorConstants.ERROR_REF); confirmStringRecord(sheet, false); - + // string to boolean cell.setCellValue("abc"); confirmStringRecord(sheet, true); @@ -295,33 +293,32 @@ public final class TestHSSFCell extends BaseTestCell { assertEquals(DBCellRecord.class, dbcr.getClass()); } - /** - * The maximum length of cell contents (text) is 32,767 characters. - */ - public void testMaxTextLength(){ - HSSFSheet sheet = new HSSFWorkbook().createSheet(); - HSSFCell cell = sheet.createRow(0).createCell(0); - - int maxlen = SpreadsheetVersion.EXCEL97.getMaxTextLength(); - assertEquals(32767, maxlen); - - StringBuffer b = new StringBuffer() ; - - // 32767 is okay - for( int i = 0 ; i < maxlen ; i++ ) - { - b.append( "X" ) ; - } - cell.setCellValue(b.toString()); - - b.append("X"); - // 32768 produces an invalid XLS file - try { - cell.setCellValue(b.toString()); - fail("Expected exception"); - } catch (IllegalArgumentException e){ - assertEquals("The maximum length of cell contents (text) is 32,767 characters", e.getMessage()); - } - } -} + /** + * The maximum length of cell contents (text) is 32,767 characters. + */ + public void testMaxTextLength(){ + HSSFSheet sheet = new HSSFWorkbook().createSheet(); + HSSFCell cell = sheet.createRow(0).createCell(0); + int maxlen = SpreadsheetVersion.EXCEL97.getMaxTextLength(); + assertEquals(32767, maxlen); + + StringBuffer b = new StringBuffer() ; + + // 32767 is okay + for( int i = 0 ; i < maxlen ; i++ ) + { + b.append( "X" ) ; + } + cell.setCellValue(b.toString()); + + b.append("X"); + // 32768 produces an invalid XLS file + try { + cell.setCellValue(b.toString()); + fail("Expected exception"); + } catch (IllegalArgumentException e){ + assertEquals("The maximum length of cell contents (text) is 32,767 characters", e.getMessage()); + } + } +} |