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 0caedf5964722821eb307648cf559afe00b60c19 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Fri Apr 12 11:31:43 2024 +0200 (chores) camel-core: modernized throw-based assertions --- .../apache/camel/ThreadPoolRejectedPolicyTest.java | 11 +++++----- .../apache/camel/model/RoutePropertiesTest.java | 25 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java b/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java index c55178355a0..d43c206a0ed 100644 --- a/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java @@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.camel.util.concurrent.Rejectable; import org.apache.camel.util.concurrent.RejectableThreadPoolExecutor; import org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -35,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.*; public class ThreadPoolRejectedPolicyTest extends TestSupport { @Test - public void testAbortAsRejectedExecutionHandler() throws InterruptedException { + public void testAbortAsRejectedExecutionHandler() { final ExecutorService executorService = createTestExecutorService(ThreadPoolRejectedPolicy.Abort.asRejectedExecutionHandler()); @@ -45,11 +46,9 @@ public class ThreadPoolRejectedPolicyTest extends TestSupport { final MockRunnable task2 = new MockRunnable(); final Future<?> result2 = executorService.submit(task2); final MockCallable<String> task3 = new MockCallable<>(); - try { - executorService.submit(task3); - fail("Third task should have been rejected by a threadpool is full with 1 task and queue is full with 1 task."); - } catch (RejectedExecutionException e) { - } + + Assertions.assertThrows(RejectedExecutionException.class, () -> executorService.submit(task3), + "Third task should have been rejected by a threadpool is full with 1 task and queue is full with 1 task."); shutdownAndAwait(executorService); diff --git a/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java b/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java index d5c989ad749..91eb9585463 100644 --- a/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java @@ -17,8 +17,11 @@ package org.apache.camel.model; import org.apache.camel.ContextTestSupport; +import org.apache.camel.FailedToCreateRouteException; import org.apache.camel.Route; import org.apache.camel.builder.RouteBuilder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -53,20 +56,18 @@ public class RoutePropertiesTest extends ContextTestSupport { assertEquals("val2", route.getProperties().get("key2")); } + @DisplayName("Checks that trying to use a reserved property leads to failure") @Test - public void testRoutePropertiesFailuer() throws Exception { - try { - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start").routeId("route-id").routeProperty(Route.ID_PROPERTY, "the id").to("mock:output"); - } - }); + public void testRoutePropertiesFailure() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:start").routeId("route-id").routeProperty(Route.ID_PROPERTY, "the id").to("mock:output"); + } + }); - context.start(); + Assertions.assertThrows(FailedToCreateRouteException.class, () -> context.start(), + "Should have prevented setting a property with a reserved name"); - fail(""); - } catch (Exception e) { - } } }