Issue #207 - more test fixes

This commit is contained in:
Joakim Erdfelt 2017-04-28 09:41:58 -07:00
parent 9fd70d3d6f
commit 9345bc3d5a
4 changed files with 112 additions and 7 deletions

View File

@ -21,12 +21,14 @@ package org.eclipse.jetty.websocket.jsr356.server;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
import javax.websocket.DeploymentException;
import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.jsr356.server.samples.InvalidCloseIntSocket;
import org.eclipse.jetty.websocket.jsr356.server.samples.InvalidErrorErrorSocket;
import org.eclipse.jetty.websocket.jsr356.server.samples.InvalidErrorExceptionSocket;
@ -36,7 +38,8 @@ import org.eclipse.jetty.websocket.jsr356.server.samples.InvalidOpenIntSocket;
import org.eclipse.jetty.websocket.jsr356.server.samples.InvalidOpenSessionIntSocket;
import org.eclipse.jetty.websocket.server.MappedWebSocketCreator;
import org.eclipse.jetty.websocket.server.WebSocketServerFactory;
import org.eclipse.jetty.websocket.server.WebSocketUpgradeHandlerWrapper;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@ -79,14 +82,36 @@ public class DeploymentExceptionTest
@Parameterized.Parameter(0)
public Class<?> pojo;
private Server server;
private HandlerCollection contexts;
@Before
public void startServer() throws Exception
{
server = new Server(0);
contexts = new HandlerCollection(true, new Handler[0]);
server.setHandler(contexts);
server.start();
}
@After
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testDeploy_InvalidSignature() throws Exception
{
MappedWebSocketCreator creator = new WebSocketUpgradeHandlerWrapper();
WebSocketServerFactory serverFactory = new WebSocketServerFactory();
Executor executor = new QueuedThreadPool();
ServerContainer container = new ServerContainer(creator, serverFactory, executor);
ServletContextHandler context = new ServletContextHandler();
WebSocketServerFactory serverFactory = new WebSocketServerFactory(context.getServletContext());
NativeWebSocketConfiguration configuration = new NativeWebSocketConfiguration(serverFactory);
ServerContainer container = new ServerContainer(configuration, server.getThreadPool());
context.addBean(container);
contexts.addHandler(context);
try
{
container.start();

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<listener>
<listener-class>org.eclipse.jetty.websocket.tests.server.InfoContextAltAttributeListener</listener-class>
</listener>
<filter>
<filter-name>wsuf-alt</filter-name>
<filter-class>org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter</filter-class>
<init-param>
<param-name>configAttributeKey</param-name>
<param-value>alt.config</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>wsuf-alt</filter-name>
<url-pattern>/info/*</url-pattern>
</filter-mapping>
</web-app>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- disable JSR-356 -->
<context-param>
<param-name>org.eclipse.jetty.websocket.jsr356</param-name>
<param-value>false</param-value>
</context-param>
<listener>
<listener-class>org.eclipse.jetty.websocket.tests.server.InfoContextAttributeListener</listener-class>
</listener>
<filter>
<filter-name>wsuf</filter-name>
<filter-class>org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>wsuf</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- disable JSR-356 -->
<context-param>
<param-name>org.eclipse.jetty.websocket.jsr356</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>info-servlet</servlet-name>
<servlet-class>org.eclipse.jetty.websocket.tests.server.InfoServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<filter>
<filter-name>wsuf</filter-name>
<filter-class>org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>wsuf</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>