]> source.dussan.org Git - poi.git/commitdiff
Add test for setters/getters of XWPFRun to include morre generated classes in poi...
authorDominik Stadler <centic@apache.org>
Sun, 11 Mar 2018 21:11:11 +0000 (21:11 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 11 Mar 2018 21:11:11 +0000 (21:11 +0000)
See also https://github.com/centic9/poi-on-android/issues/31

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1826464 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java

index 459271ec27490f8a2b960a6b049b64c2e83c3480..026cdac5849aefb9c01490f0292e310a2f348b30 100644 (file)
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.util.Units;
 import org.apache.poi.wp.usermodel.HeaderFooterType;
@@ -38,18 +28,25 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
 import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLang;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLang;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 /**
  * Tests for XWPF Run
  */
@@ -294,8 +291,6 @@ public class TestXWPFRun {
     /**
      * Test that on an existing document, we do the
      * right thing with it
-     *
-     * @throws IOException
      */
     @Test
     public void testExisting() throws IOException {
@@ -458,7 +453,7 @@ public class TestXWPFRun {
     }
     
     @Test
-    public void testSetGetLang() throws IOException {
+    public void testSetGetLang() {
         XWPFRun run = p.createRun();
         assertNull(run.getLang());
 
@@ -473,7 +468,7 @@ public class TestXWPFRun {
     }
 
     @Test
-    public void testSetGetHighlight() throws IOException {
+    public void testSetGetHighlight() {
         XWPFRun run = p.createRun();
         assertEquals(false, run.isHighlighted());
         
@@ -654,4 +649,28 @@ public class TestXWPFRun {
         
         document.close();
     }
+
+    @Test
+    public void testSetters() throws IOException {
+        XWPFDocument document = new XWPFDocument();
+        final XWPFRun run = document.createParagraph().createRun();
+
+        // at least trigger some of the setters to ensure classes are included in
+        // the poi-ooxml-schemas
+        run.setBold(true);
+        run.setCapitalized(true);
+        run.setCharacterSpacing(2);
+        assertEquals(2, run.getCharacterSpacing());
+        run.setColor("000000");
+        run.setDoubleStrikethrough(true);
+        run.setEmbossed(true);
+        run.setFontFamily("Calibri");
+        assertEquals("Calibri", run.getFontFamily());
+        run.setFontSize(10);
+        assertEquals(10, run.getFontSize());
+        run.setImprinted(true);
+        run.setItalic(true);
+
+        document.close();
+    }
 }