diff options
author | Dominik Stadler <centic@apache.org> | 2016-06-02 20:09:44 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2016-06-02 20:09:44 +0000 |
commit | 8811c99ac3a9d6b843c99fc6cee00533067f1402 (patch) | |
tree | 96dee00fce89ad60dbe0bc78b909b687c73ace0b /src/ooxml/testcases/org/apache/poi/xwpf | |
parent | bde09054f029fbd8e9206a4b6d83d659e0aebb9c (diff) | |
download | poi-8811c99ac3a9d6b843c99fc6cee00533067f1402.tar.gz poi-8811c99ac3a9d6b843c99fc6cee00533067f1402.zip |
Avoid NPE in XWPFTableCell, taken from https://github.com/prasad-babu/poi/tree/WORKING_BRANCH
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1746625 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/xwpf')
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java | 35 |
1 files changed, 19 insertions, 16 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 ab2fad84b3..00e34e241e 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java @@ -19,23 +19,12 @@ package org.apache.poi.xwpf.usermodel; -import java.util.List; - import junit.framework.TestCase; - import org.apache.poi.xwpf.XWPFTestDataSamples; import org.apache.poi.xwpf.usermodel.XWPFTableCell.XWPFVertAlign; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHMerge; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcBorders; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVMerge; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalJc; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STShd; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalJc; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; + +import java.util.List; public class TestXWPFTableCell extends TestCase { @Override @@ -117,9 +106,23 @@ public class TestXWPFTableCell extends TestCase { List<XWPFTableRow> tableRows = table.getRows(); assertEquals(2, tableRows.size()); - assertNull(tableRows.get(0).getCell(0).getVerticalAlignment()); + assertEquals(XWPFVertAlign.TOP, tableRows.get(0).getCell(0).getVerticalAlignment()); assertEquals(XWPFVertAlign.BOTTOM, tableRows.get(0).getCell(1).getVerticalAlignment()); assertEquals(XWPFVertAlign.CENTER, tableRows.get(1).getCell(0).getVerticalAlignment()); - assertNull(tableRows.get(1).getCell(1).getVerticalAlignment()); + assertEquals(XWPFVertAlign.TOP, tableRows.get(1).getCell(1).getVerticalAlignment()); } + + public void testCellVerticalAlign2() throws Exception{ + XWPFDocument docx = XWPFTestDataSamples.openSampleDocument("TestTableCellAlign.docx"); + List<XWPFTable> tables = docx.getTables(); + for (XWPFTable table : tables) { + List<XWPFTableRow> tableRows = table.getRows(); + for (XWPFTableRow tableRow : tableRows) { + List<XWPFTableCell> tableCells = tableRow.getTableCells(); + for (XWPFTableCell tableCell : tableCells) { + assertNotNull(tableCell.getVerticalAlignment()); + } + } + } + } } |