fix BasteTestCellComment#attemptToSave2CommentsWithSameCoordinates to work with different behaviors of HSSFWorkbook and XSSFWorkbook
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742871 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e9bfa9da87
commit
fe04abd31d
@ -357,19 +357,25 @@ public abstract class BaseTestCellComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void attemptToSave2CommentsWithSameCoordinates(){
|
public void attemptToSave2CommentsWithSameCoordinates() throws IOException {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
Sheet sh = wb.createSheet();
|
Sheet sh = wb.createSheet();
|
||||||
CreationHelper factory = wb.getCreationHelper();
|
CreationHelper factory = wb.getCreationHelper();
|
||||||
Drawing patriarch = sh.createDrawingPatriarch();
|
Drawing patriarch = sh.createDrawingPatriarch();
|
||||||
patriarch.createCellComment(factory.createClientAnchor());
|
patriarch.createCellComment(factory.createClientAnchor());
|
||||||
patriarch.createCellComment(factory.createClientAnchor());
|
|
||||||
|
|
||||||
try{
|
try {
|
||||||
|
patriarch.createCellComment(factory.createClientAnchor());
|
||||||
_testDataProvider.writeOutAndReadBack(wb);
|
_testDataProvider.writeOutAndReadBack(wb);
|
||||||
fail("Expected IllegalStateException(found multiple cell comments for cell $A$1");
|
fail("Should not be able to create a corrupted workbook with multiple cell comments in one cell");
|
||||||
} catch (IllegalStateException e){
|
} catch (IllegalStateException e) {
|
||||||
|
// HSSFWorkbooks fail when writing out workbook
|
||||||
assertEquals("found multiple cell comments for cell $A$1", e.getMessage());
|
assertEquals("found multiple cell comments for cell $A$1", e.getMessage());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// XSSFWorkbooks fail when creating and setting the cell address of the comment
|
||||||
|
assertEquals("Multiple cell comments in one cell are not allowed, cell: A1", e.getMessage());
|
||||||
|
} finally {
|
||||||
|
wb.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user