You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2026/01/25 14:04:38 UTC
(camel) 24/36: CAMEL-21196: modernize exception-based assertions in camel-hazelcast
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 1683285ee7cab84c9ba1475d44add205c63ccaf8
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Sat Jan 24 19:39:54 2026 +0000
CAMEL-21196: modernize exception-based assertions in camel-hazelcast
---
.../hazelcast/HazelcastErrorMessagesTest.java | 22 +++++++++-------------
.../hazelcast/HazelcastSedaConfigurationTest.java | 10 ++++------
2 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
index fd91d1196c2e..0eaa19609fdd 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.hazelcast;
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;
+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 HazelcastErrorMessagesTest extends HazelcastCamelTestSupport {
@@ -31,14 +31,12 @@ public class HazelcastErrorMessagesTest extends HazelcastCamelTestSupport {
from("hazelcast-atomicvalue:foo").to("seda:out");
}
};
- try {
+ Exception e = assertThrows(Exception.class, () -> {
context.addRoutes(builder);
context.start();
- fail("Should have thrown exception");
- } catch (Exception e) {
- assertTrue(e.getCause().getMessage()
- .contains("You cannot send messages to this endpoint: hazelcast-atomicvalue://foo"));
- }
+ });
+ assertTrue(e.getCause().getMessage()
+ .contains("You cannot send messages to this endpoint: hazelcast-atomicvalue://foo"));
}
@Test
@@ -49,14 +47,12 @@ public class HazelcastErrorMessagesTest extends HazelcastCamelTestSupport {
}
};
- try {
+ Exception e = assertThrows(Exception.class, () -> {
context.addRoutes(builder);
context.start();
- fail("Should have thrown exception");
- } catch (Exception e) {
- assertTrue(
- e.getCause().getMessage().contains("You cannot send messages to this endpoint: hazelcast-instance://foo"));
- }
+ });
+ assertTrue(
+ e.getCause().getMessage().contains("You cannot send messages to this endpoint: hazelcast-instance://foo"));
}
@Override
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastSedaConfigurationTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastSedaConfigurationTest.java
index 30d13fd77429..b1d43a68ccef 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastSedaConfigurationTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastSedaConfigurationTest.java
@@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test;
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;
public class HazelcastSedaConfigurationTest extends CamelTestSupport {
@@ -91,12 +91,10 @@ public class HazelcastSedaConfigurationTest extends CamelTestSupport {
@Test
public void createEndpointWithIllegalOnErrorDelayParam() throws Exception {
- try {
+ ResolveEndpointFailedException e = assertThrows(ResolveEndpointFailedException.class, () -> {
context.getEndpoint("hazelcast-seda:foo?onErrorDelay=-1");
- fail("Should have thrown exception");
- } catch (ResolveEndpointFailedException e) {
- assertIsInstanceOf(PropertyBindingException.class, e.getCause());
- }
+ });
+ assertIsInstanceOf(PropertyBindingException.class, e.getCause());
}
}