Skip to content

Commit f9b9d9b

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

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import static org.junit.jupiter.api.Assertions.assertNull;
3535
import static org.junit.jupiter.api.Assertions.assertThrows;
3636
import static org.junit.jupiter.api.Assertions.assertTrue;
37-
import static org.junit.jupiter.api.Assertions.fail;
3837
import org.junit.jupiter.api.BeforeAll;
3938
import 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
}

pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.pdfbox.io.RandomAccessReadBuffer;
2727
import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
2828

29+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
2930
import static org.junit.jupiter.api.Assertions.assertEquals;
3031
import static org.junit.jupiter.api.Assertions.assertNull;
3132
import 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

pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
2525
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
2626
import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
27+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
2728
import static org.junit.jupiter.api.Assertions.assertEquals;
2829

2930
import 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();

0 commit comments

Comments
 (0)