]> source.dussan.org Git - poi.git/commitdiff
fix BasteTestCellComment#attemptToSave2CommentsWithSameCoordinates to work with diffe...
authorJaven O'Neal <onealj@apache.org>
Mon, 9 May 2016 04:29:17 +0000 (04:29 +0000)
committerJaven O'Neal <onealj@apache.org>
Mon, 9 May 2016 04:29:17 +0000 (04:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742871 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java

index e7db17c47c978740d64f45172aa88db451d10930..844c95f825df067e59d9fb689769965339583239 100644 (file)
@@ -357,19 +357,25 @@ public abstract class BaseTestCellComment {
     }
     
     @Test
-    public void attemptToSave2CommentsWithSameCoordinates(){
+    public void attemptToSave2CommentsWithSameCoordinates() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet sh = wb.createSheet();
         CreationHelper factory = wb.getCreationHelper();
         Drawing patriarch = sh.createDrawingPatriarch();
         patriarch.createCellComment(factory.createClientAnchor());
-        patriarch.createCellComment(factory.createClientAnchor());
         
-        try{
+        try {
+            patriarch.createCellComment(factory.createClientAnchor());
             _testDataProvider.writeOutAndReadBack(wb);
-            fail("Expected IllegalStateException(found multiple cell comments for cell $A$1");
-        } catch (IllegalStateException e){
+            fail("Should not be able to create a corrupted workbook with multiple cell comments in one cell");
+        } catch (IllegalStateException e) {
+            // HSSFWorkbooks fail when writing out workbook
             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();
         }
     }
 }