Author: tilman
Date: Mon Oct 27 12:03:59 2025
New Revision: 1929363

Log:
PDFBOX-5660: sonar fix: use specific exceptions

Modified:
   
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java
   
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
   
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java
   
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java
   
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java
   
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestValidatePermitedMetadata.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithDefinedSchemas.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithUndefinedSchemas.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationTest.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPBasicTest.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPMediaManagementTest.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XmpRightsSchemaTest.java

Modified: 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java
==============================================================================
--- 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java
   Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestInvalidDirectory.java
   Mon Oct 27 12:03:59 2025        (r1929363)
@@ -24,6 +24,7 @@ package org.apache.pdfbox.preflight;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -36,7 +37,7 @@ class TestInvalidDirectory
 {
     @ParameterizedTest
     @MethodSource("initializeParameters")
-    void validate(File target) throws Exception
+    void validate(File target) throws IOException
     {
         if (target != null)
         {
@@ -46,7 +47,7 @@ class TestInvalidDirectory
         }
     }
 
-    public static Collection<File> initializeParameters() throws Exception
+    public static Collection<File> initializeParameters() throws IOException
     {
         // check directory
         File directory = null;
@@ -59,9 +60,13 @@ class TestInvalidDirectory
         {
             directory = new File(pdfPath);
             if (!directory.exists())
-                throw new Exception("directory does not exists : " + 
directory.getAbsolutePath());
+            {
+                throw new IOException("directory does not exists : " + 
directory.getAbsolutePath());
+            }
             if (!directory.isDirectory())
-                throw new Exception("not a directory : " + 
directory.getAbsolutePath());
+            {
+                throw new IOException("not a directory : " + 
directory.getAbsolutePath());
+            }
         }
         else
         {

Modified: 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
==============================================================================
--- 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
     Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
     Mon Oct 27 12:03:59 2025        (r1929363)
@@ -28,6 +28,7 @@ import static org.junit.jupiter.api.Asse
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -52,7 +53,7 @@ class TestIsartorBavaria
     private static final String SKIP_BAVARIA = "skip-bavaria";
     private static FileOutputStream isartorResultFile;
 
-    public static Collection<Object[]> initializeParameters() throws Exception
+    public static Collection<Object[]> initializeParameters() throws 
IOException
     {
         String filter = System.getProperty(FILTER_FILE);
         String skipBavaria = System.getProperty(SKIP_BAVARIA);

Modified: 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java
==============================================================================
--- 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java
     Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestValidDirectory.java
     Mon Oct 27 12:03:59 2025        (r1929363)
@@ -24,6 +24,7 @@ package org.apache.pdfbox.preflight;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -36,7 +37,7 @@ class TestValidDirectory
 {
     @ParameterizedTest
     @MethodSource("initializeParameters")
-    void validate(File target) throws Exception
+    void validate(File target) throws IOException
     {
         if (target != null)
         {
@@ -46,7 +47,7 @@ class TestValidDirectory
         }
     }
 
-    public static Collection<File> initializeParameters() throws Exception
+    public static Collection<File> initializeParameters() throws IOException
     {
         // check directory
         File directory = null;
@@ -59,9 +60,13 @@ class TestValidDirectory
         {
             directory = new File(pdfPath);
             if (!directory.exists())
-                throw new Exception("directory does not exists : " + 
directory.getAbsolutePath());
+            {
+                throw new IOException("directory does not exists : " + 
directory.getAbsolutePath());
+            }
             if (!directory.isDirectory())
-                throw new Exception("not a directory : " + 
directory.getAbsolutePath());
+            {
+                throw new IOException("not a directory : " + 
directory.getAbsolutePath());
+            }
         }
         else
         {

Modified: 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java
==============================================================================
--- 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java
   Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java
   Mon Oct 27 12:03:59 2025        (r1929363)
@@ -23,6 +23,7 @@ package org.apache.pdfbox.preflight.inte
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -67,19 +68,19 @@ class TestInvalidFiles
 
     @ParameterizedTest
        @MethodSource("initializeParameters")
-    void validate(File path, String expectedError) throws Exception
+    void validate(File path, String expectedError) throws IOException
     {
         tester.validate(path, expectedError);
     }
 
-    protected static Collection<Arguments> stopIfExpected() throws Exception
+    protected static Collection<Arguments> stopIfExpected()
     {
         List<Arguments> ret = new ArrayList<>();
         ret.add(Arguments.of(null, null));
         return ret;
     }
 
-    public static Collection<Arguments> initializeParameters() throws Exception
+    public static Collection<Arguments> initializeParameters() throws 
IOException
     {
         // find isartor files
         String isartor = System.getProperty(ISARTOR_FILES);

Modified: 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java
==============================================================================
--- 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java
      Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java
      Mon Oct 27 12:03:59 2025        (r1929363)
@@ -23,6 +23,8 @@ package org.apache.pdfbox.preflight.inte
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -54,32 +56,32 @@ class TestIsartorValidation
     private static InvalidFileTester tester;
 
     @BeforeAll
-    static void setup() throws Exception
+    static void setup() throws FileNotFoundException
     {
         tester = new InvalidFileTester(RESULTS_FILE);
     }
 
     @AfterAll
-    static void closeDown() throws Exception
+    static void closeDown()
     {
         tester.after();
     }
 
     @ParameterizedTest
        @MethodSource("initializeParameters")
-    void validate(File path, String expectedError) throws Exception
+    void validate(File path, String expectedError) throws IOException
     {
         tester.validate(path, expectedError);
     }
 
-    protected static Collection<Arguments> stopIfExpected() throws Exception
+    protected static Collection<Arguments> stopIfExpected()
     {
         List<Arguments> ret = new ArrayList<>();
         ret.add(Arguments.of(null, null));
         return ret;
     }
 
-    public static Collection<Arguments> initializeParameters() throws Exception
+    public static Collection<Arguments> initializeParameters() throws 
IOException
     {
         // find isartor files
         String isartor = System.getProperty(ISARTOR_FILES);

Modified: 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
==============================================================================
--- 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
     Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
     Mon Oct 27 12:03:59 2025        (r1929363)
@@ -26,7 +26,9 @@ import static org.junit.jupiter.api.Asse
  ****************************************************************************/
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -58,7 +60,7 @@ class TestValidFiles
 
     protected Log logger = null;
 
-    protected static Collection<File> stopIfExpected() throws Exception
+    protected static Collection<File> stopIfExpected()
     {
         // throw new Exception("Test badly configured");
         List<File> ret = new ArrayList<>();
@@ -66,7 +68,7 @@ class TestValidFiles
         return ret;
     }
 
-    public static Collection<File> initializeParameters() throws Exception
+    public static Collection<File> initializeParameters()
     {
         // find isartor files
         String isartor = System.getProperty(ISARTOR_FILES);
@@ -90,7 +92,7 @@ class TestValidFiles
     }
 
     @BeforeAll
-    static void beforeClass() throws Exception
+    static void beforeClass() throws FileNotFoundException
     {
         String irp = System.getProperty(RESULTS_FILE);
         if (irp == null)
@@ -106,14 +108,14 @@ class TestValidFiles
     }
 
     @AfterAll
-    static void afterClass() throws Exception
+    static void afterClass()
     {
         IOUtils.closeQuietly(isartorResultFile);
     }
 
     @ParameterizedTest
     @MethodSource("initializeParameters")
-    void validate(File path) throws Exception
+    void validate(File path) throws IOException
     {
         logger = LogFactory.getLog(path != null ? path.getName() : "dummy");
         if (path == null)

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestValidatePermitedMetadata.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestValidatePermitedMetadata.java
        Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestValidatePermitedMetadata.java
        Mon Oct 27 12:03:59 2025        (r1929363)
@@ -33,6 +33,7 @@ import static org.junit.jupiter.api.Asse
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.lang.reflect.Field;
@@ -44,7 +45,7 @@ import java.util.List;
 class TestValidatePermitedMetadata
 {
 
-    static Collection<Object[]> initializeParameters() throws Exception
+    static Collection<Object[]> initializeParameters() throws IOException
     {
         List<Object[]> params = new ArrayList<>();
         InputStream is =  
TestValidatePermitedMetadata.class.getResourceAsStream("/permited_metadata.txt");

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithDefinedSchemas.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithDefinedSchemas.java
   Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithDefinedSchemas.java
   Mon Oct 27 12:03:59 2025        (r1929363)
@@ -27,12 +27,13 @@ import java.io.InputStream;
 import java.util.stream.Stream;
 
 import org.apache.xmpbox.xml.DomXmpParser;
+import org.apache.xmpbox.xml.XmpParsingException;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.MethodSource;
 
 class TestXMPWithDefinedSchemas
 {
-    static Stream<String> initializeParameters() throws Exception
+    static Stream<String> initializeParameters()
     {
         return Stream.of(
             "/validxmp/override_ns.rdf",
@@ -45,7 +46,7 @@ class TestXMPWithDefinedSchemas
 
     @ParameterizedTest
     @MethodSource("initializeParameters")
-    void main(String path) throws Exception
+    void main(String path) throws XmpParsingException
     {
         InputStream is = this.getClass().getResourceAsStream(path);
 

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithUndefinedSchemas.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithUndefinedSchemas.java
 Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithUndefinedSchemas.java
 Mon Oct 27 12:03:59 2025        (r1929363)
@@ -37,7 +37,7 @@ import org.junit.jupiter.params.provider
 
 class TestXMPWithUndefinedSchemas
 {
-    static Stream<Arguments> initializeParameters() throws Exception
+    static Stream<Arguments> initializeParameters()
     {
         return Stream.of(
             Arguments.of("/undefinedxmp/prism.xmp", 
"http://prismstandard.org/namespaces/basic/2.0/";, "aggregationType", "journal")

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationTest.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationTest.java
       Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationTest.java
       Mon Oct 27 12:03:59 2025        (r1929363)
@@ -61,7 +61,7 @@ class PDFAIdentificationTest
         xmpSchemaTester.testGetSetProperty();
     }
 
-    static Stream<Arguments> initializeParameters() throws Exception
+    static Stream<Arguments> initializeParameters()
     {
         return Stream.of(
             Arguments.of("part", 
XMPSchemaTester.createPropertyType(Types.Integer), 1),

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPBasicTest.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPBasicTest.java
 Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPBasicTest.java
 Mon Oct 27 12:03:59 2025        (r1929363)
@@ -63,7 +63,7 @@ class XMPBasicTest
         xmpSchemaTester.testGetSetProperty();
     }
 
-    static Stream<Arguments> initializeParameters() throws Exception
+    static Stream<Arguments> initializeParameters()
     {
         return Stream.of(
             Arguments.of("Advisory", 
XMPSchemaTester.createPropertyType(Types.XPath, Cardinality.Bag), new String[] 
{ "xpath1", "xpath2" }),

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPMediaManagementTest.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPMediaManagementTest.java
       Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPMediaManagementTest.java
       Mon Oct 27 12:03:59 2025        (r1929363)
@@ -62,7 +62,7 @@ class XMPMediaManagementTest
         xmpSchemaTester.testGetSetProperty();
     }
 
-    static Stream<Arguments> initializeParameters() throws Exception
+    static Stream<Arguments> initializeParameters()
     {
         return Stream.of(
             Arguments.of("DocumentID", 
XMPSchemaTester.createPropertyType(Types.URI), 
"uuid:FB031973-5E75-11B2-8F06-E7F5C101C07A"),

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XmpRightsSchemaTest.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XmpRightsSchemaTest.java
  Mon Oct 27 12:03:41 2025        (r1929362)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XmpRightsSchemaTest.java
  Mon Oct 27 12:03:59 2025        (r1929363)
@@ -64,7 +64,7 @@ class XmpRightsSchemaTest
         xmpSchemaTester.testGetSetProperty();
     }
 
-    static Stream<Arguments> initializeParameters() throws Exception
+    static Stream<Arguments> initializeParameters()
     {
         Map<String, String> desc = new HashMap<>(2);
         desc.put("fr", "Termes d'utilisation");

Reply via email to