diff --git a/tests/test-jpms/pom.xml b/tests/test-jpms/pom.xml
index abe7e8d2b0c..0acfe67a511 100644
--- a/tests/test-jpms/pom.xml
+++ b/tests/test-jpms/pom.xml
@@ -10,7 +10,7 @@
pom
Jetty Tests :: JPMS Parent
- test-websocket-core
+ test-jpms-websocket-core
diff --git a/tests/test-jpms/test-websocket-core/pom.xml b/tests/test-jpms/test-jpms-websocket-core/pom.xml
similarity index 93%
rename from tests/test-jpms/test-websocket-core/pom.xml
rename to tests/test-jpms/test-jpms-websocket-core/pom.xml
index 903d38e64fd..93f862c4c1e 100644
--- a/tests/test-jpms/test-websocket-core/pom.xml
+++ b/tests/test-jpms/test-jpms-websocket-core/pom.xml
@@ -6,7 +6,7 @@
10.0.7-SNAPSHOT
4.0.0
- test-websocket-core
+ test-jpms-websocket-core
jar
Jetty Tests :: JPMS :: WebSocket Core Tests
@@ -22,4 +22,4 @@
${project.version}
-
\ No newline at end of file
+
diff --git a/tests/test-jpms/test-websocket-core/src/main/java/module-info.java b/tests/test-jpms/test-jpms-websocket-core/src/main/java/module-info.java
similarity index 81%
rename from tests/test-jpms/test-websocket-core/src/main/java/module-info.java
rename to tests/test-jpms/test-jpms-websocket-core/src/main/java/module-info.java
index bf90ab65d56..c10573d1531 100644
--- a/tests/test-jpms/test-websocket-core/src/main/java/module-info.java
+++ b/tests/test-jpms/test-jpms-websocket-core/src/main/java/module-info.java
@@ -11,10 +11,12 @@
// ========================================================================
//
+/**
+ * This module-info.java exists so that the tests can be run in JPMS mode,
+ * therefore testing the JPMS module descriptors of the dependencies involved.
+ */
module org.eclipse.jetty.websocket.core.tests
{
- exports org.example.websocket;
-
requires org.eclipse.jetty.websocket.core.server;
requires org.eclipse.jetty.websocket.core.client;
-}
\ No newline at end of file
+}
diff --git a/tests/test-jpms/test-websocket-core/src/test/java/WebSocketCoreJpmsTest.java b/tests/test-jpms/test-jpms-websocket-core/src/test/java/WebSocketCoreJPMSTest.java
similarity index 65%
rename from tests/test-jpms/test-websocket-core/src/test/java/WebSocketCoreJpmsTest.java
rename to tests/test-jpms/test-jpms-websocket-core/src/test/java/WebSocketCoreJPMSTest.java
index c3884154246..f5533189a2d 100644
--- a/tests/test-jpms/test-websocket-core/src/test/java/WebSocketCoreJpmsTest.java
+++ b/tests/test-jpms/test-jpms-websocket-core/src/test/java/WebSocketCoreJPMSTest.java
@@ -17,18 +17,21 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.Callback;
+import org.eclipse.jetty.websocket.core.CloseStatus;
import org.eclipse.jetty.websocket.core.CoreSession;
+import org.eclipse.jetty.websocket.core.Frame;
import org.eclipse.jetty.websocket.core.FrameHandler;
import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest;
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator;
import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler;
-import org.example.websocket.MyFrameHandler;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class WebSocketCoreJpmsTest
+public class WebSocketCoreJPMSTest
{
private Server _server;
private ServerConnector _serverConnector;
@@ -42,7 +45,7 @@ public class WebSocketCoreJpmsTest
_server.addConnector(_serverConnector);
WebSocketUpgradeHandler webSocketUpgradeHandler = new WebSocketUpgradeHandler();
- FrameHandler myFrameHandler = new MyFrameHandler("Server");
+ FrameHandler myFrameHandler = new TestFrameHandler("Server");
webSocketUpgradeHandler.addMapping("/ws", WebSocketNegotiator.from(negotiation -> myFrameHandler));
_server.setHandler(webSocketUpgradeHandler);
@@ -62,11 +65,51 @@ public class WebSocketCoreJpmsTest
@Test
public void testSimpleEcho() throws Exception
{
- MyFrameHandler frameHandler = new MyFrameHandler("Client");
+ TestFrameHandler frameHandler = new TestFrameHandler("Client");
URI uri = URI.create("ws://localhost:" + _serverConnector.getLocalPort() + "/ws");
CoreClientUpgradeRequest upgradeRequest = CoreClientUpgradeRequest.from(_client, uri, frameHandler);
upgradeRequest.addExtensions("permessage-deflate");
CoreSession coreSession = _client.connect(upgradeRequest).get(5, TimeUnit.SECONDS);
coreSession.close(Callback.NOOP);
}
+
+ public static class TestFrameHandler implements FrameHandler
+ {
+ private static final Logger LOG = LoggerFactory.getLogger(TestFrameHandler.class);
+
+ private final String _id;
+
+ public TestFrameHandler(String id)
+ {
+ _id = id;
+ }
+
+ @Override
+ public void onOpen(CoreSession coreSession, Callback callback)
+ {
+ LOG.info(_id + " onOpen");
+ callback.succeeded();
+ }
+
+ @Override
+ public void onFrame(Frame frame, Callback callback)
+ {
+ LOG.info(_id + " onFrame");
+ callback.succeeded();
+ }
+
+ @Override
+ public void onError(Throwable cause, Callback callback)
+ {
+ LOG.info(_id + " onError");
+ callback.succeeded();
+ }
+
+ @Override
+ public void onClosed(CloseStatus closeStatus, Callback callback)
+ {
+ LOG.info(_id + " onClosed");
+ callback.succeeded();
+ }
+ }
}
diff --git a/tests/test-jpms/test-websocket-core/src/main/java/org/example/websocket/MyFrameHandler.java b/tests/test-jpms/test-websocket-core/src/main/java/org/example/websocket/MyFrameHandler.java
deleted file mode 100644
index d02b7e593bd..00000000000
--- a/tests/test-jpms/test-websocket-core/src/main/java/org/example/websocket/MyFrameHandler.java
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
-//
-// This program and the accompanying materials are made available under the
-// terms of the Eclipse Public License v. 2.0 which is available at
-// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
-// which is available at https://www.apache.org/licenses/LICENSE-2.0.
-//
-// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
-// ========================================================================
-//
-
-package org.example.websocket;
-
-import org.eclipse.jetty.util.Callback;
-import org.eclipse.jetty.websocket.core.CloseStatus;
-import org.eclipse.jetty.websocket.core.CoreSession;
-import org.eclipse.jetty.websocket.core.Frame;
-import org.eclipse.jetty.websocket.core.FrameHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MyFrameHandler implements FrameHandler
-{
- private static final Logger LOG = LoggerFactory.getLogger(MyFrameHandler.class);
-
- private final String _id;
-
- public MyFrameHandler(String id)
- {
- _id = id;
- }
-
- @Override
- public void onOpen(CoreSession coreSession, Callback callback)
- {
- LOG.info(_id + " onOpen");
- callback.succeeded();
- }
-
- @Override
- public void onFrame(Frame frame, Callback callback)
- {
- LOG.info(_id + " onFrame");
- callback.succeeded();
- }
-
- @Override
- public void onError(Throwable cause, Callback callback)
- {
- LOG.info(_id + " onError");
- callback.succeeded();
- }
-
- @Override
- public void onClosed(CloseStatus closeStatus, Callback callback)
- {
- LOG.info(_id + " onClosed");
- callback.succeeded();
- }
-}