From cc962432a46b887e5a139e5973a7b22380076678 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Wed, 8 Feb 2017 18:35:04 +0000 Subject: [PATCH] bug 59030: revert r1746625 and restore r1731257, where XWPFTableCell#getVerticalAlignment() returns null rather than a default value (XWPFVertAlign.TOP) if vertical alignment is not set git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1782225 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java index d33a9aa3a..d1cf5b2e9 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java @@ -110,12 +110,14 @@ public class TestXWPFTableCell { List tableRows = table.getRows(); assertEquals(2, tableRows.size()); - assertEquals(XWPFVertAlign.TOP, tableRows.get(0).getCell(0).getVerticalAlignment()); + assertNull(tableRows.get(0).getCell(0).getVerticalAlignment()); assertEquals(XWPFVertAlign.BOTTOM, tableRows.get(0).getCell(1).getVerticalAlignment()); assertEquals(XWPFVertAlign.CENTER, tableRows.get(1).getCell(0).getVerticalAlignment()); - assertEquals(XWPFVertAlign.TOP, tableRows.get(1).getCell(1).getVerticalAlignment()); + assertNull(tableRows.get(1).getCell(1).getVerticalAlignment()); // should return null since alignment isn't set } + // This is not a very useful test as written. It is not worth the execution time for a unit test + @Ignore @Test public void testCellVerticalAlignShouldNotThrowNPE() throws Exception { XWPFDocument docx = XWPFTestDataSamples.openSampleDocument("TestTableCellAlign.docx"); @@ -125,7 +127,8 @@ public class TestXWPFTableCell { for (XWPFTableRow tableRow : tableRows) { List tableCells = tableRow.getTableCells(); for (XWPFTableCell tableCell : tableCells) { - assertNotNull(tableCell.getVerticalAlignment()); + // getVerticalAlignment should return either an XWPFVertAlign enum or null if not set + tableCell.getVerticalAlignment(); } } }