Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java?rev=1695757&r1=1695756&r2=1695757&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java Thu Aug 13 19:20:58 2015 @@ -19,82 +19,77 @@ package org.apache.poi.xwpf.usermodel; import java.io.IOException; import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; -import org.apache.poi.xwpf.XWPFTestDataSamples; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLatentStyles; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.poi.xwpf.XWPFTestDataSamples; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLatentStyles; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLsdException; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType; public class TestXWPFStyles extends TestCase { + public void testGetUsedStyles() throws IOException { + XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("Styles.docx"); + List<XWPFStyle> testUsedStyleList = new ArrayList<XWPFStyle>(); + XWPFStyles styles = sampleDoc.getStyles(); + XWPFStyle style = styles.getStyle("berschrift1"); + testUsedStyleList.add(style); + testUsedStyleList.add(styles.getStyle("Standard")); + testUsedStyleList.add(styles.getStyle("berschrift1Zchn")); + testUsedStyleList.add(styles.getStyle("Absatz-Standardschriftart")); + style.hasSameName(style); + + List<XWPFStyle> usedStyleList = styles.getUsedStyleList(style); + assertEquals(usedStyleList, testUsedStyleList); + } + + public void testAddStylesToDocument() throws IOException { + XWPFDocument docOut = new XWPFDocument(); + XWPFStyles styles = docOut.createStyles(); + + String strStyleId = "headline1"; + CTStyle ctStyle = CTStyle.Factory.newInstance(); + + ctStyle.setStyleId(strStyleId); + XWPFStyle s = new XWPFStyle(ctStyle); + styles.addStyle(s); + + assertTrue(styles.styleExist(strStyleId)); + + XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(docOut); + + styles = docIn.getStyles(); + assertTrue(styles.styleExist(strStyleId)); + } + + /** + * Bug #52449 - We should be able to write a file containing + * both regular and glossary styles without error + */ + public void test52449() throws Exception { + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("52449.docx"); + XWPFStyles styles = doc.getStyles(); + assertNotNull(styles); + + XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(doc); + styles = docIn.getStyles(); + assertNotNull(styles); + } -// protected void setUp() throws Exception { -// super.setUp(); -// } - - public void testGetUsedStyles() throws IOException { - XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("Styles.docx"); - List<XWPFStyle> testUsedStyleList = new ArrayList<XWPFStyle>(); - XWPFStyles styles = sampleDoc.getStyles(); - XWPFStyle style = styles.getStyle("berschrift1"); - testUsedStyleList.add(style); - testUsedStyleList.add(styles.getStyle("Standard")); - testUsedStyleList.add(styles.getStyle("berschrift1Zchn")); - testUsedStyleList.add(styles.getStyle("Absatz-Standardschriftart")); - style.hasSameName(style); - - List<XWPFStyle> usedStyleList = styles.getUsedStyleList(style); - assertEquals(usedStyleList, testUsedStyleList); - - - } - - public void testAddStylesToDocument() throws IOException { - XWPFDocument docOut = new XWPFDocument(); - XWPFStyles styles = docOut.createStyles(); - - String strStyleId = "headline1"; - CTStyle ctStyle = CTStyle.Factory.newInstance(); - - ctStyle.setStyleId(strStyleId); - XWPFStyle s = new XWPFStyle(ctStyle); - styles.addStyle(s); - - assertTrue(styles.styleExist(strStyleId)); - - XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(docOut); - - styles = docIn.getStyles(); - assertTrue(styles.styleExist(strStyleId)); - } - - /** - * Bug #52449 - We should be able to write a file containing - * both regular and glossary styles without error - */ - public void test52449() throws Exception { - XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("52449.docx"); - XWPFStyles styles = doc.getStyles(); - assertNotNull(styles); - - XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(doc); - styles = docIn.getStyles(); - assertNotNull(styles); - } - - - /** - * YK: tests below don't make much sense, - * they exist only to copy xml beans to pi-ooxml-schemas.jar - */ - public void testLanguages() { - XWPFDocument docOut = new XWPFDocument(); - XWPFStyles styles = docOut.createStyles(); - styles.setEastAsia("Chinese"); + + /** + * YK: tests below don't make much sense, + * they exist only to copy xml beans to pi-ooxml-schemas.jar + */ + @SuppressWarnings("resource") + public void testLanguages() { + XWPFDocument docOut = new XWPFDocument(); + XWPFStyles styles = docOut.createStyles(); + styles.setEastAsia("Chinese"); styles.setSpellingLanguage("English"); @@ -115,82 +110,82 @@ public class TestXWPFStyles extends Test CTLsdException ex = latentStyles.addNewLsdException(); ex.setName("ex1"); XWPFLatentStyles ls = new XWPFLatentStyles(latentStyles); - assertEquals(true, ls.isLatentStyle("ex1")); - assertEquals(false, ls.isLatentStyle("notex1")); - } - - public void testSetStyles_Bug57254() throws IOException { - XWPFDocument docOut = new XWPFDocument(); - XWPFStyles styles = docOut.createStyles(); + assertEquals(true, ls.isLatentStyle("ex1")); + assertEquals(false, ls.isLatentStyle("notex1")); + } + + public void testSetStyles_Bug57254() throws IOException { + XWPFDocument docOut = new XWPFDocument(); + XWPFStyles styles = docOut.createStyles(); CTStyles ctStyles = CTStyles.Factory.newInstance(); String strStyleId = "headline1"; CTStyle ctStyle = ctStyles.addNewStyle(); - - ctStyle.setStyleId(strStyleId); - styles.setStyles(ctStyles); - - assertTrue(styles.styleExist(strStyleId)); - - XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(docOut); - - styles = docIn.getStyles(); - assertTrue(styles.styleExist(strStyleId)); - } - - public void testEasyAccessToStyles() throws IOException { - XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx"); - XWPFStyles styles = doc.getStyles(); - assertNotNull(styles); - - // Has 3 paragraphs on page one, a break, and 3 on page 2 - assertEquals(7, doc.getParagraphs().size()); - - // Check the first three have no run styles, just default paragraph style - for (int i = 0; i < 3; i++) { - XWPFParagraph p = doc.getParagraphs().get(i); - assertEquals(null, p.getStyle()); - assertEquals(null, p.getStyleID()); - assertEquals(1, p.getRuns().size()); - - XWPFRun r = p.getRuns().get(0); - assertEquals(null, r.getColor()); - assertEquals(null, r.getFontFamily()); - assertEquals(null, r.getFontName()); - assertEquals(-1, r.getFontSize()); - } - - // On page two, has explicit styles, but on runs not on - // the paragraph itself - for (int i = 4; i < 7; i++) { - XWPFParagraph p = doc.getParagraphs().get(i); - assertEquals(null, p.getStyle()); - assertEquals(null, p.getStyleID()); - assertEquals(1, p.getRuns().size()); - - XWPFRun r = p.getRuns().get(0); - assertEquals("Arial Black", r.getFontFamily()); - assertEquals("Arial Black", r.getFontName()); - assertEquals(16, r.getFontSize()); - assertEquals("548DD4", r.getColor()); - } - - // Check the document styles - // Should have a style defined for each type - assertEquals(4, styles.getNumberOfStyles()); + + ctStyle.setStyleId(strStyleId); + styles.setStyles(ctStyles); + + assertTrue(styles.styleExist(strStyleId)); + + XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(docOut); + + styles = docIn.getStyles(); + assertTrue(styles.styleExist(strStyleId)); + } + + public void testEasyAccessToStyles() throws IOException { + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx"); + XWPFStyles styles = doc.getStyles(); + assertNotNull(styles); + + // Has 3 paragraphs on page one, a break, and 3 on page 2 + assertEquals(7, doc.getParagraphs().size()); + + // Check the first three have no run styles, just default paragraph style + for (int i = 0; i < 3; i++) { + XWPFParagraph p = doc.getParagraphs().get(i); + assertEquals(null, p.getStyle()); + assertEquals(null, p.getStyleID()); + assertEquals(1, p.getRuns().size()); + + XWPFRun r = p.getRuns().get(0); + assertEquals(null, r.getColor()); + assertEquals(null, r.getFontFamily()); + assertEquals(null, r.getFontName()); + assertEquals(-1, r.getFontSize()); + } + + // On page two, has explicit styles, but on runs not on + // the paragraph itself + for (int i = 4; i < 7; i++) { + XWPFParagraph p = doc.getParagraphs().get(i); + assertEquals(null, p.getStyle()); + assertEquals(null, p.getStyleID()); + assertEquals(1, p.getRuns().size()); + + XWPFRun r = p.getRuns().get(0); + assertEquals("Arial Black", r.getFontFamily()); + assertEquals("Arial Black", r.getFontName()); + assertEquals(16, r.getFontSize()); + assertEquals("548DD4", r.getColor()); + } + + // Check the document styles + // Should have a style defined for each type + assertEquals(4, styles.getNumberOfStyles()); assertNotNull(styles.getStyle("Normal")); - assertNotNull(styles.getStyle("DefaultParagraphFont")); - assertNotNull(styles.getStyle("TableNormal")); - assertNotNull(styles.getStyle("NoList")); - - // We can't do much yet with latent styles - assertEquals(137, styles.getLatentStyles().getNumberOfStyles()); - - // Check the default styles - assertNotNull(styles.getDefaultRunStyle()); - assertNotNull(styles.getDefaultParagraphStyle()); - - assertEquals(11, styles.getDefaultRunStyle().getFontSize()); - assertEquals(200, styles.getDefaultParagraphStyle().getSpacingAfter()); - } + assertNotNull(styles.getStyle("DefaultParagraphFont")); + assertNotNull(styles.getStyle("TableNormal")); + assertNotNull(styles.getStyle("NoList")); + + // We can't do much yet with latent styles + assertEquals(137, styles.getLatentStyles().getNumberOfStyles()); + + // Check the default styles + assertNotNull(styles.getDefaultRunStyle()); + assertNotNull(styles.getDefaultParagraphStyle()); + + assertEquals(11, styles.getDefaultRunStyle().getFontSize()); + assertEquals(200, styles.getDefaultParagraphStyle().getSpacingAfter()); + } }
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java?rev=1695757&r1=1695756&r2=1695757&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java Thu Aug 13 19:20:58 2015 @@ -17,12 +17,12 @@ package org.apache.poi.xwpf.usermodel; import java.math.BigInteger; -import java.util.List; - -import junit.framework.TestCase; -import org.apache.poi.xwpf.XWPFTestDataSamples; -import org.apache.poi.xwpf.usermodel.XWPFTable.XWPFBorderType; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; +import java.util.List; + +import junit.framework.TestCase; +import org.apache.poi.xwpf.XWPFTestDataSamples; +import org.apache.poi.xwpf.usermodel.XWPFTable.XWPFBorderType; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl; @@ -34,10 +34,9 @@ import org.openxmlformats.schemas.wordpr import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder; /** - * Tests for XWPF Run + * Tests for XWPF Tables */ public class TestXWPFTable extends TestCase { - protected void setUp() { /* XWPFDocument doc = new XWPFDocument(); @@ -121,13 +120,13 @@ public class TestXWPFTable extends TestC assertEquals(1, xtab.getCTTbl().getTrArray(0).sizeOfTcArray()); } - - public void testSetGetWidth() { - XWPFDocument doc = new XWPFDocument(); - - CTTbl table = CTTbl.Factory.newInstance(); - table.addNewTblPr().addNewTblW().setW(new BigInteger("1000")); - + + public void testSetGetWidth() { + XWPFDocument doc = new XWPFDocument(); + + CTTbl table = CTTbl.Factory.newInstance(); + table.addNewTblPr().addNewTblW().setW(new BigInteger("1000")); + XWPFTable xtab = new XWPFTable(table, doc); assertEquals(1000, xtab.getWidth()); @@ -145,20 +144,20 @@ public class TestXWPFTable extends TestC XWPFTableRow row = xtab.createRow(); row.setHeight(20); assertEquals(20, row.getHeight()); - } - - public void testSetGetMargins() { - // instantiate the following class so it'll get picked up by - // the XmlBean process and added to the jar file. it's required - // for the following XWPFTable methods. - CTTblCellMar ctm = CTTblCellMar.Factory.newInstance(); - assertNotNull(ctm); - // create a table - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); - // set margins - table.setCellMargins(50, 50, 250, 450); + } + + public void testSetGetMargins() { + // instantiate the following class so it'll get picked up by + // the XmlBean process and added to the jar file. it's required + // for the following XWPFTable methods. + CTTblCellMar ctm = CTTblCellMar.Factory.newInstance(); + assertNotNull(ctm); + // create a table + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); + // set margins + table.setCellMargins(50, 50, 250, 450); // get margin components int t = table.getCellMarginTop(); assertEquals(50, t); @@ -168,22 +167,22 @@ public class TestXWPFTable extends TestC assertEquals(250, b); int r = table.getCellMarginRight(); assertEquals(450, r); - } - - public void testSetGetHBorders() { - // instantiate the following classes so they'll get picked up by - // the XmlBean process and added to the jar file. they are required - // for the following XWPFTable methods. - CTTblBorders cttb = CTTblBorders.Factory.newInstance(); - assertNotNull(cttb); - STBorder stb = STBorder.Factory.newInstance(); - assertNotNull(stb); - // create a table - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); - // set inside horizontal border - table.setInsideHBorder(XWPFBorderType.SINGLE, 4, 0, "FF0000"); + } + + public void testSetGetHBorders() { + // instantiate the following classes so they'll get picked up by + // the XmlBean process and added to the jar file. they are required + // for the following XWPFTable methods. + CTTblBorders cttb = CTTblBorders.Factory.newInstance(); + assertNotNull(cttb); + STBorder stb = STBorder.Factory.newInstance(); + assertNotNull(stb); + // create a table + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); + // set inside horizontal border + table.setInsideHBorder(XWPFBorderType.SINGLE, 4, 0, "FF0000"); // get inside horizontal border components int s = table.getInsideHBorderSize(); assertEquals(4, s); @@ -193,26 +192,26 @@ public class TestXWPFTable extends TestC assertEquals("FF0000", clr); XWPFBorderType bt = table.getInsideHBorderType(); assertEquals(XWPFBorderType.SINGLE, bt); - } - - public void testSetGetVBorders() { - // create a table - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); + } + + public void testSetGetVBorders() { + // create a table + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); // set inside vertical border table.setInsideVBorder(XWPFBorderType.DOUBLE, 4, 0, "00FF00"); // get inside vertical border components XWPFBorderType bt = table.getInsideVBorderType(); assertEquals(XWPFBorderType.DOUBLE, bt); int sz = table.getInsideVBorderSize(); - assertEquals(4, sz); - int sp = table.getInsideVBorderSpace(); - assertEquals(0, sp); - String clr = table.getInsideVBorderColor(); - assertEquals("00FF00", clr); - } - + assertEquals(4, sz); + int sp = table.getInsideVBorderSpace(); + assertEquals(0, sp); + String clr = table.getInsideVBorderColor(); + assertEquals("00FF00", clr); + } + public void testSetGetRowBandSize() { XWPFDocument doc = new XWPFDocument(); CTTbl ctTable = CTTbl.Factory.newInstance(); @@ -229,30 +228,30 @@ public class TestXWPFTable extends TestC table.setColBandSize(16); int sz = table.getColBandSize(); assertEquals(16, sz); - } - - public void testCreateTable() throws Exception { - // open an empty document - XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx"); - - // create a table with 5 rows and 7 columns - int noRows = 5; - int noCols = 7; - XWPFTable table = doc.createTable(noRows, noCols); - - // assert the table is empty - List<XWPFTableRow> rows = table.getRows(); - assertEquals("Table has less rows than requested.", noRows, rows.size()); - for (XWPFTableRow xwpfRow : rows) { - assertNotNull(xwpfRow); - for (int i = 0; i < 7; i++) { - XWPFTableCell xwpfCell = xwpfRow.getCell(i); - assertNotNull(xwpfCell); - assertEquals("Empty cells should not have one paragraph.", 1, xwpfCell.getParagraphs().size()); - xwpfCell = xwpfRow.getCell(i); - assertEquals("Calling 'getCell' must not modify cells content.", 1, xwpfCell.getParagraphs().size()); - } - } - doc.getPackage().revert(); - } + } + + public void testCreateTable() throws Exception { + // open an empty document + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx"); + + // create a table with 5 rows and 7 columns + int noRows = 5; + int noCols = 7; + XWPFTable table = doc.createTable(noRows, noCols); + + // assert the table is empty + List<XWPFTableRow> rows = table.getRows(); + assertEquals("Table has less rows than requested.", noRows, rows.size()); + for (XWPFTableRow xwpfRow : rows) { + assertNotNull(xwpfRow); + for (int i = 0; i < 7; i++) { + XWPFTableCell xwpfCell = xwpfRow.getCell(i); + assertNotNull(xwpfCell); + assertEquals("Empty cells should not have one paragraph.", 1, xwpfCell.getParagraphs().size()); + xwpfCell = xwpfRow.getCell(i); + assertEquals("Calling 'getCell' must not modify cells content.", 1, xwpfCell.getParagraphs().size()); + } + } + doc.getPackage().revert(); + } } \ No newline at end of file Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java?rev=1695757&r1=1695756&r2=1695757&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java Thu Aug 13 19:20:58 2015 @@ -17,80 +17,81 @@ * ==================================================================== */ -package org.apache.poi.xwpf.usermodel; - -import junit.framework.TestCase; -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; - -public class TestXWPFTableCell extends TestCase { - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - public void testSetGetVertAlignment() throws Exception { - // instantiate the following classes so they'll get picked up by - // the XmlBean process and added to the jar file. they are required - // for the following XWPFTableCell methods. - CTShd ctShd = CTShd.Factory.newInstance(); - assertNotNull(ctShd); - CTVerticalJc ctVjc = CTVerticalJc.Factory.newInstance(); - assertNotNull(ctVjc); - STShd stShd = STShd.Factory.newInstance(); - assertNotNull(stShd); - STVerticalJc stVjc = STVerticalJc.Factory.newInstance(); - assertNotNull(stVjc); - - // create a table - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); - // table has a single row by default; grab it - XWPFTableRow tr = table.getRow(0); +package org.apache.poi.xwpf.usermodel; + +import junit.framework.TestCase; + +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; + +public class TestXWPFTableCell extends TestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + public void testSetGetVertAlignment() throws Exception { + // instantiate the following classes so they'll get picked up by + // the XmlBean process and added to the jar file. they are required + // for the following XWPFTableCell methods. + CTShd ctShd = CTShd.Factory.newInstance(); + assertNotNull(ctShd); + CTVerticalJc ctVjc = CTVerticalJc.Factory.newInstance(); + assertNotNull(ctVjc); + STShd stShd = STShd.Factory.newInstance(); + assertNotNull(stShd); + STVerticalJc stVjc = STVerticalJc.Factory.newInstance(); + assertNotNull(stVjc); + + // create a table + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); + // table has a single row by default; grab it + XWPFTableRow tr = table.getRow(0); assertNotNull(tr); // row has a single cell by default; grab it XWPFTableCell cell = tr.getCell(0); - cell.setVerticalAlignment(XWPFVertAlign.BOTH); - XWPFVertAlign al = cell.getVerticalAlignment(); - assertEquals(XWPFVertAlign.BOTH, al); - } - - public void testSetGetColor() throws Exception { - // create a table - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); - // table has a single row by default; grab it - XWPFTableRow tr = table.getRow(0); + cell.setVerticalAlignment(XWPFVertAlign.BOTH); + XWPFVertAlign al = cell.getVerticalAlignment(); + assertEquals(XWPFVertAlign.BOTH, al); + } + + public void testSetGetColor() throws Exception { + // create a table + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); + // table has a single row by default; grab it + XWPFTableRow tr = table.getRow(0); assertNotNull(tr); // row has a single cell by default; grab it XWPFTableCell cell = tr.getCell(0); - cell.setColor("F0000F"); - String clr = cell.getColor(); - assertEquals("F0000F", clr); - } - - /** - * ensure that CTHMerge & CTTcBorders go in poi-ooxml.jar - */ - public void test54099() { - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); + cell.setColor("F0000F"); + String clr = cell.getColor(); + assertEquals("F0000F", clr); + } + + /** + * ensure that CTHMerge & CTTcBorders go in poi-ooxml.jar + */ + @SuppressWarnings("unused") + public void test54099() { + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); XWPFTableRow tr = table.getRow(0); XWPFTableCell cell = tr.getCell(0); Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java?rev=1695757&r1=1695756&r2=1695757&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java Thu Aug 13 19:20:58 2015 @@ -15,54 +15,53 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xwpf.usermodel; - -import junit.framework.TestCase; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl; - -public class TestXWPFTableRow extends TestCase { - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - public void testCreateRow() throws Exception { - CTRow ctRow = CTRow.Factory.newInstance(); - assertNotNull(ctRow); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testSetGetCantSplitRow() { - // create a table - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); - // table has a single row by default; grab it - XWPFTableRow tr = table.getRow(0); - assertNotNull(tr); - - tr.setCantSplitRow(true); - boolean isCant = tr.isCantSplitRow(); - assert (isCant); - } - - public void testSetGetRepeatHeader() { - // create a table - XWPFDocument doc = new XWPFDocument(); - CTTbl ctTable = CTTbl.Factory.newInstance(); - XWPFTable table = new XWPFTable(ctTable, doc); - // table has a single row by default; grab it - XWPFTableRow tr = table.getRow(0); - assertNotNull(tr); - - tr.setRepeatHeader(true); - boolean isRpt = tr.isRepeatHeader(); - assert (isRpt); - } -} +package org.apache.poi.xwpf.usermodel; + +import junit.framework.TestCase; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl; + +public class TestXWPFTableRow extends TestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + public void testCreateRow() throws Exception { + CTRow ctRow = CTRow.Factory.newInstance(); + assertNotNull(ctRow); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testSetGetCantSplitRow() { + // create a table + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); + // table has a single row by default; grab it + XWPFTableRow tr = table.getRow(0); + assertNotNull(tr); + + tr.setCantSplitRow(true); + boolean isCant = tr.isCantSplitRow(); + assert (isCant); + } + + public void testSetGetRepeatHeader() { + // create a table + XWPFDocument doc = new XWPFDocument(); + CTTbl ctTable = CTTbl.Factory.newInstance(); + XWPFTable table = new XWPFTable(ctTable, doc); + // table has a single row by default; grab it + XWPFTableRow tr = table.getRow(0); + assertNotNull(tr); + + tr.setRepeatHeader(true); + boolean isRpt = tr.isRepeatHeader(); + assert (isRpt); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
