use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.
the class TestDigestAuthenticator method bug54521.
@Test
public void bug54521() throws LifecycleException {
DigestAuthenticator digestAuthenticator = new DigestAuthenticator();
TesterContext context = new TesterContext();
context.setServletContext(new TesterServletContext());
digestAuthenticator.setContainer(context);
digestAuthenticator.start();
Request request = new TesterRequest();
final int count = 1000;
Set<String> nonces = new HashSet<>();
for (int i = 0; i < count; i++) {
nonces.add(digestAuthenticator.generateNonce(request));
}
Assert.assertEquals(count, nonces.size());
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.
the class FileStoreTest method setup.
@BeforeClass
public static void setup() {
TesterContext testerContext = new TesterContext();
testerContext.setServletContext(new TesterServletContext());
manager.setContext(testerContext);
fileStore = new FileStore();
fileStore.setManager(manager);
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.
the class TestStandardJarScanner method skipsInvalidClasspathURLNoFilePartNoFileScheme.
/**
* Tomcat should ignore URLs which do not have a file part and do not use the file scheme.
*/
@Test
public void skipsInvalidClasspathURLNoFilePartNoFileScheme() {
StandardJarScanner scanner = new StandardJarScanner();
LoggingCallback callback = new LoggingCallback();
TesterServletContext context = new TesterServletContext() {
@Override
public ClassLoader getClassLoader() {
URLClassLoader urlClassLoader;
try {
urlClassLoader = new URLClassLoader(new URL[] { new URL("http://felix.extensions:9/") });
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
return urlClassLoader;
}
};
scanner.scan(JarScanType.PLUGGABILITY, context, callback);
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.
the class TestWsServerContainer method testDuplicatePaths13.
/*
* POJO programmatic followed by programmatic duplicate.
*/
@Test(expected = DeploymentException.class)
public void testDuplicatePaths13() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Pojo.class, "/foo").build();
sc.addEndpoint(Pojo.class);
sc.addEndpoint(configA);
}
use of org.apache.tomcat.unittest.TesterServletContext in project tomcat by apache.
the class TestWsServerContainer method testDuplicatePaths01.
@Test(expected = DeploymentException.class)
public void testDuplicatePaths01() 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);
}
Aggregations