1818package org .apache .pdfbox .pdfparser ;
1919
2020import static org .junit .jupiter .api .Assertions .assertEquals ;
21- import static org .junit .jupiter .api .Assertions .fail ;
2221
2322import java .io .File ;
2423import java .io .IOException ;
25- import java .net .URISyntaxException ;
2624
2725import org .apache .pdfbox .Loader ;
2826import org .apache .pdfbox .cos .COSName ;
3331import org .apache .pdfbox .pdmodel .interactive .documentnavigation .outline .PDOutlineItem ;
3432import org .apache .pdfbox .rendering .PDFRenderer ;
3533import org .apache .pdfbox .util .DateConverter ;
34+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
3635import org .junit .jupiter .api .Test ;
3736
3837class TestPDFParser
3938{
4039 private static final File TARGETPDFDIR = new File ("target/pdfs" );
4140
4241 @ Test
43- void testPDFParserMissingCatalog () throws URISyntaxException
42+ void testPDFParserMissingCatalog ()
4443 {
4544 // PDFBOX-3060
46- try
47- {
45+ assertDoesNotThrow (() ->
4846 Loader .loadPDF (new File (TestPDFParser .class .getResource ("MissingCatalog.pdf" ).toURI ()))
49- .close ();
50- }
51- catch (Exception exception )
52- {
53- fail ("Unexpected Exception" );
54- }
47+ .close ());
5548 }
5649
5750 /**
@@ -107,17 +100,12 @@ void testPDFBox3940() throws IOException
107100 @ Test
108101 void testPDFBox3783 ()
109102 {
110- try
103+ assertDoesNotThrow (() ->
111104 {
112105 Loader .loadPDF (
113106 new File (TARGETPDFDIR , "PDFBOX-3783-72GLBIGUC6LB46ELZFBARRJTLN4RBSQM.pdf" ))
114107 .close ();
115- }
116- catch (Exception exception )
117- {
118- fail ("Unexpected IOException" );
119- }
120-
108+ });
121109 }
122110
123111 /**
@@ -141,14 +129,10 @@ void testPDFBox3785() throws IOException
141129 @ Test
142130 void testPDFBox3947 ()
143131 {
144- try
132+ assertDoesNotThrow (() ->
145133 {
146134 Loader .loadPDF (new File (TARGETPDFDIR , "PDFBOX-3947-670064.pdf" )).close ();
147- }
148- catch (Exception exception )
149- {
150- fail ("Unexpected Exception" );
151- }
135+ });
152136 }
153137
154138 /**
@@ -157,16 +141,12 @@ void testPDFBox3947()
157141 @ Test
158142 void testPDFBox3948 ()
159143 {
160- try
144+ assertDoesNotThrow (() ->
161145 {
162146 Loader .loadPDF (
163147 new File (TARGETPDFDIR , "PDFBOX-3948-EUWO6SQS5TM4VGOMRD3FLXZHU35V2CP2.pdf" ))
164148 .close ();
165- }
166- catch (Exception exception )
167- {
168- fail ("Unexpected Exception" );
169- }
149+ });
170150 }
171151
172152 /**
@@ -175,16 +155,12 @@ void testPDFBox3948()
175155 @ Test
176156 void testPDFBox3949 ()
177157 {
178- try
158+ assertDoesNotThrow (() ->
179159 {
180160 Loader .loadPDF (
181161 new File (TARGETPDFDIR , "PDFBOX-3949-MKFYUGZWS3OPXLLVU2Z4LWCTVA5WNOGF.pdf" ))
182162 .close ();
183- }
184- catch (Exception exception )
185- {
186- fail ("Unexpected Exception" );
187- }
163+ });
188164 }
189165
190166 /**
@@ -275,14 +251,10 @@ void testPDFBox3977() throws IOException
275251 @ Test
276252 void testParseGenko ()
277253 {
278- try
254+ assertDoesNotThrow (() ->
279255 {
280256 Loader .loadPDF (new File (TARGETPDFDIR , "genko_oc_shiryo1.pdf" )).close ();
281- }
282- catch (Exception exception )
283- {
284- fail ("Unexpected Exception" );
285- }
257+ });
286258 }
287259
288260 /**
@@ -292,14 +264,10 @@ void testParseGenko()
292264 @ Test
293265 void testPDFBox4338 ()
294266 {
295- try
267+ assertDoesNotThrow (() ->
296268 {
297269 Loader .loadPDF (new File (TARGETPDFDIR , "PDFBOX-4338.pdf" )).close ();
298- }
299- catch (Exception exception )
300- {
301- fail ("Unexpected Exception" );
302- }
270+ });
303271 }
304272
305273 /**
@@ -309,14 +277,10 @@ void testPDFBox4338()
309277 @ Test
310278 void testPDFBox4339 ()
311279 {
312- try
280+ assertDoesNotThrow (() ->
313281 {
314282 Loader .loadPDF (new File (TARGETPDFDIR , "PDFBOX-4339.pdf" )).close ();
315- }
316- catch (Exception exception )
317- {
318- fail ("Unexpected Exception" );
319- }
283+ });
320284 }
321285
322286 /**
0 commit comments