fix all disabled tests in websocket ee9

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2022-10-19 16:55:47 +11:00
parent 6016106442
commit c85f3f40a3
11 changed files with 15 additions and 32 deletions

View File

@ -22,20 +22,25 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.websocket.server.HandshakeRequest; import jakarta.websocket.server.HandshakeRequest;
import org.eclipse.jetty.http.pathmap.PathSpec; import org.eclipse.jetty.http.pathmap.PathSpec;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.websocket.core.WebSocketConstants;
import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest;
public class JsrHandshakeRequest implements HandshakeRequest public class JsrHandshakeRequest implements HandshakeRequest
{ {
private final ServerUpgradeRequest delegate; private final ServerUpgradeRequest delegate;
private final HttpServletRequest httpServletRequest;
private Map<String, List<String>> parameterMap; private Map<String, List<String>> parameterMap;
public JsrHandshakeRequest(ServerUpgradeRequest req) public JsrHandshakeRequest(ServerUpgradeRequest req)
{ {
this.delegate = req; this.delegate = req;
this.httpServletRequest = (HttpServletRequest)req
.getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
} }
@Override @Override
@ -49,8 +54,7 @@ public class JsrHandshakeRequest implements HandshakeRequest
@Override @Override
public Object getHttpSession() public Object getHttpSession()
{ {
// TODO return httpServletRequest.getSession(false);
return null;
} }
@Override @Override
@ -94,14 +98,12 @@ public class JsrHandshakeRequest implements HandshakeRequest
@Override @Override
public Principal getUserPrincipal() public Principal getUserPrincipal()
{ {
// TODO; return httpServletRequest.getUserPrincipal();
return null;
} }
@Override @Override
public boolean isUserInRole(String role) public boolean isUserInRole(String role)
{ {
// TODO; return httpServletRequest.isUserInRole(role);
return false;
} }
} }

View File

@ -14,7 +14,6 @@
package org.eclipse.jetty.ee9.websocket.jakarta.server.internal; package org.eclipse.jetty.ee9.websocket.jakarta.server.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -25,18 +24,19 @@ import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse;
public class JsrHandshakeResponse implements HandshakeResponse public class JsrHandshakeResponse implements HandshakeResponse
{ {
private final ServerUpgradeResponse delegate; private final ServerUpgradeResponse delegate;
private final Map<String, List<String>> headers;
public JsrHandshakeResponse(ServerUpgradeResponse resp) public JsrHandshakeResponse(ServerUpgradeResponse resp)
{ {
this.delegate = resp; this.delegate = resp;
this.headers = delegate.getHeaders().getFieldNamesCollection().stream()
.collect(Collectors.toMap((name) -> name, (name) -> new ArrayList<>(delegate.getHeaders().getValuesList(name))));
} }
@Override @Override
public Map<String, List<String>> getHeaders() public Map<String, List<String>> getHeaders()
{ {
Map<String, List<String>> headers = delegate.getHeaders().getFieldNamesCollection().stream() return headers;
.collect(Collectors.toMap((name) -> name, (name) -> new ArrayList<>(delegate.getHeaders().getValuesList(name))));
return Collections.unmodifiableMap(headers);
} }
public void setHeaders(Map<String, List<String>> headers) public void setHeaders(Map<String, List<String>> headers)

View File

@ -32,7 +32,6 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -88,7 +87,6 @@ public class JakartaClientShutdownWithServerEmbeddedTest
server.stop(); server.stop();
} }
@Disabled
@Test @Test
public void testShutdownWithContextHandler() throws Exception public void testShutdownWithContextHandler() throws Exception
{ {
@ -101,7 +99,7 @@ public class JakartaClientShutdownWithServerEmbeddedTest
assertThat(clientContainer.isRunning(), is(true)); assertThat(clientContainer.isRunning(), is(true));
// The container should be a bean on the ContextHandler. // The container should be a bean on the ContextHandler.
Collection<WebSocketContainer> containedBeans = contextHandler.getBeans(WebSocketContainer.class); Collection<WebSocketContainer> containedBeans = contextHandler.getCoreContextHandler().getBeans(WebSocketContainer.class);
assertThat(containedBeans.size(), is(1)); assertThat(containedBeans.size(), is(1));
assertThat(containedBeans.toArray()[0], is(container)); assertThat(containedBeans.toArray()[0], is(container));

View File

@ -28,7 +28,6 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -38,7 +37,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@Disabled
public class JakartaWebSocketRestartTest public class JakartaWebSocketRestartTest
{ {
private Server server; private Server server;

View File

@ -32,10 +32,8 @@ import org.eclipse.jetty.websocket.core.Frame;
import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OpCode;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Disabled
public class AnnotatedServerEndpointTest public class AnnotatedServerEndpointTest
{ {
private LocalServer server; private LocalServer server;

View File

@ -34,7 +34,6 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
@ -47,7 +46,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
* Deploy various {@link ServerEndpoint} annotated classes with invalid signatures, * Deploy various {@link ServerEndpoint} annotated classes with invalid signatures,
* check for {@link DeploymentException} * check for {@link DeploymentException}
*/ */
@Disabled
public class DeploymentExceptionTest public class DeploymentExceptionTest
{ {
public static Stream<Arguments> data() public static Stream<Arguments> data()

View File

@ -36,7 +36,6 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnJre; import org.junit.jupiter.api.condition.DisabledOnJre;
import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.api.condition.JRE;
@ -63,7 +62,6 @@ public class DeploymentTest
server.stop(); server.stop();
} }
@Disabled
@Test @Test
public void testBadPathParamSignature() throws Exception public void testBadPathParamSignature() throws Exception
{ {
@ -94,7 +92,6 @@ public class DeploymentTest
* @see <a href="https://bugs.openjdk.java.net/browse/JDK-8244090">JDK-8244090</a> * @see <a href="https://bugs.openjdk.java.net/browse/JDK-8244090">JDK-8244090</a>
* @throws Exception if there is an error during the test. * @throws Exception if there is an error during the test.
*/ */
@Disabled
@Test @Test
@DisabledOnJre({JRE.JAVA_14, JRE.JAVA_15}) @DisabledOnJre({JRE.JAVA_14, JRE.JAVA_15})
public void testDifferentWebAppsWithSameClassInSignature() throws Exception public void testDifferentWebAppsWithSameClassInSignature() throws Exception

View File

@ -30,7 +30,6 @@ import org.eclipse.jetty.websocket.core.Frame;
import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OpCode;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -114,7 +113,6 @@ public class InputStreamEchoTest
} }
} }
@Disabled
@Test @Test
public void testInputStreamParamSocket() throws Exception public void testInputStreamParamSocket() throws Exception
{ {
@ -125,7 +123,7 @@ public class InputStreamEchoTest
send.add(CloseStatus.toFrame(CloseStatus.NORMAL)); send.add(CloseStatus.toFrame(CloseStatus.NORMAL));
List<Frame> expect = new ArrayList<>(); List<Frame> expect = new ArrayList<>();
expect.add(new Frame(OpCode.TEXT).setPayload("Hello World|Every Person")); expect.add(new Frame(OpCode.TEXT).setPayload("Hello World|Every%20Person"));
expect.add(CloseStatus.toFrame(CloseStatus.NORMAL)); expect.add(CloseStatus.toFrame(CloseStatus.NORMAL));
try (Fuzzer session = server.newNetworkFuzzer(requestPath)) try (Fuzzer session = server.newNetworkFuzzer(requestPath))

View File

@ -30,7 +30,6 @@ import org.eclipse.jetty.websocket.core.Frame;
import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OpCode;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -114,7 +113,6 @@ public class ReaderEchoTest
} }
} }
@Disabled
@Test @Test
public void testReaderParamSocket() throws Exception public void testReaderParamSocket() throws Exception
{ {
@ -125,7 +123,7 @@ public class ReaderEchoTest
send.add(CloseStatus.toFrame(CloseStatus.NORMAL)); send.add(CloseStatus.toFrame(CloseStatus.NORMAL));
List<Frame> expect = new ArrayList<>(); List<Frame> expect = new ArrayList<>();
expect.add(new Frame(OpCode.TEXT).setPayload("Hello World|Every Person")); expect.add(new Frame(OpCode.TEXT).setPayload("Hello World|Every%20Person"));
expect.add(CloseStatus.toFrame(CloseStatus.NORMAL)); expect.add(CloseStatus.toFrame(CloseStatus.NORMAL));
try (Fuzzer session = server.newNetworkFuzzer(requestPath)) try (Fuzzer session = server.newNetworkFuzzer(requestPath))

View File

@ -43,7 +43,6 @@ import org.eclipse.jetty.ee9.websocket.jakarta.tests.WSURI;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.eclipse.jetty.ee9.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer.HTTPCLIENT_ATTRIBUTE; import static org.eclipse.jetty.ee9.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer.HTTPCLIENT_ATTRIBUTE;
@ -52,7 +51,6 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance; import static org.hamcrest.Matchers.sameInstance;
import static org.hamcrest.Matchers.startsWith; import static org.hamcrest.Matchers.startsWith;
@Disabled
public class WebSocketServerContainerExecutorTest public class WebSocketServerContainerExecutorTest
{ {
@ServerEndpoint("/echo") @ServerEndpoint("/echo")

View File

@ -41,7 +41,6 @@ import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Credential; import org.eclipse.jetty.util.security.Credential;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,7 +48,6 @@ import org.slf4j.LoggerFactory;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@Disabled
public class WebSocketServerExamplesTest public class WebSocketServerExamplesTest
{ {
private static final Logger LOG = LoggerFactory.getLogger(WebSocketServerExamplesTest.class); private static final Logger LOG = LoggerFactory.getLogger(WebSocketServerExamplesTest.class);