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 3c44341732fce3435c52ccbd4c68c436fdf43d1b
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 19:46:03 2026 +0000

    CAMEL-21196: modernize exception-based assertions in camel-protobuf
    
    Replace try-catch-fail patterns with assertThrows in:
    - ProtobufMarshalAndUnmarshalSpringTest.java (1 occurrence)
    - ProtobufMarshalAndUnmarshalTest.java (1 occurrence)
---
 .../protobuf/ProtobufMarshalAndUnmarshalSpringTest.java        | 10 ++++------
 .../dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java   | 10 ++++------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git 
a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
 
b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
index cf8053189415..22f3f4002a70 100644
--- 
a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
+++ 
b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
@@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 public class ProtobufMarshalAndUnmarshalSpringTest extends 
CamelSpringTestSupport {
 
@@ -54,17 +54,15 @@ public class ProtobufMarshalAndUnmarshalSpringTest extends 
CamelSpringTestSuppor
 
     @Test
     public void testMarshalAndUnmarshalWithDSL3() {
-        try {
+        Exception ex = assertThrows(Exception.class, () -> {
             context.addRoutes(new RouteBuilder() {
                 @Override
                 public void configure() {
                     from("direct:unmarshalC").unmarshal().protobuf(new 
CamelException("wrong instance")).to("mock:reverse");
                 }
             });
-            fail("Expect the exception here");
-        } catch (Exception ex) {
-            assertTrue(ex instanceof FailedToCreateRouteException, "Expect 
FailedToCreateRouteException");
-        }
+        });
+        assertTrue(ex instanceof FailedToCreateRouteException, "Expect 
FailedToCreateRouteException");
     }
 
     private void marshalAndUnmarshal(String inURI, String outURI) throws 
Exception {
diff --git 
a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java
 
b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java
index 2b0380d41a75..6ba0700d3a4d 100644
--- 
a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java
+++ 
b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java
@@ -26,8 +26,8 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 public class ProtobufMarshalAndUnmarshalTest extends CamelTestSupport {
 
@@ -48,17 +48,15 @@ public class ProtobufMarshalAndUnmarshalTest extends 
CamelTestSupport {
 
     @Test
     public void testMarshalAndUnmarshalWithDSL3() {
-        try {
+        Exception ex = assertThrows(Exception.class, () -> {
             context.addRoutes(new RouteBuilder() {
                 @Override
                 public void configure() {
                     from("direct:unmarshalC").unmarshal().protobuf(new 
CamelException("wrong instance")).to("mock:reverse");
                 }
             });
-            fail("Expect the exception here");
-        } catch (Exception ex) {
-            assertTrue(ex instanceof FailedToCreateRouteException, "Expect 
FailedToCreateRouteException");
-        }
+        });
+        assertTrue(ex instanceof FailedToCreateRouteException, "Expect 
FailedToCreateRouteException");
     }
 
     private void marshalAndUnmarshal(String inURI, String outURI) throws 
Exception {

Reply via email to