|
27 | 27 | import jakarta.servlet.ServletContext;
|
28 | 28 | import jakarta.servlet.ServletRequest;
|
29 | 29 | import jakarta.servlet.ServletResponse;
|
| 30 | +import jakarta.servlet.annotation.MultipartConfig; |
30 | 31 | import jakarta.servlet.annotation.WebInitParam;
|
31 | 32 | import jakarta.servlet.http.HttpServlet;
|
32 | 33 | import jakarta.servlet.http.HttpServletRequest;
|
|
51 | 52 | * @author Andy Wilkinson
|
52 | 53 | * @author Moritz Halbritter
|
53 | 54 | * @author Daeho Kwon
|
| 55 | + * @author Dmytro Danilenkov |
54 | 56 | */
|
55 | 57 | class ServletContextInitializerBeansTests {
|
56 | 58 |
|
@@ -127,6 +129,13 @@ void shouldApplyServletRegistrationAnnotation() {
|
127 | 129 | assertThat(servletRegistrationBean.getServletName()).isEqualTo("test");
|
128 | 130 | assertThat(servletRegistrationBean.isAsyncSupported()).isFalse();
|
129 | 131 | assertThat(servletRegistrationBean.getUrlMappings()).containsExactly("/test/*");
|
| 132 | + assertThat(servletRegistrationBean.getInitParameters()) |
| 133 | + .containsExactlyInAnyOrderEntriesOf(Map.of("env", "test", "debug", "true")); |
| 134 | + assertThat(servletRegistrationBean.getMultipartConfig()).isNotNull(); |
| 135 | + assertThat(servletRegistrationBean.getMultipartConfig().getLocation()).isEqualTo("/tmp"); |
| 136 | + assertThat(servletRegistrationBean.getMultipartConfig().getMaxFileSize()).isEqualTo(1024); |
| 137 | + assertThat(servletRegistrationBean.getMultipartConfig().getMaxRequestSize()).isEqualTo(4096); |
| 138 | + assertThat(servletRegistrationBean.getMultipartConfig().getFileSizeThreshold()).isEqualTo(128); |
130 | 139 | });
|
131 | 140 | }
|
132 | 141 |
|
@@ -244,7 +253,11 @@ static class ServletConfigurationWithAnnotation {
|
244 | 253 |
|
245 | 254 | @Bean
|
246 | 255 | @ServletRegistration(enabled = false, name = "test", asyncSupported = false, urlMappings = "/test/*",
|
247 |
| - loadOnStartup = 1) |
| 256 | + loadOnStartup = 1, |
| 257 | + initParameters = { @WebInitParam(name = "env", value = "test"), |
| 258 | + @WebInitParam(name = "debug", value = "true") }, |
| 259 | + multipartConfig = @MultipartConfig(location = "/tmp", maxFileSize = 1024, maxRequestSize = 4096, |
| 260 | + fileSizeThreshold = 128)) |
248 | 261 | TestServlet testServlet() {
|
249 | 262 | return new TestServlet();
|
250 | 263 | }
|
|
0 commit comments