use of org.apache.tomcat.unittest.TesterServletContext in project tomcat 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());
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.
the class TestWsServerContainer method testDuplicatePaths_01.
@Test(expected = javax.websocket.DeploymentException.class)
public void testDuplicatePaths_01() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/a/b/c").build();
ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/a/b/c").build();
sc.addEndpoint(configA);
sc.addEndpoint(configB);
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.
the class TestStandardJarScanner method testWebappClassPath.
@Test
public void testWebappClassPath() {
StandardJarScanner scanner = new StandardJarScanner();
scanner.setScanClassPath(true);
// When running the test on Java 9, one or more URLs to jimage files may
// be returned. By setting the scanAllFiles option, a callback will be
// generated for these files which in turn will mean the number of URLs
// and the number of call backs will agree and this test will pass.
// There is a TODO in StandardJarScanner to add 'proper' Java 9 support.
scanner.setScanAllFiles(true);
LoggingCallback callback = new LoggingCallback();
scanner.scan(JarScanType.PLUGGABILITY, new TesterServletContext(), callback);
List<String> callbacks = callback.getCallbacks();
ClassLoader cl = TesterServletContext.class.getClassLoader();
if (cl instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) cl).getURLs();
int size;
if (urls == null) {
size = 0;
} else {
size = urls.length;
}
// Some JREs (Gump) construct a class path that includes JARs that
// reference additional JARs via the Class-Path attribute of the
// Manifest. These JARs are not returned in ClassLoader.getURLs().
// Therefore, this test looks for at least as many JARs as there are
// URLs but it can't check for an exact match.
Assert.assertTrue("[" + callbacks.size() + "] callbacks but expected at least [" + size + "]", callbacks.size() >= size);
} else {
Assert.fail("Unexpected class loader type: " + cl.getClass().getName());
}
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat70 by apache.
the class TestWsServerContainer method testDuplicatePaths_03.
@Test(expected = javax.websocket.DeploymentException.class)
public void testDuplicatePaths_03() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/a/b/{var1}").build();
ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/a/b/{var2}").build();
sc.addEndpoint(configA);
sc.addEndpoint(configB);
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat70 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());
}
Aggregations