]> source.dussan.org Git - poi.git/commitdiff
Test that shows that bug #52288 is already fixed
authorNick Burch <nick@apache.org>
Tue, 6 Dec 2011 03:33:11 +0000 (03:33 +0000)
committerNick Burch <nick@apache.org>
Tue, 6 Dec 2011 03:33:11 +0000 (03:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1210768 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java
test-data/document/52288.docx [new file with mode: 0644]

index 88b44975f6820b9e6715a746354390ef549179a0..272ca87d1ca994888a8eacfe271eea450c1525df 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.xwpf.usermodel;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.math.BigInteger;
+import java.util.Iterator;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -369,4 +370,24 @@ public class TestXWPFRun extends TestCase {
        assertEquals(1, doc.getAllPictures().size());
        assertEquals(1, r.getEmbeddedPictures().size());
     }
+    
+    /**
+     * Bugzilla #52288 - setting the font family on the
+     *  run mustn't NPE
+     */
+    public void testSetFontFamily_52288() throws Exception {
+       XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("52288.docx");
+       final Iterator<XWPFParagraph> paragraphs = doc.getParagraphsIterator();
+       while (paragraphs.hasNext()) {
+          final XWPFParagraph paragraph = paragraphs.next();
+          for (final XWPFRun run : paragraph.getRuns()) {
+             if (run != null) {
+                final String text = run.getText(0);
+                if (text != null) {
+                   run.setFontFamily("Times New Roman");
+                }
+             }
+          }
+       }
+    }
 }
diff --git a/test-data/document/52288.docx b/test-data/document/52288.docx
new file mode 100644 (file)
index 0000000..0eb23b0
Binary files /dev/null and b/test-data/document/52288.docx differ