assertEquals(abstrNumId, compareAbstractNum);
}
+ public void testAddNumberingToDoc() throws IOException{
+ BigInteger abstractNumId = BigInteger.valueOf(1);
+ BigInteger numId = BigInteger.valueOf(1);
+
+ XWPFDocument docOut = new XWPFDocument();
+ XWPFNumbering numbering = docOut.createNumbering();
+ numId = numbering.addNum(abstractNumId);
+
+ XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(docOut);
+
+ numbering = docIn.getNumbering();
+ assertTrue(numbering.numExist(numId));
+ XWPFNum num = numbering.getNum(numId);
+
+ BigInteger compareAbstractNum = num.getCTNum().getAbstractNumId().getVal();
+ assertEquals(abstractNumId, compareAbstractNum);
+ }
+
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.lang.String;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
+
public class TestXWPFStyles extends TestCase {
// protected void setUp() throws Exception {
}
+ public void testAddStylesToDocument() throws IOException{
+ XWPFDocument docOut = new XWPFDocument();
+ XWPFStyles styles = docOut.createStyles();
+
+ String strStyleName = "headline1";
+ CTStyle ctStyle = CTStyle.Factory.newInstance();
+
+ ctStyle.setStyleId(strStyleName);
+ XWPFStyle s = new XWPFStyle(ctStyle);
+ styles.addStyle(s);
+
+ XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(docOut);
+
+ styles = docIn.getStyles();
+ assertTrue(styles.styleExist(strStyleName));
+ }
+
// protected void tearDown() throws Exception {
// super.tearDown();
// }