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

View File

@ -14,7 +14,6 @@
package org.eclipse.jetty.ee9.websocket.jakarta.server.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -25,18 +24,19 @@ import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse;
public class JsrHandshakeResponse implements HandshakeResponse
{
private final ServerUpgradeResponse delegate;
private final Map<String, List<String>> headers;
public JsrHandshakeResponse(ServerUpgradeResponse resp)
{
this.delegate = resp;
this.headers = delegate.getHeaders().getFieldNamesCollection().stream()
.collect(Collectors.toMap((name) -> name, (name) -> new ArrayList<>(delegate.getHeaders().getValuesList(name))));
}
@Override
public Map<String, List<String>> getHeaders()
{
Map<String, List<String>> headers = delegate.getHeaders().getFieldNamesCollection().stream()
.collect(Collectors.toMap((name) -> name, (name) -> new ArrayList<>(delegate.getHeaders().getValuesList(name))));
return Collections.unmodifiableMap(headers);
return 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.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
@ -88,7 +87,6 @@ public class JakartaClientShutdownWithServerEmbeddedTest
server.stop();
}
@Disabled
@Test
public void testShutdownWithContextHandler() throws Exception
{
@ -101,7 +99,7 @@ public class JakartaClientShutdownWithServerEmbeddedTest
assertThat(clientContainer.isRunning(), is(true));
// 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.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.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
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.assertTrue;
@Disabled
public class JakartaWebSocketRestartTest
{
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.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@Disabled
public class AnnotatedServerEndpointTest
{
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.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
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,
* check for {@link DeploymentException}
*/
@Disabled
public class DeploymentExceptionTest
{
public static Stream<Arguments> data()

View File

@ -36,7 +36,6 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnJre;
import org.junit.jupiter.api.condition.JRE;
@ -63,7 +62,6 @@ public class DeploymentTest
server.stop();
}
@Disabled
@Test
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>
* @throws Exception if there is an error during the test.
*/
@Disabled
@Test
@DisabledOnJre({JRE.JAVA_14, JRE.JAVA_15})
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.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -114,7 +113,6 @@ public class InputStreamEchoTest
}
}
@Disabled
@Test
public void testInputStreamParamSocket() throws Exception
{
@ -125,7 +123,7 @@ public class InputStreamEchoTest
send.add(CloseStatus.toFrame(CloseStatus.NORMAL));
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));
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.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -114,7 +113,6 @@ public class ReaderEchoTest
}
}
@Disabled
@Test
public void testReaderParamSocket() throws Exception
{
@ -125,7 +123,7 @@ public class ReaderEchoTest
send.add(CloseStatus.toFrame(CloseStatus.NORMAL));
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));
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.util.IO;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
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.startsWith;
@Disabled
public class WebSocketServerContainerExecutorTest
{
@ServerEndpoint("/echo")

View File

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