add unit test for Cell.getCellComment
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748813 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ea5e99ce4
commit
720e866a4c
@ -979,4 +979,35 @@ public abstract class BaseTestCell {
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCellComment() throws IOException {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
CreationHelper factory = wb.getCreationHelper();
|
||||
Row row = sheet.createRow(0);
|
||||
Cell cell = row.createCell(1);
|
||||
|
||||
// cell does not have a comment
|
||||
assertNull(cell.getCellComment());
|
||||
|
||||
// add a cell comment
|
||||
ClientAnchor anchor = factory.createClientAnchor();
|
||||
anchor.setCol1(cell.getColumnIndex());
|
||||
anchor.setCol2(cell.getColumnIndex()+1);
|
||||
anchor.setRow1(row.getRowNum());
|
||||
anchor.setRow2(row.getRowNum()+3);
|
||||
|
||||
Drawing drawing = sheet.createDrawingPatriarch();
|
||||
Comment comment = drawing.createCellComment(anchor);
|
||||
RichTextString str = factory.createRichTextString("Hello, World!");
|
||||
comment.setString(str);
|
||||
|
||||
comment.setAuthor("Apache POI");
|
||||
cell.setCellComment(comment);
|
||||
// ideally assertSame, but XSSFCell creates a new XSSFCellComment wrapping the same bean for every call to getCellComment.
|
||||
assertEquals(comment, cell.getCellComment());
|
||||
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user