Author: tilman
Date: Mon Jun 15 11:02:54 2026
New Revision: 1935342
Log:
PDFBOX-5660: Sonar fix
Modified:
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCodespaceRange.java
Modified:
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java
==============================================================================
---
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java
Mon Jun 15 10:06:12 2026 (r1935341)
+++
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java
Mon Jun 15 11:02:54 2026 (r1935342)
@@ -18,11 +18,11 @@
package org.apache.fontbox.afm;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
import java.util.List;
import org.apache.fontbox.util.BoundingBox;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class CharMetricTest
@@ -84,14 +84,6 @@ class CharMetricTest
List<Ligature> ligatures = charMetric.getLigatures();
assertEquals(1, ligatures.size());
assertEquals("successor", ligatures.get(0).getSuccessor());
- try
- {
- ligatures.add(ligature);
- fail("An UnsupportedOperationException should have been thrown");
- }
- catch (UnsupportedOperationException exception)
- {
- // do nothing
- }
+ assertThrows(UnsupportedOperationException.class, () ->
ligatures.add(ligature));
}
}
Modified:
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java
==============================================================================
---
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java
Mon Jun 15 10:06:12 2026 (r1935341)
+++
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java
Mon Jun 15 11:02:54 2026 (r1935342)
@@ -18,7 +18,7 @@
package org.apache.fontbox.afm;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.List;
@@ -37,14 +37,6 @@ class CompositeTest
List<CompositePart> parts = composite.getParts();
assertEquals(1, parts.size());
assertEquals("name", parts.get(0).getName());
- try
- {
- parts.add(compositePart);
- fail("An UnsupportedOperationException should have been thrown");
- }
- catch (UnsupportedOperationException exception)
- {
- // do nothing
- }
+ assertThrows(UnsupportedOperationException.class, () ->
parts.add(compositePart));
}
}
Modified:
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCodespaceRange.java
==============================================================================
---
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCodespaceRange.java
Mon Jun 15 10:06:12 2026 (r1935341)
+++
pdfbox/branches/3.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCodespaceRange.java
Mon Jun 15 11:02:54 2026 (r1935342)
@@ -18,8 +18,8 @@ package org.apache.fontbox.cmap;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
@@ -61,15 +61,8 @@ class TestCodespaceRange
// other cases of different lengths are not
byte[] startBytes3 = new byte[] { 0x01 };
byte[] endBytes4 = new byte[] { 0x01, 0x20 };
- try
- {
- new CodespaceRange(startBytes3, endBytes4);
- fail("The constructor should have thrown an
IllegalArgumentException exception.");
- }
- catch (IllegalArgumentException exception)
- {
- // everything is fine as the expected exception is thrown
- }
+
+ assertThrows(IllegalArgumentException.class, () -> new
CodespaceRange(startBytes3, endBytes4));
}
@Test