]> source.dussan.org Git - poi.git/commitdiff
XWPF Numbering tests from bug #51134
authorNick Burch <nick@apache.org>
Fri, 8 Jul 2011 13:12:53 +0000 (13:12 +0000)
committerNick Burch <nick@apache.org>
Fri, 8 Jul 2011 13:12:53 +0000 (13:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144303 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFNumbering.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java

index 7ee56373940aafaeb35b34b657f5fc4183f5c1e7..8c114e209ef92b67f31a41b2afd6d6eb48496468 100644 (file)
@@ -38,4 +38,22 @@ public class TestXWPFNumbering extends TestCase {
                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);
+       }
+
 }
index 704b02afc5fc9c86a4f650041fd99c1f7307aef0..156e1b580239e287d96dff172142c01adfbf3553 100644 (file)
@@ -20,11 +20,14 @@ package org.apache.poi.xwpf.usermodel;
 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 {
@@ -48,6 +51,23 @@ public class TestXWPFStyles extends TestCase {
                
        }
 
+       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();
 //     }