]> source.dussan.org Git - poi.git/commitdiff
[bug-66079] apply test provided by Vladislav Arakelov
authorPJ Fanning <fanningpj@apache.org>
Sat, 21 May 2022 22:38:43 +0000 (22:38 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 21 May 2022 22:38:43 +0000 (22:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901105 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java

index f3ce643603db6003ee85ba030733f79a32f67855..dd241c14d3d43d9bff1502cedc92bd9b9416cfa3 100644 (file)
@@ -196,23 +196,26 @@ class TestXWPFBugs {
             //attempt to remove item with numId 2
             assertTrue(numbering.removeAbstractNum(BigInteger.valueOf(2)));
 
-            for (int i = 0; i <= 10; i++) {
-                XWPFAbstractNum abstractNum = numbering.getAbstractNum(BigInteger.valueOf(i));
+            XWPFDocument docReloaded = writeOutAndReadBack(doc);
+            XWPFNumbering numberingReloaded = docReloaded.getNumbering();
+
+            for (int id = 0; id <= 10; id++) {
+                XWPFAbstractNum abstractNum = numberingReloaded.getAbstractNum(BigInteger.valueOf(id));
 
                 // we removed id "2", so this one should be empty, all others not
-                if (i == 2) {
-                    assertNull(abstractNum, "Failed for " + i);
+                if (id == 2) {
+                    assertNull(abstractNum, "Failed for " + id);
                 } else {
-                    assertNotNull(abstractNum, "Failed for " + i);
-                    assertEquals(i, abstractNum.getAbstractNum().getAbstractNumId().longValue());
+                    assertNotNull(abstractNum, "Failed for " + id);
+                    assertEquals(id, abstractNum.getAbstractNum().getAbstractNumId().longValue());
                 }
             }
 
             // removing the same again fails
-            assertFalse(numbering.removeAbstractNum(BigInteger.valueOf(2)));
+            assertFalse(numberingReloaded.removeAbstractNum(BigInteger.valueOf(2)));
 
             // removing another one works
-            assertTrue(numbering.removeAbstractNum(BigInteger.valueOf(4)));
+            assertTrue(numberingReloaded.removeAbstractNum(BigInteger.valueOf(4)));
         }
     }