Search in sources :

Example 21 with TesterServletContext

use of org.apache.tomcat.unittest.TesterServletContext in project tomcat70 by apache.

the class TestWsServerContainer method testDuplicatePaths_04.

@Test
public void testDuplicatePaths_04() 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(javax.websocket.server.ServerEndpointConfig) Test(org.junit.Test) WebSocketBaseTest(org.apache.tomcat.websocket.WebSocketBaseTest)

Example 22 with TesterServletContext

use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.

the class TestWsServerContainer method testDuplicatePaths21.

/*
     * Simulates a class that gets picked up for extending Endpoint and for
     * being annotated.
     */
@Test(expected = DeploymentException.class)
public void testDuplicatePaths21() throws Exception {
    WsServerContainer sc = new WsServerContainer(new TesterServletContext());
    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(PojoTemplate.class, "/foo/{a}").build();
    sc.addEndpoint(configA, false);
    sc.addEndpoint(PojoTemplate.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 23 with TesterServletContext

use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.

the class TestWsServerContainer method testDuplicatePaths22.

/*
     * POJO auto deployment followed by programmatic duplicate. Keep POJO.
     */
@Test
public void testDuplicatePaths22() throws Exception {
    WsServerContainer sc = new WsServerContainer(new TesterServletContext());
    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(PojoTemplate.class, "/foo/{a}").build();
    sc.addEndpoint(PojoTemplate.class, true);
    sc.addEndpoint(configA);
    Assert.assertNotEquals(configA, sc.findMapping("/foo/{a}").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 24 with TesterServletContext

use of org.apache.tomcat.unittest.TesterServletContext 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 25 with TesterServletContext

use of org.apache.tomcat.unittest.TesterServletContext 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)

Aggregations

TesterServletContext (org.apache.tomcat.unittest.TesterServletContext)28 Test (org.junit.Test)27 WebSocketBaseTest (org.apache.tomcat.websocket.WebSocketBaseTest)24 ServerEndpointConfig (jakarta.websocket.server.ServerEndpointConfig)14 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)10 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 TesterContext (org.apache.tomcat.unittest.TesterContext)2 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1 Request (org.apache.catalina.connector.Request)1 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)1 TesterRequest (org.apache.tomcat.unittest.TesterRequest)1 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)1 BeforeClass (org.junit.BeforeClass)1