[AMQ-8283] Migrate to non-deprecated Jetty constructors and methods (#661)

This commit is contained in:
Matt Pavlovich 2021-05-29 00:15:27 -05:00 committed by GitHub
parent 769032e952
commit e4f81bf4d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 24 deletions

View File

@ -42,7 +42,7 @@ public class SecureSocketConnectorFactory extends SocketConnectorFactory {
private String auth;
private SslContext context;
private SslContextFactory contextFactory;
private SslContextFactory.Server contextFactory;
public SecureSocketConnectorFactory() {
@ -51,7 +51,7 @@ public class SecureSocketConnectorFactory extends SocketConnectorFactory {
this.context = context;
}
public SecureSocketConnectorFactory(SslContextFactory contextFactory) {
public SecureSocketConnectorFactory(SslContextFactory.Server contextFactory) {
this.contextFactory = contextFactory;
}
@ -65,7 +65,7 @@ public class SecureSocketConnectorFactory extends SocketConnectorFactory {
// Get a reference to the current ssl context factory...
SslContextFactory factory;
SslContextFactory.Server factory;
if (contextFactory == null) {
factory = new SslContextFactory.Server();
if (context != null) {

View File

@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -39,7 +40,7 @@ public class MQTTWSSubProtocolTest extends WSTransportTestSupport {
public void setUp() throws Exception {
super.setUp();
wsClient = new WebSocketClient(new SslContextFactory.Client(true));
wsClient = new WebSocketClient(new HttpClient(new SslContextFactory.Client(true)));
wsClient.start();
}

View File

@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.activemq.util.Wait;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -68,7 +69,7 @@ public class MQTTWSTransportTest extends WSTransportTestSupport {
public void setUp() throws Exception {
super.setUp();
wsClient = new WebSocketClient(new SslContextFactory.Client(true));
wsClient = new WebSocketClient(new HttpClient(new SslContextFactory.Client(true)));
wsClient.start();
request = new ClientUpgradeRequest();

View File

@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -78,7 +79,7 @@ public class MQTTWSTransportWillTest extends WSTransportTestSupport {
//turn off advisory support
broker = createBroker(true, false);
wsClient = new WebSocketClient(new SslContextFactory.Client(true));
wsClient = new WebSocketClient(new HttpClient(new SslContextFactory.Client(true)));
wsClient.start();
request = new ClientUpgradeRequest();

View File

@ -24,6 +24,7 @@ import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.activemq.transport.stomp.Stomp;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -150,7 +151,7 @@ public class StompWSSubProtocolTest extends WSTransportTestSupport {
request.setSubProtocols(subProtocol);
}
wsClient = new WebSocketClient(new SslContextFactory.Client(true));
wsClient = new WebSocketClient(new HttpClient(new SslContextFactory.Client(true)));
wsClient.start();
wsClient.connect(wsStompConnection, wsConnectUri, request);

View File

@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.transport.stomp.Stomp;
import org.apache.activemq.transport.stomp.StompFrame;
import org.apache.activemq.util.Wait;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -57,7 +58,7 @@ public class StompWSTransportTest extends WSTransportTestSupport {
ClientUpgradeRequest request = new ClientUpgradeRequest();
request.setSubProtocols("v11.stomp");
wsClient = new WebSocketClient(new SslContextFactory.Client(true));
wsClient = new WebSocketClient(new HttpClient(new SslContextFactory.Client(true)));
wsClient.start();
wsClient.connect(wsStompConnection, wsConnectUri, request);

View File

@ -22,6 +22,7 @@ import org.apache.activemq.transport.stomp.Stomp;
import org.apache.activemq.transport.stomp.StompFrame;
import org.apache.activemq.transport.ws.MQTTWSConnection;
import org.apache.activemq.transport.ws.StompWSConnection;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
@ -84,28 +85,29 @@ public class WSSTransportNeedClientAuthTest {
factory.setTrustStorePath(TRUST_KEYSTORE);
factory.setTrustStorePassword(PASSWORD);
factory.setTrustStoreType(KEYSTORE_TYPE);
WebSocketClient wsClient = new WebSocketClient(factory);
WebSocketClient wsClient = new WebSocketClient(new HttpClient(factory));
wsClient.start();
Future<Session> connected = wsClient.connect(wsStompConnection, new URI("wss://localhost:61618"));
Session sess = connected.get(30, TimeUnit.SECONDS);
try(Session sess = connected.get(30, TimeUnit.SECONDS)) {
String connectFrame = "STOMP\n" +
"login:system\n" +
"passcode:manager\n" +
"accept-version:1.2\n" +
"host:localhost\n" +
"\n" + Stomp.NULL;
String connectFrame = "STOMP\n" +
"login:system\n" +
"passcode:manager\n" +
"accept-version:1.2\n" +
"host:localhost\n" +
"\n" + Stomp.NULL;
wsStompConnection.sendRawFrame(connectFrame);
wsStompConnection.sendRawFrame(connectFrame);
String incoming = wsStompConnection.receive(30, TimeUnit.SECONDS);
assertNotNull(incoming);
assertTrue(incoming.startsWith("CONNECTED"));
wsStompConnection.sendFrame(new StompFrame(Stomp.Commands.DISCONNECT));
wsStompConnection.close();
String incoming = wsStompConnection.receive(30, TimeUnit.SECONDS);
assertNotNull(incoming);
assertTrue(incoming.startsWith("CONNECTED"));
wsStompConnection.sendFrame(new StompFrame(Stomp.Commands.DISCONNECT));
wsStompConnection.close();
}
}
@Test
@ -117,7 +119,7 @@ public class WSSTransportNeedClientAuthTest {
factory.setTrustStorePath(TRUST_KEYSTORE);
factory.setTrustStorePassword(PASSWORD);
factory.setTrustStoreType(KEYSTORE_TYPE);
WebSocketClient wsClient = new WebSocketClient(factory);
WebSocketClient wsClient = new WebSocketClient(new HttpClient(factory));
wsClient.start();
ClientUpgradeRequest request = new ClientUpgradeRequest();