Skip to content

Commit

Permalink
Revert a wrong test
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1735612 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
violetagg committed Mar 18, 2016
1 parent a59da0f commit 74ebb85
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@
import javax.websocket.OnMessage;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpoint;
import javax.websocket.server.ServerEndpointConfig;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import org.apache.catalina.Context;
Expand Down Expand Up @@ -767,76 +765,6 @@ public void testSessionExpirySession() throws Exception {
Assert.assertEquals(0, getOpenCount(setA));
}

@Ignore
@Test
public void testSessionMaxIdleTimeout() throws Exception {

Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
ctx.addApplicationListener(Config.class.getName());
Tomcat.addServlet(ctx, "default", new DefaultServlet());
ctx.addServletMapping("/", "default");

tomcat.start();

// Need access to implementation methods for configuring unit tests
WsWebSocketContainer wsContainer = (WsWebSocketContainer)
ContainerProvider.getWebSocketContainer();
wsContainer.setProcessPeriod(1);

long timeout = 2000;
try (Session session = connectToEchoServer(wsContainer, new EndpointA(),
Config.PATH_MAX_IDLE_TIMEOUT + "/" + (2 * timeout))) {
session.addMessageHandler(new MessageHandler.Whole<String>() {
@Override
public void onMessage(String message) {
System.out.println(message);
}
});
session.setMaxIdleTimeout(timeout);
session.getBasicRemote().sendText("timeout");
Thread.sleep(2 * timeout);
}

}

public static class Config extends WsContextListener {

public static final String PATH_MAX_IDLE_TIMEOUT = "/MaxIdleTimeout";

@Override
public void contextInitialized(ServletContextEvent sce) {
super.contextInitialized(sce);
ServerContainer sc =
(ServerContainer) sce.getServletContext().getAttribute(
Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
try {
sc.addEndpoint(MaxIdleTimeout.class);
} catch (DeploymentException e) {
throw new IllegalStateException(e);
}
}

@ServerEndpoint("/MaxIdleTimeout/{timeout}")
public static class MaxIdleTimeout {

@OnMessage
public void echoTextMessage(@PathParam("timeout") long timeout, Session session, String msg) {
try {
session.getBasicRemote().sendText(msg + "=" + timeout);
Thread.sleep(timeout);
session.getBasicRemote().sendText("After sleep...");
} catch (Exception e) {
try {
session.close();
} catch (IOException e1) {
// Ignore
}
}
}
}
}

private int getOpenCount(Set<Session> sessions) {
int result = 0;
Expand Down

0 comments on commit 74ebb85

Please sign in to comment.