diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java index e69bc7010a1..ca8c3b37fd9 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java @@ -203,7 +203,7 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket switch (messageType) { case -1: // new message - frame = new Frame(OpCode.BINARY); + frame = new Frame(OpCode.TEXT); messageType = OpCode.TEXT; break; case OpCode.TEXT: diff --git a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java index 771c5d3be5a..08edf8d620f 100644 --- a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java +++ b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java @@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.tests.server; import java.net.URI; import java.nio.ByteBuffer; import java.time.Duration; -import java.time.temporal.TemporalAmount; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; @@ -42,24 +41,21 @@ import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.common.WebSocketSession; import org.eclipse.jetty.websocket.common.util.TextUtil; -import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactory; -import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory; -import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; -import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse; -import org.eclipse.jetty.websocket.servlet.WebSocketCreator; -import org.eclipse.jetty.websocket.servlet.WebSocketServlet; -import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; +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.tests.CloseTrackingEndpoint; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static java.util.concurrent.TimeUnit.SECONDS; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -@Disabled("merge from 9.4.x but fail") public class PartialListenerTest { private Server server; @@ -77,28 +73,18 @@ public class PartialListenerTest ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); - ServletHolder closeEndpoint = new ServletHolder(new WebSocketServlet() + ServletHolder closeEndpoint = new ServletHolder(new JettyWebSocketServlet() { @Override - public void configure(WebSocketServletFactory factory) + public void configure(JettyWebSocketServletFactory factory) { - factory.setIdleTimeout( Duration.ofMillis( 2 )); + factory.setIdleTimeout(Duration.ofSeconds(2)); partialCreator = new PartialCreator(); factory.setCreator(partialCreator); } - - protected FrameHandlerFactory getFactory() - { - JettyServerFrameHandlerFactory - frameHandlerFactory = JettyServerFrameHandlerFactory.getFactory( getServletContext()); - - if (frameHandlerFactory == null) - throw new IllegalStateException("JettyServerFrameHandlerFactory not found"); - - return frameHandlerFactory; - } }); context.addServlet(closeEndpoint, "/ws"); + JettyWebSocketServletContainerInitializer.configure(context, null); HandlerList handlers = new HandlerList(); handlers.addHandler(context); @@ -265,13 +251,12 @@ public class PartialListenerTest } } - - public static class PartialCreator implements WebSocketCreator + public static class PartialCreator implements JettyWebSocketCreator { public PartialEndpoint partialEndpoint; @Override - public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) + public Object createWebSocket(JettyServerUpgradeRequest req, JettyServerUpgradeResponse resp) { partialEndpoint = new PartialEndpoint(); return partialEndpoint;