Merge pull request #6680 from eclipse/jetty-10.0.x-6601-WebSocketJPMS
Issue #6601 - fix JPMS issues for websocket-core-common
This commit is contained in:
commit
dff5e14bb5
|
@ -24,7 +24,8 @@ module org.eclipse.jetty.websocket.core.common
|
|||
|
||||
exports org.eclipse.jetty.websocket.core.internal to
|
||||
org.eclipse.jetty.websocket.core.client,
|
||||
org.eclipse.jetty.websocket.core.server;
|
||||
org.eclipse.jetty.websocket.core.server,
|
||||
org.eclipse.jetty.util; // Export to DecoratedObjectFactory.
|
||||
|
||||
// The Jetty & Javax API Layers need to access both access some internal utilities which we don't want to expose.
|
||||
exports org.eclipse.jetty.websocket.core.internal.util to
|
||||
|
|
|
@ -56,5 +56,6 @@
|
|||
<module>test-http-client-transport</module>
|
||||
<module>test-distribution</module>
|
||||
<module>test-cdi</module>
|
||||
<module>test-jpms</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>tests-parent</artifactId>
|
||||
<version>10.0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>test-jpms</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Jetty Tests :: JPMS Parent</name>
|
||||
<modules>
|
||||
<module>test-jpms-websocket-core</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-slf4j-impl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>test-jpms</artifactId>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<version>10.0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>test-jpms-websocket-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Jetty Tests :: JPMS :: WebSocket Core Tests</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-core-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-core-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// 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
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
requires org.eclipse.jetty.websocket.core.server;
|
||||
requires org.eclipse.jetty.websocket.core.client;
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// 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
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
import java.net.URI;
|
||||
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.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
|
||||
{
|
||||
private Server _server;
|
||||
private ServerConnector _serverConnector;
|
||||
private WebSocketCoreClient _client;
|
||||
|
||||
@BeforeEach
|
||||
public void before() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_serverConnector = new ServerConnector(_server);
|
||||
_server.addConnector(_serverConnector);
|
||||
|
||||
WebSocketUpgradeHandler webSocketUpgradeHandler = new WebSocketUpgradeHandler();
|
||||
FrameHandler myFrameHandler = new TestFrameHandler("Server");
|
||||
webSocketUpgradeHandler.addMapping("/ws", WebSocketNegotiator.from(negotiation -> myFrameHandler));
|
||||
|
||||
_server.setHandler(webSocketUpgradeHandler);
|
||||
_server.start();
|
||||
|
||||
_client = new WebSocketCoreClient();
|
||||
_client.start();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void after() throws Exception
|
||||
{
|
||||
_client.stop();
|
||||
_server.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleEcho() throws Exception
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue