This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4316e3eec043c99d227d5eee4fa49a0bc9febdf1
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 18:38:36 2026 +0000

    CAMEL-21196: modernize exception-based assertions in camel-univocity-parsers
    
    Converted try-catch-fail patterns to JUnit 5 assertThrows in 6 test files:
    - UniVocityCsvDataFormatUnmarshalTest
    - UniVocityCsvDataFormatUnmarshalSpringTest
    - UniVocityFixedDataFormatUnmarshalTest
    - UniVocityFixedDataFormatUnmarshalSpringTest
    - UniVocityTsvDataFormatUnmarshalTest
    - UniVocityTsvDataFormatUnmarshalSpringTest
    
    Replaced fail() import with assertThrows and converted all
    try-catch blocks to lambda-based assertThrows calls.
---
 .../UniVocityCsvDataFormatUnmarshalSpringTest.java       | 16 +++-------------
 .../univocity/UniVocityCsvDataFormatUnmarshalTest.java   | 16 +++-------------
 .../UniVocityFixedDataFormatUnmarshalSpringTest.java     | 16 +++-------------
 .../univocity/UniVocityFixedDataFormatUnmarshalTest.java | 16 +++-------------
 .../UniVocityTsvDataFormatUnmarshalSpringTest.java       | 16 +++-------------
 .../univocity/UniVocityTsvDataFormatUnmarshalTest.java   | 16 +++-------------
 6 files changed, 18 insertions(+), 78 deletions(-)

diff --git 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalSpringTest.java
 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalSpringTest.java
index e3dde7c022c2..14436dd61f21 100644
--- 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalSpringTest.java
+++ 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalSpringTest.java
@@ -33,8 +33,8 @@ import static 
org.apache.camel.dataformat.univocity.UniVocityTestHelper.join;
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 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;
 
 /**
  * This class tests the unmarshalling of {@link 
org.apache.camel.dataformat.univocity.UniVocityCsvDataFormat} using the
@@ -110,12 +110,7 @@ public final class 
UniVocityCsvDataFormatUnmarshalSpringTest extends CamelSpring
         assertEquals(Arrays.asList("A", "B", "C"), body.next());
 
         // Try to remove the element
-        try {
-            body.remove();
-            fail("Should have thrown a UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            // Success
-        }
+        assertThrows(UnsupportedOperationException.class, body::remove);
 
         // Read all the lines
         assertTrue(body.hasNext());
@@ -125,12 +120,7 @@ public final class 
UniVocityCsvDataFormatUnmarshalSpringTest extends CamelSpring
         assertFalse(body.hasNext());
 
         // Try to read one more element
-        try {
-            body.next();
-            fail("Should have thrown a NoSuchElementException");
-        } catch (NoSuchElementException e) {
-            // Success
-        }
+        assertThrows(NoSuchElementException.class, body::next);
     }
 
     /**
diff --git 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalTest.java
 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalTest.java
index 0759cc6b9d5c..b9c503c04270 100644
--- 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalTest.java
+++ 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityCsvDataFormatUnmarshalTest.java
@@ -35,8 +35,8 @@ import static 
org.apache.camel.dataformat.univocity.UniVocityTestHelper.join;
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 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;
 
 /**
  * This class tests the unmarshalling of {@link 
org.apache.camel.dataformat.univocity.UniVocityCsvDataFormat} using the
@@ -112,12 +112,7 @@ public final class UniVocityCsvDataFormatUnmarshalTest 
extends CamelTestSupport
         assertEquals(Arrays.asList("A", "B", "C"), body.next());
 
         // Try to remove the element
-        try {
-            body.remove();
-            fail("Should have thrown a UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            // Success
-        }
+        assertThrows(UnsupportedOperationException.class, body::remove);
 
         // Read all the lines
         assertTrue(body.hasNext());
@@ -127,12 +122,7 @@ public final class UniVocityCsvDataFormatUnmarshalTest 
extends CamelTestSupport
         assertFalse(body.hasNext());
 
         // Try to read one more element
-        try {
-            body.next();
-            fail("Should have thrown a NoSuchElementException");
-        } catch (NoSuchElementException e) {
-            // Success
-        }
+        assertThrows(NoSuchElementException.class, body::next);
     }
 
     /**
diff --git 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalSpringTest.java
 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalSpringTest.java
index 1433615e4e16..9ea29a02e539 100644
--- 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalSpringTest.java
+++ 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalSpringTest.java
@@ -33,8 +33,8 @@ import static 
org.apache.camel.dataformat.univocity.UniVocityTestHelper.join;
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 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;
 
 /**
  * This class tests the unmarshalling of {@link UniVocityFixedDataFormat} 
using the Spring DSL.
@@ -109,12 +109,7 @@ public final class 
UniVocityFixedDataFormatUnmarshalSpringTest extends CamelSpri
         assertEquals(Arrays.asList("A", "B", "C"), body.next());
 
         // Try to remove the element
-        try {
-            body.remove();
-            fail("Should have thrown a UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            // Success
-        }
+        assertThrows(UnsupportedOperationException.class, body::remove);
 
         // Read all the lines
         assertTrue(body.hasNext());
@@ -124,12 +119,7 @@ public final class 
UniVocityFixedDataFormatUnmarshalSpringTest extends CamelSpri
         assertFalse(body.hasNext());
 
         // Try to read one more element
-        try {
-            body.next();
-            fail("Should have thrown a NoSuchElementException");
-        } catch (NoSuchElementException e) {
-            // Success
-        }
+        assertThrows(NoSuchElementException.class, body::next);
     }
 
     /**
diff --git 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalTest.java
 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalTest.java
index cc73e718d95e..8122159c3549 100644
--- 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalTest.java
+++ 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatUnmarshalTest.java
@@ -35,8 +35,8 @@ import static 
org.apache.camel.dataformat.univocity.UniVocityTestHelper.join;
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 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;
 
 /**
  * This class tests the unmarshalling of {@link UniVocityFixedDataFormat}.
@@ -111,12 +111,7 @@ public final class UniVocityFixedDataFormatUnmarshalTest 
extends CamelTestSuppor
         assertEquals(Arrays.asList("A", "B", "C"), body.next());
 
         // Try to remove the element
-        try {
-            body.remove();
-            fail("Should have thrown a UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            // Success
-        }
+        assertThrows(UnsupportedOperationException.class, body::remove);
 
         // Read all the lines
         assertTrue(body.hasNext());
@@ -126,12 +121,7 @@ public final class UniVocityFixedDataFormatUnmarshalTest 
extends CamelTestSuppor
         assertFalse(body.hasNext());
 
         // Try to read one more element
-        try {
-            body.next();
-            fail("Should have thrown a NoSuchElementException");
-        } catch (NoSuchElementException e) {
-            // Success
-        }
+        assertThrows(NoSuchElementException.class, body::next);
     }
 
     /**
diff --git 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalSpringTest.java
 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalSpringTest.java
index 991a0730a862..ad0c032f177a 100644
--- 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalSpringTest.java
+++ 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalSpringTest.java
@@ -33,8 +33,8 @@ import static 
org.apache.camel.dataformat.univocity.UniVocityTestHelper.join;
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 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;
 
 /**
  * This class tests the unmarshalling of {@link 
org.apache.camel.dataformat.univocity.UniVocityTsvDataFormat} using the
@@ -110,12 +110,7 @@ public final class 
UniVocityTsvDataFormatUnmarshalSpringTest extends CamelSpring
         assertEquals(Arrays.asList("A", "B", "C"), body.next());
 
         // Try to remove the element
-        try {
-            body.remove();
-            fail("Should have thrown a UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            // Success
-        }
+        assertThrows(UnsupportedOperationException.class, body::remove);
 
         // Read all the lines
         assertTrue(body.hasNext());
@@ -125,12 +120,7 @@ public final class 
UniVocityTsvDataFormatUnmarshalSpringTest extends CamelSpring
         assertFalse(body.hasNext());
 
         // Try to read one more element
-        try {
-            body.next();
-            fail("Should have thrown a NoSuchElementException");
-        } catch (NoSuchElementException e) {
-            // Success
-        }
+        assertThrows(NoSuchElementException.class, body::next);
     }
 
     /**
diff --git 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalTest.java
 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalTest.java
index b1c886e5f4dd..984209eecf32 100644
--- 
a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalTest.java
+++ 
b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityTsvDataFormatUnmarshalTest.java
@@ -35,8 +35,8 @@ import static 
org.apache.camel.dataformat.univocity.UniVocityTestHelper.join;
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 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;
 
 /**
  * This class tests the unmarshalling of {@link 
org.apache.camel.dataformat.univocity.UniVocityTsvDataFormat}.
@@ -111,12 +111,7 @@ public final class UniVocityTsvDataFormatUnmarshalTest 
extends CamelTestSupport
         assertEquals(Arrays.asList("A", "B", "C"), body.next());
 
         // Try to remove the element
-        try {
-            body.remove();
-            fail("Should have thrown a UnsupportedOperationException");
-        } catch (UnsupportedOperationException e) {
-            // Success
-        }
+        assertThrows(UnsupportedOperationException.class, body::remove);
 
         // Read all the lines
         assertTrue(body.hasNext());
@@ -126,12 +121,7 @@ public final class UniVocityTsvDataFormatUnmarshalTest 
extends CamelTestSupport
         assertFalse(body.hasNext());
 
         // Try to read one more element
-        try {
-            body.next();
-            fail("Should have thrown a NoSuchElementException");
-        } catch (NoSuchElementException e) {
-            // Success
-        }
+        assertThrows(NoSuchElementException.class, body::next);
     }
 
     /**

Reply via email to