File tree Expand file tree Collapse file tree
pdfbox/src/test/java/org/apache/pdfbox/pdmodel Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434import static org .junit .jupiter .api .Assertions .assertNull ;
3535import static org .junit .jupiter .api .Assertions .assertThrows ;
3636import static org .junit .jupiter .api .Assertions .assertTrue ;
37- import static org .junit .jupiter .api .Assertions .fail ;
3837import org .junit .jupiter .api .BeforeAll ;
3938import org .junit .jupiter .api .Test ;
4039
@@ -205,15 +204,8 @@ void testDeleteGoodFile() throws IOException
205204 }
206205
207206 Loader .loadPDF (f ).close ();
208-
209- try
210- {
211- Files .delete (f .toPath ());
212- }
213- catch (IOException ex )
214- {
215- fail ("delete good file failed after successful load() and close()" );
216- }
207+ assertDoesNotThrow (() -> Files .delete (f .toPath ()),
208+ "delete good file failed after successful load() and close()" );
217209 }
218210
219211 /**
@@ -237,7 +229,7 @@ void testSaveArabicLocale() throws IOException
237229 doc .save (baos );
238230 }
239231
240- Loader .loadPDF (baos .toByteArray ()).close ();
232+ assertDoesNotThrow (() -> Loader .loadPDF (baos .toByteArray ()).close () );
241233
242234 Locale .setDefault (defaultLocale );
243235 }
Original file line number Diff line number Diff line change 2626import org .apache .pdfbox .io .RandomAccessReadBuffer ;
2727import org .apache .pdfbox .pdmodel .graphics .color .PDOutputIntent ;
2828
29+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
2930import static org .junit .jupiter .api .Assertions .assertEquals ;
3031import static org .junit .jupiter .api .Assertions .assertNull ;
3132import static org .junit .jupiter .api .Assertions .assertTrue ;
@@ -90,7 +91,7 @@ void retrievePageLabelsOnMalformedPdf() throws IOException
9091 {
9192 PDDocumentCatalog cat = doc .getDocumentCatalog ();
9293 // getLabelsByPageIndices() should not throw an exception
93- cat .getPageLabels ().getLabelsByPageIndices ();
94+ assertDoesNotThrow (() -> cat .getPageLabels ().getLabelsByPageIndices () );
9495 }
9596 }
9697
Original file line number Diff line number Diff line change 2424import org .apache .pdfbox .pdmodel .interactive .annotation .PDAnnotationWidget ;
2525import org .apache .pdfbox .pdmodel .interactive .form .PDAcroForm ;
2626import org .apache .pdfbox .pdmodel .interactive .form .PDTextField ;
27+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
2728import static org .junit .jupiter .api .Assertions .assertEquals ;
2829
2930import org .junit .jupiter .api .Test ;
@@ -51,7 +52,7 @@ void testAddingPageAfterCreatingAnnotation() throws IOException
5152 acroForm .getFields ().add (textField );
5253
5354 // Adding page AFTER creating form fields causes a StackOverflowError
54- document .addPage (page );
55+ assertDoesNotThrow (() -> document .addPage (page ) );
5556
5657 document .save (OutputStream .nullOutputStream ());
5758 document .close ();
You can’t perform that action at this time.
0 commit comments