Search in sources :

Example 16 with ServerEndpointConfig

use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.

the class TestWsServerContainer method testDuplicatePaths11.

/*
     * Simulates a class that gets picked up for extending Endpoint and for
     * being annotated.
     */
@Test(expected = DeploymentException.class)
public void testDuplicatePaths11() throws Exception {
    WsServerContainer sc = new WsServerContainer(new TesterServletContext());
    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Pojo.class, "/foo").build();
    sc.addEndpoint(configA, false);
    sc.addEndpoint(Pojo.class, true);
}
Also used : TesterServletContext(org.apache.tomcat.unittest.TesterServletContext) ServerEndpointConfig(jakarta.websocket.server.ServerEndpointConfig) Test(org.junit.Test) WebSocketBaseTest(org.apache.tomcat.websocket.WebSocketBaseTest)

Example 17 with ServerEndpointConfig

use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.

the class TestWsServerContainer method testDuplicatePaths14.

/*
     * POJO auto deployment followed by programmatic on same path.
     */
@Test(expected = DeploymentException.class)
public void testDuplicatePaths14() throws Exception {
    WsServerContainer sc = new WsServerContainer(new TesterServletContext());
    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/foo").build();
    sc.addEndpoint(Pojo.class, true);
    sc.addEndpoint(configA);
}
Also used : TesterServletContext(org.apache.tomcat.unittest.TesterServletContext) ServerEndpointConfig(jakarta.websocket.server.ServerEndpointConfig) Test(org.junit.Test) WebSocketBaseTest(org.apache.tomcat.websocket.WebSocketBaseTest)

Example 18 with ServerEndpointConfig

use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.

the class TestWsServerContainer method testDuplicatePaths23.

/*
     * POJO programmatic followed by programmatic duplicate.
     */
@Test(expected = DeploymentException.class)
public void testDuplicatePaths23() throws Exception {
    WsServerContainer sc = new WsServerContainer(new TesterServletContext());
    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(PojoTemplate.class, "/foo/{a}").build();
    sc.addEndpoint(PojoTemplate.class);
    sc.addEndpoint(configA);
}
Also used : TesterServletContext(org.apache.tomcat.unittest.TesterServletContext) ServerEndpointConfig(jakarta.websocket.server.ServerEndpointConfig) Test(org.junit.Test) WebSocketBaseTest(org.apache.tomcat.websocket.WebSocketBaseTest)

Example 19 with ServerEndpointConfig

use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.

the class TestWsServerContainer method testSpecExample4.

@Test
public void testSpecExample4() throws Exception {
    WsServerContainer sc = new WsServerContainer(new TesterServletContext());
    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/{var1}/d").build();
    ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/b/{var2}").build();
    sc.addEndpoint(configA);
    sc.addEndpoint(configB);
    Assert.assertEquals(configB, sc.findMapping("/b/d").getConfig());
}
Also used : TesterServletContext(org.apache.tomcat.unittest.TesterServletContext) ServerEndpointConfig(jakarta.websocket.server.ServerEndpointConfig) Test(org.junit.Test) WebSocketBaseTest(org.apache.tomcat.websocket.WebSocketBaseTest)

Example 20 with ServerEndpointConfig

use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.

the class TestWsServerContainer method testDuplicatePaths04.

@Test
public void testDuplicatePaths04() throws Exception {
    WsServerContainer sc = new WsServerContainer(new TesterServletContext());
    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/a/{var1}/{var2}").build();
    ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/a/b/{var2}").build();
    sc.addEndpoint(configA);
    sc.addEndpoint(configB);
    Assert.assertEquals(configA, sc.findMapping("/a/x/y").getConfig());
    Assert.assertEquals(configB, sc.findMapping("/a/b/y").getConfig());
}
Also used : TesterServletContext(org.apache.tomcat.unittest.TesterServletContext) ServerEndpointConfig(jakarta.websocket.server.ServerEndpointConfig) Test(org.junit.Test) WebSocketBaseTest(org.apache.tomcat.websocket.WebSocketBaseTest)

Aggregations

ServerEndpointConfig (jakarta.websocket.server.ServerEndpointConfig)20 TesterServletContext (org.apache.tomcat.unittest.TesterServletContext)14 WebSocketBaseTest (org.apache.tomcat.websocket.WebSocketBaseTest)14 Test (org.junit.Test)14 DeploymentException (jakarta.websocket.DeploymentException)4 ServerEndpoint (jakarta.websocket.server.ServerEndpoint)2 ServletException (jakarta.servlet.ServletException)1 Endpoint (jakarta.websocket.Endpoint)1 ServerApplicationConfig (jakarta.websocket.server.ServerApplicationConfig)1 ServerContainer (jakarta.websocket.server.ServerContainer)1 Configurator (jakarta.websocket.server.ServerEndpointConfig.Configurator)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 ApplicationContext (org.springframework.context.ApplicationContext)1