Skip to content

Commit 22b636b

Browse files
author
Alexander Pliushchou
committed
add test for double increment update
DEVSIX-1686
1 parent 0171de5 commit 22b636b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

kernel/src/test/java/com/itextpdf/kernel/pdf/XrefStreamDocumentUpdatesTest.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void beforeClass() {
5252
public static void afterClass() {
5353
CompareTool.cleanup(destinationFolder);
5454
}
55-
55+
5656
@Test
5757
public void readFreeRefReusingInIncrementTest() throws IOException {
5858
PdfDocument document = new PdfDocument(new PdfReader
@@ -137,12 +137,12 @@ public void freeRefReuseWhenAddNewObjTest() throws IOException {
137137
Assert.assertEquals(8, expectObjNumber);
138138
Assert.assertEquals(0, expectGenNumber);
139139
Assert.assertTrue(xref.get(5).isFree());
140-
140+
141141
pdfDoc1.close();
142142
}
143143

144144
@Test
145-
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
145+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
146146
ignore = true))
147147
public void checkEncryptionInXrefStmInIncrementsTest() throws IOException, InterruptedException {
148148
String inFileName = sourceFolder + "encryptedDocWithXrefStm.pdf";
@@ -278,4 +278,27 @@ public void closeDocumentWithoutModificationsTest() throws IOException {
278278
doc.close();
279279
Assert.assertEquals(1, xrefTableCounter);
280280
}
281+
282+
@Test
283+
public void hybridReferenceIncrementTwiceTest() throws IOException, InterruptedException {
284+
String inFileName = sourceFolder + "hybridReferenceDocument.pdf";
285+
String outFileName = destinationFolder + "hybridReferenceDocumentUpdateTwice.pdf";
286+
287+
PdfDocument pdfDoc1 = new PdfDocument(
288+
new PdfReader(inFileName),
289+
new PdfWriter(destinationFolder + "hybridReferenceDocumentUpdate.pdf"),
290+
new StampingProperties().useAppendMode()
291+
);
292+
pdfDoc1.close();
293+
294+
PdfDocument pdfDoc2 = new PdfDocument(
295+
new PdfReader(destinationFolder + "hybridReferenceDocumentUpdate.pdf"),
296+
CompareTool.createTestPdfWriter(outFileName),
297+
new StampingProperties().useAppendMode()
298+
);
299+
pdfDoc2.close();
300+
301+
//if document processed correctly, no errors should occur
302+
Assert.assertNull(new CompareTool().compareByContent(outFileName, inFileName, destinationFolder));
303+
}
281304
}

0 commit comments

Comments
 (0)