diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/CookiesTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/CookiesTest.java index ede1f8d1519..51f2b1557ca 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/CookiesTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/CookiesTest.java @@ -19,14 +19,12 @@ package org.eclipse.jetty.server; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import javax.servlet.http.Cookie; -import org.eclipse.jetty.http.CookieCompliance; import org.hamcrest.Matchers; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CookiesTest { diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ConfigurationsTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ConfigurationsTest.java index 822d57cb01f..7ffea852f79 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ConfigurationsTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ConfigurationsTest.java @@ -18,12 +18,12 @@ package org.eclipse.jetty.webapp; +import org.junit.jupiter.api.Test; + import static java.util.stream.Collectors.toList; import static org.eclipse.jetty.webapp.Configurations.getKnown; import static org.hamcrest.Matchers.contains; -import static org.junit.Assert.assertThat; - -import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; public class ConfigurationsTest { diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketUpgradeRequest.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketUpgradeRequest.java index a7b1ece3525..5b421699df5 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketUpgradeRequest.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketUpgradeRequest.java @@ -624,7 +624,7 @@ public class WebSocketUpgradeRequest extends HttpRequest implements CompleteList // Now swap out the connection endp.upgrade(connection); } - + public EndPoint configure(EndPoint endp) { return endp; diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/RedirectWebSocketClientTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/RedirectWebSocketClientTest.java deleted file mode 100644 index e4d6ccbd0c4..00000000000 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/RedirectWebSocketClientTest.java +++ /dev/null @@ -1,155 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.websocket.server; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - -import java.net.URI; -import java.util.concurrent.Future; - -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.http.HttpVersion; -import org.eclipse.jetty.server.HttpConfiguration; -import org.eclipse.jetty.server.HttpConnectionFactory; -import org.eclipse.jetty.server.SecureRequestCustomizer; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.SslConnectionFactory; -import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerList; -import org.eclipse.jetty.server.handler.SecuredRedirectHandler; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.toolchain.test.MavenTestingUtils; -import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.websocket.api.Session; -import org.eclipse.jetty.websocket.api.annotations.WebSocket; -import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; -import org.eclipse.jetty.websocket.client.WebSocketClient; -import org.eclipse.jetty.websocket.server.helper.EchoServlet; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -public class RedirectWebSocketClientTest -{ - public static Server server; - public static URI serverWsUri; - public static URI serverWssUri; - - @BeforeAll - public static void startServer() throws Exception - { - server = new Server(); - - HttpConfiguration http_config = new HttpConfiguration(); - http_config.setSecureScheme("https"); - http_config.setSecurePort(0); - http_config.setOutputBufferSize(32768); - http_config.setRequestHeaderSize(8192); - http_config.setResponseHeaderSize(8192); - http_config.setSendServerVersion(true); - http_config.setSendDateHeader(false); - - SslContextFactory sslContextFactory = newSslContextFactory(); - - // SSL HTTP Configuration - HttpConfiguration https_config = new HttpConfiguration(http_config); - https_config.addCustomizer(new SecureRequestCustomizer()); - - // SSL Connector - ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(https_config)); - sslConnector.setPort(0); - server.addConnector(sslConnector); - - // Normal Connector - ServerConnector connector = new ServerConnector(server); - connector.setPort(0); - server.addConnector(connector); - - ServletContextHandler contextHandler = new ServletContextHandler(); - contextHandler.setContextPath("/"); - contextHandler.addServlet(EchoServlet.class, "/echo"); - - HandlerList handlers = new HandlerList(); - - handlers.addHandler(new SecuredRedirectHandler()); - handlers.addHandler(contextHandler); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); - - server.start(); - - serverWsUri = URI.create("ws://localhost:" + connector.getLocalPort() + "/"); - serverWssUri = URI.create("wss://localhost:" + sslConnector.getLocalPort() + "/"); - - // adjust HttpConfiguration in connector - HttpConnectionFactory connectionFactory = connector.getConnectionFactory(HttpConnectionFactory.class); - connectionFactory.getHttpConfiguration().setSecurePort(sslConnector.getLocalPort()); - } - - @AfterAll - public static void stopServer() throws Exception - { - server.stop(); - } - - private static SslContextFactory newSslContextFactory() - { - SslContextFactory ssl = new SslContextFactory(); - ssl.setKeyStorePath(MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath()); - ssl.setKeyStorePassword("storepwd"); - ssl.setKeyManagerPassword("keypwd"); - return ssl; - } - - @Test - public void testRedirect() throws Exception - { - SslContextFactory ssl = newSslContextFactory(); - ssl.setTrustAll(false); - ssl.setEndpointIdentificationAlgorithm(null); - HttpClient httpClient = new HttpClient(ssl); - - WebSocketClient client = new WebSocketClient(httpClient); - client.addBean(httpClient, true); - client.start(); - - try - { - URI wsUri = serverWsUri.resolve("/echo"); - - ClientUpgradeRequest request = new ClientUpgradeRequest(); - Future sessionFuture = client.connect(new EmptyWebSocket(), wsUri, request); - Session session = sessionFuture.get(); - assertThat(session, is(notNullValue())); - } - finally - { - client.stop(); - } - } - - @WebSocket - public static class EmptyWebSocket { - - } -}