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 f14d1151a3375b3565e70f1b1b86c955f4bdda5c Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Sat Jan 24 18:21:44 2026 +0000 CAMEL-21196: modernize exception-based assertions in camel-crypto Convert try-catch-fail patterns to JUnit 5 assertThrows in CryptoDataFormatTest. Replaced legacy fail() with assertThrows() for cleaner and more idiomatic exception testing. --- .../apache/camel/converter/crypto/CryptoDataFormatTest.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java index cb738b783e24..2e91db904324 100644 --- a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java +++ b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java @@ -40,8 +40,8 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotSame; +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 CryptoDataFormatTest extends CamelTestSupport { @@ -131,12 +131,10 @@ public class CryptoDataFormatTest extends CamelTestSupport { @Test void testNoAlgorithm() throws Exception { - try { - doRoundTripEncryptionTests("direct:no-algorithm"); - fail("Failure expected on no algorithm specified"); - } catch (CamelExecutionException ex) { - assertTrue(ex.getCause() instanceof NoSuchAlgorithmException); - } + CamelExecutionException ex = assertThrows(CamelExecutionException.class, + () -> doRoundTripEncryptionTests("direct:no-algorithm"), + "Failure expected on no algorithm specified"); + assertTrue(ex.getCause() instanceof NoSuchAlgorithmException); } private void validateHeaderIsCleared(Exchange ex) {
