Remove Eclipse warnings, remove duplicate test, rename tests to also run tests in base class

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1521015 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2013-09-09 09:41:31 +00:00
parent e6ed66a126
commit 4a3c974e3b
9 changed files with 36 additions and 45 deletions

View File

@ -64,7 +64,7 @@ public final class HSSFPalette {
} }
/** /**
* Finds the first occurance of a given color * Finds the first occurrence of a given color
* *
* @param red the RGB red component, between 0 and 255 inclusive * @param red the RGB red component, between 0 and 255 inclusive
* @param green the RGB green component, between 0 and 255 inclusive * @param green the RGB green component, between 0 and 255 inclusive
@ -194,11 +194,13 @@ public final class HSSFPalette {
_blue = blue; _blue = blue;
} }
@Override
public short getIndex() public short getIndex()
{ {
return _byteOffset; return _byteOffset;
} }
@Override
public short[] getTriplet() public short[] getTriplet()
{ {
return new short[] return new short[]
@ -209,6 +211,7 @@ public final class HSSFPalette {
}; };
} }
@Override
public String getHexString() public String getHexString()
{ {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();

View File

@ -592,6 +592,7 @@ public interface Sheet extends Iterable<Row> {
* @param leftcol the left column to show in desktop window pane * @param leftcol the left column to show in desktop window pane
* @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows. * @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows.
*/ */
@Deprecated
void showInPane(short toprow, short leftcol); void showInPane(short toprow, short leftcol);
/** /**

View File

@ -22,13 +22,13 @@ import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.formula.SharedFormula;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.FormulaParser; import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaRenderer; import org.apache.poi.ss.formula.FormulaRenderer;
import org.apache.poi.ss.formula.FormulaType; import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.SharedFormula;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Comment; import org.apache.poi.ss.usermodel.Comment;
@ -39,9 +39,9 @@ import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Internal;
import org.apache.poi.xssf.model.SharedStringsTable; import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.util.Internal;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
@ -790,6 +790,7 @@ public final class XSSFCell implements Cell {
* Errors are displayed as #ERR&lt;errIdx&gt; * Errors are displayed as #ERR&lt;errIdx&gt;
* </p> * </p>
*/ */
@Override
public String toString() { public String toString() {
switch (getCellType()) { switch (getCellType()) {
case CELL_TYPE_BLANK: case CELL_TYPE_BLANK:

View File

@ -26,8 +26,6 @@ import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.model.CalculationChain; import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.model.StylesTable;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
@ -37,7 +35,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
* High level representation of a row of a spreadsheet. * High level representation of a row of a spreadsheet.
*/ */
public class XSSFRow implements Row, Comparable<XSSFRow> { public class XSSFRow implements Row, Comparable<XSSFRow> {
private static final POILogger _logger = POILogFactory.getLogger(XSSFRow.class); //private static final POILogger _logger = POILogFactory.getLogger(XSSFRow.class);
/** /**
* the xml bean containing all cell definitions for this row * the xml bean containing all cell definitions for this row
@ -93,6 +91,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* *
* @return an iterator over cells in this row. * @return an iterator over cells in this row.
*/ */
@SuppressWarnings("unchecked")
public Iterator<Cell> cellIterator() { public Iterator<Cell> cellIterator() {
return (Iterator<Cell>)(Iterator<? extends Cell>)_cells.values().iterator(); return (Iterator<Cell>)(Iterator<? extends Cell>)_cells.values().iterator();
} }
@ -202,7 +201,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
public XSSFCell getCell(int cellnum, MissingCellPolicy policy) { public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0"); if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0");
XSSFCell cell = (XSSFCell)_cells.get(cellnum); XSSFCell cell = _cells.get(cellnum);
if(policy == RETURN_NULL_AND_BLANK) { if(policy == RETURN_NULL_AND_BLANK) {
return cell; return cell;
} }

View File

@ -51,6 +51,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
} }
//TODO column styles are not yet supported by XSSF //TODO column styles are not yet supported by XSSF
@Override
public void testDefaultColumnStyle() { public void testDefaultColumnStyle() {
//super.testDefaultColumnStyle(); //super.testDefaultColumnStyle();
} }
@ -914,7 +915,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
* Rows and cells can be created in random order, * Rows and cells can be created in random order,
* but CTRows are kept in ascending order * but CTRows are kept in ascending order
*/ */
public void testCreateRow() { public void testCreateRowA() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
CTWorksheet wsh = sheet.getCTWorksheet(); CTWorksheet wsh = sheet.getCTWorksheet();

View File

@ -30,11 +30,11 @@ import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.InternalWorkbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.FormulaRecord; import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.formula.ptg.Ref3DPtg;
import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook; import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.formula.ptg.Ref3DPtg;
/** /**
* Tests for {@link EventWorkbookBuilder} * Tests for {@link EventWorkbookBuilder}
*/ */
@ -42,6 +42,7 @@ public final class TestEventWorkbookBuilder extends TestCase {
private MockHSSFListener mockListen; private MockHSSFListener mockListen;
private SheetRecordCollectingListener listener; private SheetRecordCollectingListener listener;
@Override
public void setUp() { public void setUp() {
HSSFRequest req = new HSSFRequest(); HSSFRequest req = new HSSFRequest();
mockListen = new MockHSSFListener(); mockListen = new MockHSSFListener();
@ -146,8 +147,8 @@ public final class TestEventWorkbookBuilder extends TestCase {
private static final class MockHSSFListener implements HSSFListener { private static final class MockHSSFListener implements HSSFListener {
public MockHSSFListener() {} public MockHSSFListener() {}
private final List _records = new ArrayList(); private final List<Record> _records = new ArrayList<Record>();
private final List _frecs = new ArrayList(); private final List<Record> _frecs = new ArrayList<Record>();
public void processRecord(Record record) { public void processRecord(Record record) {
_records.add(record); _records.add(record);

View File

@ -25,7 +25,6 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.PaletteRecord; import org.apache.poi.hssf.record.PaletteRecord;
import org.apache.poi.hssf.usermodel.HSSFPalette;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
/** /**
@ -36,6 +35,7 @@ public final class TestHSSFPalette extends TestCase {
private HSSFPalette _hssfPalette; private HSSFPalette _hssfPalette;
@Override
public void setUp() public void setUp()
{ {
_palette = new PaletteRecord(); _palette = new PaletteRecord();
@ -268,12 +268,12 @@ public final class TestHSSFPalette extends TestCase {
} }
private void compareToDefaults(ColorComparator c) { private void compareToDefaults(ColorComparator c) {
Map colors = HSSFColor.getIndexHash(); Map<Integer,HSSFColor> colors = HSSFColor.getIndexHash();
Iterator it = colors.keySet().iterator(); Iterator<Integer> it = colors.keySet().iterator();
while (it.hasNext()) while (it.hasNext())
{ {
Number index = (Number) it.next(); Number index = it.next();
HSSFColor expectedColor = (HSSFColor) colors.get(index); HSSFColor expectedColor = colors.get(index);
HSSFColor paletteColor = _hssfPalette.getColor(index.shortValue()); HSSFColor paletteColor = _hssfPalette.getColor(index.shortValue());
c.compare(expectedColor, paletteColor); c.compare(expectedColor, paletteColor);
} }

View File

@ -28,13 +28,13 @@ import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.DrawingManager2; import org.apache.poi.hssf.model.DrawingManager2;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.model.InternalSheet; 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.*;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.formula.ptg.Area3DPtg;
import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock; import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector; import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector;
import org.apache.poi.ss.formula.ptg.Area3DPtg;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint; import org.apache.poi.ss.usermodel.DataValidationConstraint;
@ -44,7 +44,6 @@ import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.ss.util.Region;
import org.apache.poi.util.TempFile; import org.apache.poi.util.TempFile;
/** /**
@ -363,7 +362,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash()); assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash());
} }
public void testProtectSheet() { public void testProtectSheetA() {
int expectedHash = (short)0xfef1; int expectedHash = (short)0xfef1;
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
@ -517,21 +516,6 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol()); assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol());
} }
/** cell with formula becomes null on cloning a sheet*/
public void test35084() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet("Sheet1");
HSSFRow r = s.createRow(0);
r.createCell(0).setCellValue(1);
r.createCell(1).setCellFormula("A1*2");
HSSFSheet s1 = wb.cloneSheet(0);
r = s1.getRow(0);
assertEquals("double", r.getCell(0).getNumericCellValue(), 1, 0); // sanity check
assertNotNull(r.getCell(1));
assertEquals("formula", r.getCell(1).getCellFormula(), "A1*2");
}
/** /**
* *
*/ */
@ -702,7 +686,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertTrue(wb3.getSheetAt(3).getForceFormulaRecalculation()); assertTrue(wb3.getSheetAt(3).getForceFormulaRecalculation());
} }
public void testColumnWidth() { public void testColumnWidthA() {
//check we can correctly read column widths from a reference workbook //check we can correctly read column widths from a reference workbook
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("colwidth.xls"); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("colwidth.xls");

View File

@ -394,6 +394,7 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals(40000, sheet.getColumnWidth(10)); assertEquals(40000, sheet.getColumnWidth(10));
} }
public void testDefaultRowHeight() { public void testDefaultRowHeight() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet(); Sheet sheet = workbook.createSheet();
@ -538,8 +539,8 @@ public abstract class BaseTestSheet extends TestCase {
double marginRight = defaultMargins[1]; double marginRight = defaultMargins[1];
double marginTop = defaultMargins[2]; double marginTop = defaultMargins[2];
double marginBottom = defaultMargins[3]; double marginBottom = defaultMargins[3];
double marginHeader = defaultMargins[4]; //double marginHeader = defaultMargins[4];
double marginFooter = defaultMargins[5]; //double marginFooter = defaultMargins[5];
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1"); Sheet sheet = workbook.createSheet("Sheet 1");