use of org.apache.catalina.core.StandardContext in project tomcat70 by apache.
the class TestPersistentManagerIntegration method noSessionCreate_57637.
@Test
public void noSessionCreate_57637() throws IOException, LifecycleException {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
ctx.setDistributable(true);
Tomcat.addServlet(ctx, "DummyServlet", new DummyServlet());
ctx.addServletMapping("/dummy", "DummyServlet");
PersistentManager manager = new PersistentManager();
TesterStore store = new TesterStore();
manager.setStore(store);
manager.setMaxIdleBackup(0);
ctx.setManager(manager);
ctx.addValve(new PersistentValve());
tomcat.start();
Assert.assertEquals(manager.getActiveSessions(), 0);
Assert.assertTrue("No sessions managed", manager.getSessionIdsFull().isEmpty());
Assert.assertEquals("NO_SESSION", getUrl("http://localhost:" + getPort() + "/dummy?no_create_session=true").toString());
Assert.assertEquals(manager.getActiveSessions(), 0);
Assert.assertTrue("No sessions where created", manager.getSessionIdsFull().isEmpty());
}
use of org.apache.catalina.core.StandardContext in project tomcat70 by apache.
the class TestWebappClassLoaderMemoryLeak method testTimerThreadLeak.
@Test
public void testTimerThreadLeak() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
if (ctx instanceof StandardContext) {
((StandardContext) ctx).setClearReferencesStopTimerThreads(true);
}
Tomcat.addServlet(ctx, "taskServlet", new TaskServlet());
ctx.addServletMapping("/", "taskServlet");
tomcat.start();
// This will trigger the timer & thread creation
getUrl("http://localhost:" + getPort() + "/");
// Stop the context
ctx.stop();
Thread[] threads = getThreads();
for (Thread thread : threads) {
if (thread != null && thread.isAlive() && TaskServlet.TIMER_THREAD_NAME.equals(thread.getName())) {
thread.join(5000);
if (thread.isAlive()) {
Assert.fail("Timer thread still running");
}
}
}
}
use of org.apache.catalina.core.StandardContext in project tomcat70 by apache.
the class TestGenerator method testBug48701Fail.
@Test
public void testBug48701Fail() throws Exception {
Tomcat tomcat = getTomcatInstance();
File appDir = new File("test/webapp-3.0");
// app dir is relative to server home
StandardContext ctxt = (StandardContext) tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
// This test needs the JSTL libraries
File lib = new File("webapps/examples/WEB-INF/lib");
ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());
tomcat.start();
int rc = getUrl("http://localhost:" + getPort() + "/test/bug48nnn/bug48701-fail.jsp", new ByteChunk(), null);
Assert.assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, rc);
}
use of org.apache.catalina.core.StandardContext in project tomcat70 by apache.
the class TestParser method testBug56265.
@Test
public void testBug56265() throws Exception {
Tomcat tomcat = getTomcatInstance();
File appDir = new File("test/webapp-3.0");
// app dir is relative to server home
StandardContext ctxt = (StandardContext) tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
// This test needs the JSTL libraries
File lib = new File("webapps/examples/WEB-INF/lib");
ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug56265.jsp");
String result = res.toString();
Assert.assertTrue(result, result.contains("[1: [data-test]: [window.alert('Hello World <&>!')]]"));
Assert.assertTrue(result, result.contains("[2: [data-test]: [window.alert('Hello World <&>!')]]"));
Assert.assertTrue(result, result.contains("[3: [data-test]: [window.alert('Hello 'World <&>'!')]]"));
Assert.assertTrue(result, result.contains("[4: [data-test]: [window.alert('Hello 'World <&>'!')]]"));
}
use of org.apache.catalina.core.StandardContext in project tomcat70 by apache.
the class TestParser method testBug56334And56561.
@Test
public void testBug56334And56561() throws Exception {
Tomcat tomcat = getTomcatInstance();
File appDir = new File("test/webapp-3.0");
// app dir is relative to server home
StandardContext ctxt = (StandardContext) tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
// This test needs the JSTL libraries
File lib = new File("webapps/examples/WEB-INF/lib");
ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug56334and56561.jspx");
String result = res.toString();
// NOTE: The expected values must themselves be \ escaped below
Assert.assertTrue(result, result.contains("01a\\?resize01a"));
Assert.assertTrue(result, result.contains("01b\\\\x\\?resize01b"));
Assert.assertTrue(result, result.contains("<set data-value=\"02a\\\\?resize02a\"/>"));
Assert.assertTrue(result, result.contains("<set data-value=\"02b\\\\\\\\x\\\\?resize02b\"/>"));
Assert.assertTrue(result, result.contains("<set data-value=\"03a\\?resize03a\"/>"));
Assert.assertTrue(result, result.contains("<set data-value=\"03b\\\\x\\?resize03b\"/>"));
Assert.assertTrue(result, result.contains("<04a\\?resize04a/>"));
Assert.assertTrue(result, result.contains("<04b\\\\x\\?resize04b/>"));
Assert.assertTrue(result, result.contains("<set data-value=\"05a$${&\"/>"));
Assert.assertTrue(result, result.contains("<set data-value=\"05b$${&2\"/>"));
Assert.assertTrue(result, result.contains("<set data-value=\"05c##{>hello<\"/>"));
Assert.assertTrue(result, result.contains("05x:<set data-value=\"\"/>"));
Assert.assertTrue(result, result.contains("<set xmlns:foo=\"urn:06a\\bar\\baz\"/>"));
Assert.assertTrue(result, result.contains("07a:<set data-value=\"\\?resize\"/>"));
Assert.assertTrue(result, result.contains("07b:<set data-content=\"\\?resize=.+\"/>"));
Assert.assertTrue(result, result.contains("07c:<set data-content=\"\\?resize=.+\"/>"));
Assert.assertTrue(result, result.contains("07d:<set data-content=\"false\"/>"));
Assert.assertTrue(result, result.contains("07e:<set data-content=\"false\"/>"));
Assert.assertTrue(result, result.contains("07f:<set data-content=\"\\\'something\'\"/>"));
Assert.assertTrue(result, result.contains("07g:<set data-content=\"\\\'something\'\"/>"));
}
Aggregations