Skip to content

Commit b1f4460

Browse files
committed
PDFBOX-5660: Sonar fix
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1935300 13f79535-47bb-0310-9956-ffa450edef68
1 parent 40094b4 commit b1f4460

1 file changed

Lines changed: 18 additions & 54 deletions

File tree

pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
package org.apache.pdfbox.pdfparser;
1919

2020
import static org.junit.jupiter.api.Assertions.assertEquals;
21-
import static org.junit.jupiter.api.Assertions.fail;
2221

2322
import java.io.File;
2423
import java.io.IOException;
25-
import java.net.URISyntaxException;
2624

2725
import org.apache.pdfbox.Loader;
2826
import org.apache.pdfbox.cos.COSName;
@@ -33,25 +31,20 @@
3331
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;
3432
import org.apache.pdfbox.rendering.PDFRenderer;
3533
import org.apache.pdfbox.util.DateConverter;
34+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
3635
import org.junit.jupiter.api.Test;
3736

3837
class 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

Comments
 (0)