use of cn.taketoday.framework.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project today-infrastructure by TAKETODAY.
the class ServletComponentScanIntegrationTests method indexedComponentsAreRegistered.
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
void indexedComponentsAreRegistered(String serverName, Class<?> configuration) throws IOException {
writeIndex(this.temp);
this.context = new AnnotationConfigServletWebServerApplicationContext();
try (URLClassLoader classLoader = new URLClassLoader(new URL[] { this.temp.toURI().toURL() }, getClass().getClassLoader())) {
this.context.setClassLoader(classLoader);
this.context.register(configuration);
new ServerPortInfoApplicationContextInitializer().initialize(this.context);
this.context.refresh();
String port = this.context.getEnvironment().getProperty("local.server.port");
String response = new RestTemplate().getForObject("http://localhost:" + port + "/test", String.class);
assertThat(response).isEqualTo("alpha bravo charlie");
}
}
use of cn.taketoday.framework.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project today-framework by TAKETODAY.
the class ServletComponentScanIntegrationTests method componentsAreRegistered.
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
void componentsAreRegistered(String serverName, Class<?> configuration) {
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(configuration);
new ServerPortInfoApplicationContextInitializer().initialize(this.context);
this.context.refresh();
String port = this.context.getEnvironment().getProperty("local.server.port");
String response = new RestTemplate().getForObject("http://localhost:" + port + "/test", String.class);
assertThat(response).isEqualTo("alpha bravo charlie");
}
use of cn.taketoday.framework.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project today-framework by TAKETODAY.
the class ServletComponentScanIntegrationTests method indexedComponentsAreRegistered.
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
void indexedComponentsAreRegistered(String serverName, Class<?> configuration) throws IOException {
writeIndex(this.temp);
this.context = new AnnotationConfigServletWebServerApplicationContext();
try (URLClassLoader classLoader = new URLClassLoader(new URL[] { this.temp.toURI().toURL() }, getClass().getClassLoader())) {
this.context.setClassLoader(classLoader);
this.context.register(configuration);
new ServerPortInfoApplicationContextInitializer().initialize(this.context);
this.context.refresh();
String port = this.context.getEnvironment().getProperty("local.server.port");
String response = new RestTemplate().getForObject("http://localhost:" + port + "/test", String.class);
assertThat(response).isEqualTo("alpha bravo charlie");
}
}
use of cn.taketoday.framework.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project today-framework by TAKETODAY.
the class ServletComponentScanIntegrationTests method multipartConfigIsHonoured.
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
void multipartConfigIsHonoured(String serverName, Class<?> configuration) {
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(configuration);
new ServerPortInfoApplicationContextInitializer().initialize(this.context);
this.context.refresh();
@SuppressWarnings("rawtypes") Map<String, ServletRegistrationBean> beans = this.context.getBeansOfType(ServletRegistrationBean.class);
ServletRegistrationBean<?> servletRegistrationBean = beans.get(TestMultipartServlet.class.getName());
assertThat(servletRegistrationBean).isNotNull();
MultipartConfigElement multipartConfig = servletRegistrationBean.getMultipartConfig();
assertThat(multipartConfig).isNotNull();
assertThat(multipartConfig.getLocation()).isEqualTo("test");
assertThat(multipartConfig.getMaxRequestSize()).isEqualTo(2048);
assertThat(multipartConfig.getMaxFileSize()).isEqualTo(1024);
assertThat(multipartConfig.getFileSizeThreshold()).isEqualTo(512);
}
use of cn.taketoday.framework.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project today-infrastructure by TAKETODAY.
the class ServletComponentScanIntegrationTests method multipartConfigIsHonoured.
@ParameterizedTest(name = "{0}")
@MethodSource("testConfiguration")
void multipartConfigIsHonoured(String serverName, Class<?> configuration) {
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(configuration);
new ServerPortInfoApplicationContextInitializer().initialize(this.context);
this.context.refresh();
@SuppressWarnings("rawtypes") Map<String, ServletRegistrationBean> beans = this.context.getBeansOfType(ServletRegistrationBean.class);
ServletRegistrationBean<?> servletRegistrationBean = beans.get(TestMultipartServlet.class.getName());
assertThat(servletRegistrationBean).isNotNull();
MultipartConfigElement multipartConfig = servletRegistrationBean.getMultipartConfig();
assertThat(multipartConfig).isNotNull();
assertThat(multipartConfig.getLocation()).isEqualTo("test");
assertThat(multipartConfig.getMaxRequestSize()).isEqualTo(2048);
assertThat(multipartConfig.getMaxFileSize()).isEqualTo(1024);
assertThat(multipartConfig.getFileSizeThreshold()).isEqualTo(512);
}
Aggregations