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 fa4eba3ff2c1a4487749c267696a8cb6006f5b1a Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Sat Jan 24 19:21:29 2026 +0000 CAMEL-21196: modernize exception-based assertions in camel-jdbc Replace try-catch-fail pattern with assertThrows in JdbcOptionsTest. --- .../org/apache/camel/component/jdbc/JdbcOptionsTest.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcOptionsTest.java b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcOptionsTest.java index 63cf430d9599..ab20a459e3fb 100644 --- a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcOptionsTest.java +++ b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcOptionsTest.java @@ -27,8 +27,8 @@ import org.apache.camel.component.mock.MockEndpoint; 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 JdbcOptionsTest extends AbstractJdbcTestSupport { @@ -76,13 +76,11 @@ public class JdbcOptionsTest extends AbstractJdbcTestSupport { @Test public void testNoDataSourceInRegistry() { - try { - template.sendBody("jdbc:xxx", "Hello World"); - fail("Should have thrown a ResolveEndpointFailedException"); - } catch (ResolveEndpointFailedException e) { - assertEquals("No bean could be found in the registry for: xxx of type: javax.sql.DataSource", - e.getCause().getMessage()); - } + ResolveEndpointFailedException e = assertThrows(ResolveEndpointFailedException.class, + () -> template.sendBody("jdbc:xxx", "Hello World"), + "Should have thrown a ResolveEndpointFailedException"); + assertEquals("No bean could be found in the registry for: xxx of type: javax.sql.DataSource", + e.getCause().getMessage()); } @Test
