Issue #4407 - fix broken tests, ServerFHF now extends ClientFHF

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2019-12-13 11:30:01 +11:00
parent 74e7cca28d
commit d08c1025e9
8 changed files with 18 additions and 19 deletions

View File

@ -214,7 +214,7 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple
public Session connectToServer(final Endpoint endpoint, final ClientEndpointConfig providedConfig, final URI path) throws DeploymentException, IOException
{
ClientEndpointConfig config = providedConfig;
if (config != null)
if (config == null)
config = new EmptyClientEndpointConfig();
ConfiguredEndpoint instance = new ConfiguredEndpoint(endpoint, config);

View File

@ -29,6 +29,11 @@ import org.eclipse.jetty.websocket.javax.common.util.InvokerUtils;
public class JavaxWebSocketClientFrameHandlerFactory extends JavaxWebSocketFrameHandlerFactory
{
public JavaxWebSocketClientFrameHandlerFactory(JavaxWebSocketContainer container, InvokerUtils.ParamIdentifier paramIdentifier)
{
super(container, paramIdentifier);
}
public JavaxWebSocketClientFrameHandlerFactory(JavaxWebSocketContainer container)
{
super(container, InvokerUtils.PARAM_IDENTITY);

View File

@ -24,7 +24,6 @@ import java.util.concurrent.Executor;
import java.util.function.Function;
import javax.servlet.ServletContext;
import javax.websocket.DeploymentException;
import javax.websocket.EndpointConfig;
import javax.websocket.server.ServerEndpoint;
import javax.websocket.server.ServerEndpointConfig;
@ -160,12 +159,6 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer
return frameHandlerFactory;
}
@Override
protected EndpointConfig newEmptyConfig(Object endpoint)
{
return new UndefinedServerEndpointConfig(endpoint.getClass());
}
@Override
public void addEndpoint(Class<?> endpointClass) throws DeploymentException
{

View File

@ -24,14 +24,14 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec;
import org.eclipse.jetty.websocket.core.FrameHandler;
import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientFrameHandlerFactory;
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer;
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory;
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata;
import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketFrameHandlerFactory implements FrameHandlerFactory
public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketClientFrameHandlerFactory implements FrameHandlerFactory
{
public JavaxWebSocketServerFrameHandlerFactory(JavaxWebSocketContainer container)
{
@ -47,10 +47,9 @@ public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketFrame
}
ServerEndpoint anno = endpointClass.getAnnotation(ServerEndpoint.class);
if (anno == null)
{
return null;
return super.createMetadata(endpointClass, endpointConfig);
}
UriTemplatePathSpec templatePathSpec = new UriTemplatePathSpec(anno.value());

View File

@ -77,7 +77,7 @@ public class EndpointEchoTest
ClientEndpoint clientEndpoint = new ClientEndpoint();
assertThat(clientEndpoint, Matchers.instanceOf(javax.websocket.Endpoint.class));
// Issue connect using instance of class that extends Endpoint
Session session = container.connectToServer(clientEndpoint, server.getWsUri().resolve("/echo/text"));
Session session = container.connectToServer(clientEndpoint, null, server.getWsUri().resolve("/echo/text"));
session.getBasicRemote().sendText("Echo");
String resp = clientEndpoint.messageQueue.poll(1, TimeUnit.SECONDS);
@ -91,7 +91,7 @@ public class EndpointEchoTest
{
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
// Issue connect using class reference (class extends Endpoint)
Session session = container.connectToServer(ClientEndpoint.class, server.getWsUri().resolve("/echo/text"));
Session session = container.connectToServer(ClientEndpoint.class, null, server.getWsUri().resolve("/echo/text"));
session.getBasicRemote().sendText("Echo");
JavaxWebSocketSession jsrSession = (JavaxWebSocketSession)session;

View File

@ -82,7 +82,7 @@ public class WriteTimeoutTest
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
ClientEndpoint clientEndpoint = new ClientEndpoint();
assertThat(clientEndpoint, Matchers.instanceOf(javax.websocket.Endpoint.class));
Session session = container.connectToServer(clientEndpoint, server.getWsUri().resolve("/logSocket"));
Session session = container.connectToServer(clientEndpoint, null, server.getWsUri().resolve("/logSocket"));
session.getAsyncRemote().setSendTimeout(5);

View File

@ -60,7 +60,7 @@ public class MisbehavingClassTest
try (StacklessLogging ignored = new StacklessLogging(WebSocketCoreSession.class))
{
// expecting RuntimeException during onOpen
container.connectToServer(socket, server.getWsUri());
container.connectToServer(socket, null, server.getWsUri());
assertThat("Close should have occurred", socket.closeLatch.await(1, TimeUnit.SECONDS), is(true));
Throwable cause = socket.errors.pop();
assertThat("Error", cause, instanceOf(RuntimeException.class));

View File

@ -30,11 +30,12 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.ClientEndpoint;
import javax.websocket.ContainerProvider;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
import javax.websocket.server.ServerEndpoint;
@ -73,9 +74,10 @@ public class WebSocketServerContainerExecutorTest
}
}
public static class EndpointAdapter extends Endpoint
@ClientEndpoint
public static class EndpointAdapter
{
@Override
@OnOpen
public void onOpen(Session session, EndpointConfig config)
{
/* do nothing */