Author: tilman
Date: Sun Jun 14 09:18:20 2026
New Revision: 1935281

Log:
PDFBOX-5660: Sonar fix

Modified:
   pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java

Modified: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java  
Sun Jun 14 09:17:50 2026        (r1935280)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java  
Sun Jun 14 09:18:20 2026        (r1935281)
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Asse
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
 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 java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -88,23 +87,18 @@ class TestCOSString extends TestCOSBase
 
     /**
      * Test parseHex() - tests that the proper String is created from a hex 
string input.
+     * 
+     * @throws IOException
      */
     @Test
-    void testFromHex()
+    void testFromHex() throws IOException
     {
         String expected = "Quick and simple test";
         String hexForm = createHex(expected);
-        try
-        {
-            COSString test1 = COSString.parseHex(hexForm);
-            writePDFTests("(" + expected + ")", test1);
-            COSString test2 = COSString.parseHex(createHex(ESC_CHAR_STRING));
-            writePDFTests("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", test2);
-        }
-        catch (IOException e)
-        {
-            fail("IOException thrown: " + e.getMessage());
-        }
+        COSString test1 = COSString.parseHex(hexForm);
+        writePDFTests("(" + expected + ")", test1);
+        COSString test2 = COSString.parseHex(createHex(ESC_CHAR_STRING));
+        writePDFTests("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", test2);
         assertThrows(IOException.class, () -> COSString.parseHex(hexForm + 
"xx"),
                 "Should have thrown an IOException here");
     }
@@ -137,30 +131,25 @@ class TestCOSString extends TestCOSBase
 
     /**
      * Test testGetString() - ensure getString() are returned in the correct 
format.
+     * 
+     * @throws IOException
      */
     @Test
-    void testGetString()
+    void testGetString() throws IOException
     {
-        try
-        {
-            String testStr = "Test subject for getString()";
-            COSString test1 = new COSString(testStr);
-            assertEquals(testStr, test1.getString());
-
-            COSString hexStr = COSString.parseHex(createHex(testStr));
-            assertEquals(testStr, hexStr.getString());
-
-            COSString escapedString = new COSString(ESC_CHAR_STRING);
-            assertEquals(ESC_CHAR_STRING, escapedString.getString());
-
-            testStr = "Line1\nLine2\nLine3\n";
-            COSString lineFeedString = new COSString(testStr);
-            assertEquals(testStr, lineFeedString.getString());
-        }
-        catch (IOException e)
-        {
-            fail("IOException thrown: " + e.getMessage());
-        }
+        String testStr = "Test subject for getString()";
+        COSString test1 = new COSString(testStr);
+        assertEquals(testStr, test1.getString());
+
+        COSString hexStr = COSString.parseHex(createHex(testStr));
+        assertEquals(testStr, hexStr.getString());
+
+        COSString escapedString = new COSString(ESC_CHAR_STRING);
+        assertEquals(ESC_CHAR_STRING, escapedString.getString());
+
+        testStr = "Line1\nLine2\nLine3\n";
+        COSString lineFeedString = new COSString(testStr);
+        assertEquals(testStr, lineFeedString.getString());
     }
 
     /**

Reply via email to