View | Details | Raw Unified | Return to bug 66079
Collapse All | Expand All

(-)a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFBugs.java (-8 / +10 lines)
Lines 195-218 Link Here
195
195
196
            //attempt to remove item with numId 2
196
            //attempt to remove item with numId 2
197
            assertTrue(numbering.removeAbstractNum(BigInteger.valueOf(2)));
197
            assertTrue(numbering.removeAbstractNum(BigInteger.valueOf(2)));
198
            XWPFDocument docReloaded = writeOutAndReadBack(doc);
199
            XWPFNumbering numberingReloaded = docReloaded.getNumbering();
198
200
199
            for (int i = 0; i <= 10; i++) {
201
            for (int id = 0; id <= 10; id++) {
200
                XWPFAbstractNum abstractNum = numbering.getAbstractNum(BigInteger.valueOf(i));
202
                XWPFAbstractNum abstractNum = numberingReloaded.getAbstractNum(BigInteger.valueOf(id));
201
203
202
                // we removed id "2", so this one should be empty, all others not
204
                // we removed id "2", so this one should be empty, all others not
203
                if (i == 2) {
205
                if (id == 2) {
204
                    assertNull(abstractNum, "Failed for " + i);
206
                    assertNull(abstractNum, "Failed for " + id);
205
                } else {
207
                } else {
206
                    assertNotNull(abstractNum, "Failed for " + i);
208
                    assertNotNull(abstractNum, "Failed for " + id);
207
                    assertEquals(i, abstractNum.getAbstractNum().getAbstractNumId().longValue());
209
                    assertEquals(id, abstractNum.getAbstractNum().getAbstractNumId().longValue());
208
                }
210
                }
209
            }
211
            }
210
212
211
            // removing the same again fails
213
            // removing the same again fails
212
            assertFalse(numbering.removeAbstractNum(BigInteger.valueOf(2)));
214
            assertFalse(numberingReloaded.removeAbstractNum(BigInteger.valueOf(2)));
213
215
214
            // removing another one works
216
            // removing another one works
215
            assertTrue(numbering.removeAbstractNum(BigInteger.valueOf(4)));
217
            assertTrue(numberingReloaded.removeAbstractNum(BigInteger.valueOf(4)));
216
        }
218
        }
217
    }
219
    }
218
220

Return to bug 66079