use of jakarta.websocket.Endpoint in project tomcat by apache.
the class TestWsWebSocketContainerGetOpenSessions method testClientAClientBProgAProgB.
@Test
public void testClientAClientBProgAProgB() throws Exception {
Endpoint client1 = new ClientEndpointA();
Endpoint client2 = new ClientEndpointB();
doTest(client1, client2, "/progA", "/progB", 2, 2, 2, 2);
}
use of jakarta.websocket.Endpoint in project tomcat by apache.
the class TestWsWebSocketContainerGetOpenSessions method testClientAClientAProgAProgA.
@Test
public void testClientAClientAProgAProgA() throws Exception {
Endpoint client1 = new ClientEndpointA();
Endpoint client2 = new ClientEndpointA();
doTest(client1, client2, "/progA", "/progA", 2, 2, 4, 4);
}
use of jakarta.websocket.Endpoint in project tomcat by apache.
the class TestWsWebSocketContainerGetOpenSessions method testClientAClientAProgAProgB.
@Test
public void testClientAClientAProgAProgB() throws Exception {
Endpoint client1 = new ClientEndpointA();
Endpoint client2 = new ClientEndpointA();
doTest(client1, client2, "/progA", "/progB", 2, 2, 2, 2);
}
use of jakarta.websocket.Endpoint in project tomcat by apache.
the class TestWsWebSocketContainerGetOpenSessions method testClientAClientBPojoAProgB.
@Test
public void testClientAClientBPojoAProgB() throws Exception {
Endpoint client1 = new ClientEndpointA();
Endpoint client2 = new ClientEndpointB();
doTest(client1, client2, "/pojoA", "/progB", 2, 2, 2, 2);
}
use of jakarta.websocket.Endpoint in project tomcat by apache.
the class TestWsWebSocketContainerGetOpenSessions method doTest.
private void doTest(Endpoint client1, Endpoint client2, String server1, String server2, int client1Count, int client2Count, int server1Count, int server2Count) throws Exception {
Tracker.reset();
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.addServletMappingDecoded("/", "default");
tomcat.start();
WebSocketContainer wsContainer = ContainerProvider.getWebSocketContainer();
Session sClient1Server1 = createSession(wsContainer, client1, "client1", server1);
Session sClient1Server2 = createSession(wsContainer, client1, "client1", server2);
Session sClient2Server1 = createSession(wsContainer, client2, "client2", server1);
Session sClient2Server2 = createSession(wsContainer, client2, "client2", server2);
int delayCount = 0;
// but some CI systems get be slow at times.
while (Tracker.getUpdateCount() < 8 && delayCount < 400) {
Thread.sleep(50);
delayCount++;
}
Assert.assertTrue(Tracker.dump(), Tracker.checkRecord("client1", client1Count));
Assert.assertTrue(Tracker.dump(), Tracker.checkRecord("client2", client2Count));
// Note: need to strip leading '/' from path
Assert.assertTrue(Tracker.dump(), Tracker.checkRecord(server1.substring(1), server1Count));
Assert.assertTrue(Tracker.dump(), Tracker.checkRecord(server2.substring(1), server2Count));
sClient1Server1.close();
sClient1Server2.close();
sClient2Server1.close();
sClient2Server2.close();
}
Aggregations