This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 3a6c734cc85 CAMEL-21417: Fix JettySessionSupportTest (#16201)
3a6c734cc85 is described below

commit 3a6c734cc859b112318844e9cb66a4f364f5e37f
Author: Adriano Machado <[email protected]>
AuthorDate: Sat Nov 9 10:07:53 2024 +0100

    CAMEL-21417: Fix JettySessionSupportTest (#16201)
    
    * CAMEL-21417 - Fix JettySessionSupportTest
    
    * CAMEL-21417 - Fix JettySessionSupportTest's formatting
    
    * CAMEL-21417 - Fix JettySessionSupportTest's formatting
---
 .../component/jetty/JettySessionSupportTest.java   | 35 +++++++++++-----------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySessionSupportTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySessionSupportTest.java
index d93a0fdf006..c07176de973 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySessionSupportTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySessionSupportTest.java
@@ -17,43 +17,42 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-@Disabled(value = "Broken test CAMEL-21417")
-public class JettySessionSupportTest extends BaseJettyTest {
+class JettySessionSupportTest extends BaseJettyTest {
 
-    @Override
-    public boolean isUseRouteBuilder() {
-        return false;
+    @BeforeEach
+    void setup() {
+        testConfigurationBuilder.withUseRouteBuilder(false);
     }
 
     @Test
-    public void testJettySessionSupportInvalid() throws Exception {
-        context.addRoutes(new RouteBuilder() {
+    void testJettySessionSupportInvalid() {
+        RouteBuilder routeBuilder = new RouteBuilder() {
             @Override
             public void configure() {
                 from("jetty:http://localhost:{{port}}/hello";).to("mock:foo");
 
                 
from("jetty:http://localhost:{{port}}/bye?sessionSupport=true";).to("mock:bar");
             }
-        });
-        try {
-            context.start();
-            fail("Should have thrown an exception");
-        } catch (IllegalStateException e) {
-            assertEquals("Server has already been started. Cannot enabled 
sessionSupport on http:localhost:" + getPort(),
-                    e.getMessage());
-        } finally {
+        };
+
+        assertThrows(
+                IllegalStateException.class,
+                () -> context.addRoutes(routeBuilder),
+                "Server has already been started. Cannot enabled 
sessionSupport on http:localhost:%d".formatted(getPort()));
+
+        if (context.isStarted()) {
             context.stop();
         }
     }
 
     @Test
-    public void testJettySessionSupportOk() throws Exception {
+    void testJettySessionSupportOk() throws Exception {
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() {

Reply via email to