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 ebd96328c5d48bb32d946310426ef3073c38b08d
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Jan 17 14:49:17 2023 +0100

    (chores) camel-atmosphere-websocket: fixed a few test cases
    
    Fixed broken tests due to the migration to Jakarta and Jetty 11
---
 .../websocket/WebsocketCamelRouterTestSupport.java          |  7 ++++---
 .../WebsocketCamelRouterWithInitParamTestSupport.java       |  9 +++++----
 .../camel/test/infra/jetty/services/JettyConfiguration.java | 13 ++++---------
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git 
a/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterTestSupport.java
 
b/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterTestSupport.java
index 8414bd69279..a54e4fcac1f 100644
--- 
a/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterTestSupport.java
+++ 
b/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterTestSupport.java
@@ -36,10 +36,11 @@ public abstract class WebsocketCamelRouterTestSupport 
extends CamelTestSupport {
                 .emptyTemplate()
                 .withPort(PORT)
                 .withContextPath(JettyConfiguration.ROOT_CONTEXT_PATH)
-                .withServletConfiguration()
-                .addServletConfiguration(new 
JettyConfiguration.ServletHandlerConfiguration.ServletConfiguration<>(
+                .withWebSocketConfiguration()
+                .addServletConfiguration(new 
JettyConfiguration.WebSocketContextHandlerConfiguration.ServletConfiguration<>(
                         new CamelWebSocketServlet(),
-                        
JettyConfiguration.ServletHandlerConfiguration.ServletConfiguration.ROOT_PATH_SPEC,
 "CamelWsServlet"))
+                        
JettyConfiguration.WebSocketContextHandlerConfiguration.ServletConfiguration.ROOT_PATH_SPEC,
+                        "CamelWsServlet"))
                 .build()
                 .build();
 
diff --git 
a/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterWithInitParamTestSupport.java
 
b/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterWithInitParamTestSupport.java
index 0fe77d55622..ff905693dc3 100644
--- 
a/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterWithInitParamTestSupport.java
+++ 
b/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketCamelRouterWithInitParamTestSupport.java
@@ -32,10 +32,11 @@ public abstract class 
WebsocketCamelRouterWithInitParamTestSupport extends Camel
 
     @BeforeEach
     void setupJetty() {
-        final 
JettyConfiguration.ServletHandlerConfiguration.ServletConfiguration<CamelWebSocketServlet>
 servletConfiguration
-                = new 
JettyConfiguration.ServletHandlerConfiguration.ServletConfiguration<>(
+        final 
JettyConfiguration.WebSocketContextHandlerConfiguration.ServletConfiguration<CamelWebSocketServlet>
 servletConfiguration
+                = new 
JettyConfiguration.WebSocketContextHandlerConfiguration.ServletConfiguration<>(
                         new CamelWebSocketServlet(),
-                        
JettyConfiguration.ServletHandlerConfiguration.ServletConfiguration.ROOT_PATH_SPEC,
 "CamelWsServlet");
+                        
JettyConfiguration.WebSocketContextHandlerConfiguration.ServletConfiguration.ROOT_PATH_SPEC,
+                        "CamelWsServlet");
 
         servletConfiguration.addInitParameter("events", "true");
 
@@ -43,7 +44,7 @@ public abstract class 
WebsocketCamelRouterWithInitParamTestSupport extends Camel
                 .emptyTemplate()
                 .withPort(PORT)
                 .withContextPath(JettyConfiguration.ROOT_CONTEXT_PATH)
-                
.withServletConfiguration().addServletConfiguration(servletConfiguration).build()
+                
.withWebSocketConfiguration().addServletConfiguration(servletConfiguration).build()
                 .build();
 
         service = new JettyEmbeddedService(jettyConfiguration);
diff --git 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
index 3044d8a5816..5c1b43c773e 100644
--- 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
+++ 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
@@ -25,10 +25,9 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.function.Consumer;
 
-import jakarta.servlet.Servlet;
-
 import javax.net.ssl.SSLContext;
 
+import jakarta.servlet.Servlet;
 import org.apache.camel.util.KeyValueHolder;
 import org.eclipse.jetty.security.ConstraintMapping;
 import org.eclipse.jetty.security.ConstraintSecurityHandler;
@@ -45,12 +44,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jetty.util.security.Constraint;
 import org.eclipse.jetty.util.security.Credential;
 import org.eclipse.jetty.webapp.WebAppContext;
-import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest;
-import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse;
-import org.eclipse.jetty.websocket.server.JettyWebSocketCreator;
-import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
-import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory;
-import 
org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
+import 
org.eclipse.jetty.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer;
 
 /**
  * A configuration holder for embedded Jetty instances
@@ -333,6 +327,7 @@ public class JettyConfiguration {
             }
 
             contextHandler.setContextPath(super.getContextPath());
+            contextHandler.setAttribute(contextHandler.getClass().getName(), 
contextHandler);
 
             for (ServletConfiguration servletConfiguration : 
super.servletConfigurations) {
                 
contextHandler.addServlet(servletConfiguration.buildServletHolder(), 
servletConfiguration.getPathSpec());
@@ -342,7 +337,7 @@ public class JettyConfiguration {
                 customizer.accept(contextHandler);
             }
 
-            
JettyWebSocketServletContainerInitializer.configure(contextHandler, null);
+            
JakartaWebSocketServletContainerInitializer.configure(contextHandler, null);
             return contextHandler;
         }
     }

Reply via email to