use of org.apache.catalina.Context in project tomcat by apache.
the class TestRequest method testBug49424NoChunking.
@Test
public void testBug49424NoChunking() throws Exception {
Tomcat tomcat = getTomcatInstance();
Context root = tomcat.addContext("", System.getProperty("java.io.tmpdir"));
Tomcat.addServlet(root, "Bug37794", new Bug37794Servlet());
root.addServletMappingDecoded("/", "Bug37794");
tomcat.start();
HttpURLConnection conn = getConnection("http://localhost:" + getPort() + "/");
InputStream is = conn.getInputStream();
assertNotNull(is);
}
use of org.apache.catalina.Context in project tomcat by apache.
the class TestRequest method testLoginLogout.
/*
* Test case for {@link Request#login(String, String)} and
* {@link Request#logout()}.
*/
@Test
public void testLoginLogout() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
LoginConfig config = new LoginConfig();
config.setAuthMethod("BASIC");
ctx.setLoginConfig(config);
ctx.getPipeline().addValve(new BasicAuthenticator());
Tomcat.addServlet(ctx, "servlet", new LoginLogoutServlet());
ctx.addServletMappingDecoded("/", "servlet");
TesterMapRealm realm = new TesterMapRealm();
realm.addUser(LoginLogoutServlet.USER, LoginLogoutServlet.PWD);
ctx.setRealm(realm);
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals(LoginLogoutServlet.OK, res.toString());
}
use of org.apache.catalina.Context in project tomcat by apache.
the class TestRequest method doBug56501.
private void doBug56501(String deployPath, String requestPath, String expected) throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext(deployPath, null);
Tomcat.addServlet(ctx, "servlet", new Bug56501Servlet());
ctx.addServletMappingDecoded("/*", "servlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + requestPath);
String resultPath = res.toString();
if (resultPath == null) {
resultPath = "";
}
assertEquals(expected, resultPath);
}
use of org.apache.catalina.Context in project tomcat by apache.
the class TestResponse method testCharset.
/*
* Tests an issue noticed during the investigation of BZ 52811.
*/
@Test
public void testCharset() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
Tomcat.addServlet(ctx, "servlet", new CharsetServlet());
ctx.addServletMappingDecoded("/", "servlet");
tomcat.start();
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
assertEquals("OK", bc.toString());
}
use of org.apache.catalina.Context in project tomcat by apache.
the class TestTomcatClassLoader method testDefaultClassLoader.
@Test
public void testDefaultClassLoader() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
Tomcat.addServlet(ctx, "ClassLoaderReport", new ClassLoaderReport(null));
ctx.addServletMappingDecoded("/", "ClassLoaderReport");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("WEBAPP,SYSTEM,OTHER,", res.toString());
}
Aggregations