Search in sources :

Example 1 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project uavstack by uavorg.

the class TomcatPlusIT method onServletStop.

/**
 * onServletStop
 *
 * @param args
 */
public void onServletStop(Object... args) {
    StandardWrapper sw = (StandardWrapper) args[0];
    Servlet servlet = (Servlet) args[1];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());
    context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) Servlet(javax.servlet.Servlet) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Example 2 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method devToolsSwitchesJspServletToDevelopmentMode.

@Test
void devToolsSwitchesJspServletToDevelopmentMode() throws Exception {
    this.context = getContext(() -> initializeAndRun(Config.class));
    TomcatWebServer tomcatContainer = (TomcatWebServer) ((ServletWebServerApplicationContext) this.context).getWebServer();
    Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
    StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
    EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils.getField(jspServletWrapper.getServlet(), "options");
    assertThat(options.getDevelopment()).isTrue();
}
Also used : Container(org.apache.catalina.Container) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) EmbeddedServletOptions(org.apache.jasper.EmbeddedServletOptions) StandardWrapper(org.apache.catalina.core.StandardWrapper) Test(org.junit.jupiter.api.Test)

Example 3 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project tomcat by apache.

the class TestMultipartConfig method testCompleteMultipartConfig.

@Test
public void testCompleteMultipartConfig() throws Exception {
    MultipartDef multipartDef = new MultipartDef();
    multipartDef.setMaxFileSize("1024");
    multipartDef.setMaxRequestSize("10240");
    multipartDef.setFileSizeThreshold("24");
    multipartDef.setLocation("/tmp/foo");
    StandardWrapper servlet = config(multipartDef);
    MultipartConfigElement mce = servlet.getMultipartConfigElement();
    Assert.assertNotNull(mce);
    Assert.assertEquals("/tmp/foo", mce.getLocation());
    Assert.assertEquals(1024, mce.getMaxFileSize());
    Assert.assertEquals(10240, mce.getMaxRequestSize());
    Assert.assertEquals(24, mce.getFileSizeThreshold());
}
Also used : MultipartConfigElement(jakarta.servlet.MultipartConfigElement) MultipartDef(org.apache.tomcat.util.descriptor.web.MultipartDef) StandardWrapper(org.apache.catalina.core.StandardWrapper) Test(org.junit.Test)

Example 4 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project tomcat by apache.

the class TestMultipartConfig method testNoMultipartConfig.

@Test
public void testNoMultipartConfig() throws Exception {
    StandardWrapper servlet = config(null);
    MultipartConfigElement mce = servlet.getMultipartConfigElement();
    Assert.assertNull(mce);
}
Also used : MultipartConfigElement(jakarta.servlet.MultipartConfigElement) StandardWrapper(org.apache.catalina.core.StandardWrapper) Test(org.junit.Test)

Example 5 with StandardWrapper

use of org.apache.catalina.core.StandardWrapper in project tomcat by apache.

the class TestMultipartConfig method config.

private StandardWrapper config(MultipartDef multipartDef) throws Exception {
    MyContextConfig config = new MyContextConfig();
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("test");
    servletDef.setServletClass("org.apache.catalina.startup.ParamServlet");
    servletDef.setMultipartDef(multipartDef);
    webxml.addServlet(servletDef);
    Method m = ContextConfig.class.getDeclaredMethod("configureContext", WebXml.class);
    // Force our way in
    m.setAccessible(true);
    m.invoke(config, webxml);
    StandardWrapper servlet = (StandardWrapper) config.getContext().findChild("test");
    return servlet;
}
Also used : WebXml(org.apache.tomcat.util.descriptor.web.WebXml) ServletDef(org.apache.tomcat.util.descriptor.web.ServletDef) Method(java.lang.reflect.Method) StandardWrapper(org.apache.catalina.core.StandardWrapper)

Aggregations

StandardWrapper (org.apache.catalina.core.StandardWrapper)23 MultipartConfigElement (jakarta.servlet.MultipartConfigElement)6 Test (org.junit.Test)6 Container (org.apache.catalina.Container)5 MultipartDef (org.apache.tomcat.util.descriptor.web.MultipartDef)5 InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)4 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)4 Servlet (javax.servlet.Servlet)4 HashMap (java.util.HashMap)3 Wrapper (org.apache.catalina.Wrapper)3 WebContainer (com.sun.enterprise.web.WebContainer)2 IOException (java.io.IOException)2 StandardContext (org.apache.catalina.core.StandardContext)2 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)2 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)1 WebModule (com.sun.enterprise.web.WebModule)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 Enumeration (java.util.Enumeration)1 Map (java.util.Map)1