use of javax.servlet.MultipartConfigElement in project spring-framework by spring-projects.
the class WebRequestDataBinderIntegrationTests method startJettyServer.
@BeforeClass
public static void startJettyServer() throws Exception {
// Let server pick its own random, available port.
jettyServer = new Server(0);
ServletContextHandler handler = new ServletContextHandler();
MultipartConfigElement multipartConfig = new MultipartConfigElement("");
ServletHolder holder = new ServletHolder(partsServlet);
holder.getRegistration().setMultipartConfig(multipartConfig);
handler.addServlet(holder, "/parts");
holder = new ServletHolder(partListServlet);
holder.getRegistration().setMultipartConfig(multipartConfig);
handler.addServlet(holder, "/partlist");
jettyServer.setHandler(handler);
jettyServer.start();
Connector[] connectors = jettyServer.getConnectors();
NetworkConnector connector = (NetworkConnector) connectors[0];
baseUrl = "http://localhost:" + connector.getLocalPort();
}
use of javax.servlet.MultipartConfigElement in project spring-boot by spring-projects.
the class MultipartConfigFactoryTests method sensibleDefaults.
@Test
public void sensibleDefaults() {
MultipartConfigFactory factory = new MultipartConfigFactory();
MultipartConfigElement config = factory.createMultipartConfig();
assertThat(config.getLocation()).isEqualTo("");
assertThat(config.getMaxFileSize()).isEqualTo(-1L);
assertThat(config.getMaxRequestSize()).isEqualTo(-1L);
assertThat(config.getFileSizeThreshold()).isEqualTo(0);
}
use of javax.servlet.MultipartConfigElement in project spring-boot by spring-projects.
the class MultipartConfigFactoryTests method createWithStringSizes.
@Test
public void createWithStringSizes() throws Exception {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize("1");
factory.setMaxRequestSize("2kB");
factory.setFileSizeThreshold("3Mb");
MultipartConfigElement config = factory.createMultipartConfig();
assertThat(config.getMaxFileSize()).isEqualTo(1L);
assertThat(config.getMaxRequestSize()).isEqualTo(2 * 1024L);
assertThat(config.getFileSizeThreshold()).isEqualTo(3 * 1024 * 1024);
}
use of javax.servlet.MultipartConfigElement in project spring-boot by spring-projects.
the class MultipartConfigFactoryTests method create.
@Test
public void create() throws Exception {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setLocation("loc");
factory.setMaxFileSize(1);
factory.setMaxRequestSize(2);
factory.setFileSizeThreshold(3);
MultipartConfigElement config = factory.createMultipartConfig();
assertThat(config.getLocation()).isEqualTo("loc");
assertThat(config.getMaxFileSize()).isEqualTo(1L);
assertThat(config.getMaxRequestSize()).isEqualTo(2L);
assertThat(config.getFileSizeThreshold()).isEqualTo(3);
}
use of javax.servlet.MultipartConfigElement in project spring-boot by spring-projects.
the class ServletContextInitializerBeans method addAdaptableBeans.
@SuppressWarnings("unchecked")
private void addAdaptableBeans(ListableBeanFactory beanFactory) {
MultipartConfigElement multipartConfig = getMultipartConfig(beanFactory);
addAsRegistrationBean(beanFactory, Servlet.class, new ServletRegistrationBeanAdapter(multipartConfig));
addAsRegistrationBean(beanFactory, Filter.class, new FilterRegistrationBeanAdapter());
for (Class<?> listenerType : ServletListenerRegistrationBean.getSupportedTypes()) {
addAsRegistrationBean(beanFactory, EventListener.class, (Class<EventListener>) listenerType, new ServletListenerRegistrationBeanAdapter());
}
}
Aggregations