Polish "Configure a temporary directory with Undertow"

See gh-17778
pull/17861/head
Stephane Nicoll 5 years ago
parent 0388f954af
commit 1b3a6d1616

@ -148,6 +148,16 @@ public class MultipartAutoConfigurationTests {
.isSameAs(this.context.getBean(DispatcherServlet.class).getMultipartResolver()); .isSameAs(this.context.getBean(DispatcherServlet.class).getMultipartResolver());
} }
@Test
public void webServerWithNonAbsoluteMultipartLocationUndertowConfiguration() {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithNonAbsolutePathUndertow.class, BaseConfiguration.class);
this.context.getBean(MultipartConfigElement.class);
verifyServletWorks();
assertThat(this.context.getBean(StandardServletMultipartResolver.class))
.isSameAs(this.context.getBean(DispatcherServlet.class).getMultipartResolver());
}
@Test @Test
public void webServerWithMultipartConfigDisabled() { public void webServerWithMultipartConfigDisabled() {
testWebServerWithCustomMultipartConfigEnabledSetting("false", 0); testWebServerWithCustomMultipartConfigEnabledSetting("false", 0);
@ -365,6 +375,27 @@ public class MultipartAutoConfigurationTests {
} }
@Configuration
@EnableWebMvc
public static class WebServerWithNonAbsolutePathUndertow {
@Bean
MultipartConfigElement multipartConfigElement() {
return new MultipartConfigElement("test/not-absolute");
}
@Bean
UndertowServletWebServerFactory webServerFactory() {
return new UndertowServletWebServerFactory();
}
@Bean
WebController webController() {
return new WebController();
}
}
@Configuration @Configuration
public static class WebServerWithCustomMultipartResolver { public static class WebServerWithCustomMultipartResolver {

@ -259,7 +259,6 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
deployment.setClassLoader(getServletClassLoader()); deployment.setClassLoader(getServletClassLoader());
deployment.setContextPath(getContextPath()); deployment.setContextPath(getContextPath());
deployment.setDisplayName(getDisplayName()); deployment.setDisplayName(getDisplayName());
deployment.setTempDir(new File(System.getProperty("java.io.tmpdir")));
deployment.setDeploymentName("spring-boot"); deployment.setDeploymentName("spring-boot");
if (isRegisterDefaultServlet()) { if (isRegisterDefaultServlet()) {
deployment.addServlet(Servlets.servlet("default", DefaultServlet.class)); deployment.addServlet(Servlets.servlet("default", DefaultServlet.class));
@ -267,6 +266,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
configureErrorPages(deployment); configureErrorPages(deployment);
deployment.setServletStackTraces(ServletStackTraces.NONE); deployment.setServletStackTraces(ServletStackTraces.NONE);
deployment.setResourceManager(getDocumentRootResourceManager()); deployment.setResourceManager(getDocumentRootResourceManager());
deployment.setTempDir(createTempDir("undertow"));
deployment.setEagerFilterInit(this.eagerInitFilters); deployment.setEagerFilterInit(this.eagerInitFilters);
configureMimeMappings(deployment); configureMimeMappings(deployment);
for (UndertowDeploymentInfoCustomizer customizer : this.deploymentInfoCustomizers) { for (UndertowDeploymentInfoCustomizer customizer : this.deploymentInfoCustomizers) {

Loading…
Cancel
Save