use of org.apache.catalina.core.StandardContext in project uavstack by uavorg.
the class TomcatPlusIT method onAppStop.
/**
* onAppStop
*
* @param args
*/
public void onAppStop(Object... args) {
StandardContext sc = (StandardContext) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED);
context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
context.put(InterceptConstants.CONTEXTPATH, ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true));
context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
iSupport.doIntercept(context);
}
use of org.apache.catalina.core.StandardContext in project uavstack by uavorg.
the class TomcatPlusIT method onAppStarting.
/**
* onAppStarting
*
* @param args
*/
public void onAppStarting(Object... args) {
// release the left contexts
StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_INIT);
StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_CREATE);
StandardContext sc = (StandardContext) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT);
context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
context.put(InterceptConstants.CONTEXTPATH, ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true));
context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
iSupport.doIntercept(context);
}
use of org.apache.catalina.core.StandardContext in project uavstack by uavorg.
the class TomcatPlusIT method onAppStart.
/**
* onAppStart
*
* @param args
*/
public void onAppStart(Object... args) {
StandardContext sc = (StandardContext) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED);
context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
context.put(InterceptConstants.CONTEXTPATH, ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true));
context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
iSupport.doIntercept(context);
}
use of org.apache.catalina.core.StandardContext in project tomcat by apache.
the class TestHttpServlet method testBug53454.
@Test
public void testBug53454() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
// Map the test Servlet
LargeBodyServlet largeBodyServlet = new LargeBodyServlet();
Tomcat.addServlet(ctx, "largeBodyServlet", largeBodyServlet);
ctx.addServletMappingDecoded("/", "largeBodyServlet");
tomcat.start();
Map<String, List<String>> resHeaders = new HashMap<>();
int rc = headUrl("http://localhost:" + getPort() + "/", new ByteChunk(), resHeaders);
Assert.assertEquals(HttpServletResponse.SC_OK, rc);
Assert.assertEquals(LargeBodyServlet.RESPONSE_LENGTH, resHeaders.get("Content-Length").get(0));
}
use of org.apache.catalina.core.StandardContext in project tomcat by apache.
the class TestHttpServlet method testBug57602.
/*
* Verifies that the same Content-Length is returned for both GET and HEAD
* operations when a Servlet includes content from another Servlet
*/
@Test
public void testBug57602() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
Bug57602ServletOuter outer = new Bug57602ServletOuter();
Tomcat.addServlet(ctx, "Bug57602ServletOuter", outer);
ctx.addServletMappingDecoded("/outer", "Bug57602ServletOuter");
Bug57602ServletInner inner = new Bug57602ServletInner();
Tomcat.addServlet(ctx, "Bug57602ServletInner", inner);
ctx.addServletMappingDecoded("/inner", "Bug57602ServletInner");
tomcat.start();
Map<String, List<String>> resHeaders = new HashMap<>();
String path = "http://localhost:" + getPort() + "/outer";
ByteChunk out = new ByteChunk();
int rc = getUrl(path, out, resHeaders);
Assert.assertEquals(HttpServletResponse.SC_OK, rc);
String length = resHeaders.get("Content-Length").get(0);
Assert.assertEquals(Long.parseLong(length), out.getLength());
out.recycle();
rc = headUrl(path, out, resHeaders);
Assert.assertEquals(HttpServletResponse.SC_OK, rc);
Assert.assertEquals(0, out.getLength());
Assert.assertEquals(length, resHeaders.get("Content-Length").get(0));
tomcat.stop();
}
Aggregations