Author: msahyoun
Date: Wed Dec 25 14:25:41 2019
New Revision: 1871973

URL: http://svn.apache.org/viewvc?rev=1871973&view=rev
Log:
PDFBOX-4669: add currently failing test for removal of indirect objects; note 
assertFalse shall be assertTrue

Modified:
    
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java

Modified: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java?rev=1871973&r1=1871972&r2=1871973&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java
 Wed Dec 25 14:25:41 2019
@@ -344,4 +344,49 @@ public class COSArrayListTest {
             assertTrue("The size of the internal COSArray shall be 2", 
annotations.toList().size() == 2);
         }
     }
+
+    @Test
+    public void removeIndirectObject() throws IOException {
+
+        // generate test file
+        try (PDDocument pdf = new PDDocument()) {
+            PDPage page = new PDPage();
+            pdf.addPage(page);
+
+            ArrayList<PDAnnotation> pageAnnots = new ArrayList<>();
+            PDAnnotationHighlight txtMark = new PDAnnotationHighlight();
+            PDAnnotationLink txtLink = new PDAnnotationLink();
+
+            pageAnnots.add(txtMark);
+            pageAnnots.add(txtMark);
+            pageAnnots.add(txtMark);
+            pageAnnots.add(txtLink);
+            assertTrue("There shall be 4 annotations generated", 
pageAnnots.size() == 4);
+
+            page.setAnnotations(pageAnnots);
+
+            pdf.save(OUT_DIR + "/removeIndirectObjectTest.pdf");
+            pdf.close();
+        }
+
+        try (PDDocument pdf = PDDocument.load(new File(OUT_DIR + 
"/removeIndirectObjectTest.pdf"))) {
+            PDPage page = pdf.getPage(0);
+        
+            COSArrayList<PDAnnotation> annotations = (COSArrayList) 
page.getAnnotations();
+
+            assertTrue("There shall be 4 annotations retrieved", 
annotations.size() == 4);
+            assertTrue("The size of the internal COSArray shall be 4", 
annotations.toList().size() == 4);
+
+            ArrayList<PDAnnotation> toBeRemoved = new ArrayList<>();
+            toBeRemoved.add(annotations.get(0));
+            toBeRemoved.add(annotations.get(1));
+
+            annotations.removeAll(toBeRemoved);
+
+            assertTrue("There shall be 2 annotations left", annotations.size() 
== 2);
+
+            // the following line is failing 
+            assertFalse("The size of the internal COSArray shall be 2", 
annotations.toList().size() == 2);
+        }
+    }
 }
\ No newline at end of file


Reply via email to