use of cn.taketoday.framework.web.servlet.ServletContextInitializer in project today-infrastructure by TAKETODAY.
the class AbstractServletWebServerFactoryTests method multipleConfigurations.
@Test
void multipleConfigurations() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
ServletContextInitializer[] initializers = new ServletContextInitializer[6];
Arrays.setAll(initializers, (i) -> mock(ServletContextInitializer.class));
factory.setInitializers(Arrays.asList(initializers[2], initializers[3]));
factory.addInitializers(initializers[4], initializers[5]);
this.webServer = factory.getWebServer(initializers[0], initializers[1]);
this.webServer.start();
InOrder ordered = inOrder((Object[]) initializers);
for (ServletContextInitializer initializer : initializers) {
then(initializer).should(ordered).onStartup(any(ServletContext.class));
}
}
use of cn.taketoday.framework.web.servlet.ServletContextInitializer in project today-infrastructure by TAKETODAY.
the class ServletWebServerApplicationContextTests method servletContextInitializerBeans.
@Test
void servletContextInitializerBeans() throws Exception {
addWebServerFactoryBean();
ServletContextInitializer initializer1 = mock(ServletContextInitializer.class, withSettings().extraInterfaces(Ordered.class));
given(((Ordered) initializer1).getOrder()).willReturn(1);
ServletContextInitializer initializer2 = mock(ServletContextInitializer.class, withSettings().extraInterfaces(Ordered.class));
given(((Ordered) initializer2).getOrder()).willReturn(2);
this.context.registerBeanDefinition("initializerBean2", beanDefinition(initializer2));
this.context.registerBeanDefinition("initializerBean1", beanDefinition(initializer1));
this.context.refresh();
ServletContext servletContext = getWebServerFactory().getServletContext();
InOrder ordered = inOrder(initializer1, initializer2);
then(initializer1).should(ordered).onStartup(servletContext);
then(initializer2).should(ordered).onStartup(servletContext);
}
use of cn.taketoday.framework.web.servlet.ServletContextInitializer in project today-infrastructure by TAKETODAY.
the class ServletWebServerApplicationContextTests method unorderedServletContextInitializerBeans.
@Test
void unorderedServletContextInitializerBeans() throws Exception {
addWebServerFactoryBean();
ServletContextInitializer initializer1 = mock(ServletContextInitializer.class);
ServletContextInitializer initializer2 = mock(ServletContextInitializer.class);
this.context.registerBeanDefinition("initializerBean2", beanDefinition(initializer2));
this.context.registerBeanDefinition("initializerBean1", beanDefinition(initializer1));
this.context.refresh();
ServletContext servletContext = getWebServerFactory().getServletContext();
then(initializer1).should().onStartup(servletContext);
then(initializer2).should().onStartup(servletContext);
}
use of cn.taketoday.framework.web.servlet.ServletContextInitializer in project today-framework by TAKETODAY.
the class AbstractServletWebServerFactoryTests method multipleConfigurations.
@Test
void multipleConfigurations() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
ServletContextInitializer[] initializers = new ServletContextInitializer[6];
Arrays.setAll(initializers, (i) -> mock(ServletContextInitializer.class));
factory.setInitializers(Arrays.asList(initializers[2], initializers[3]));
factory.addInitializers(initializers[4], initializers[5]);
this.webServer = factory.getWebServer(initializers[0], initializers[1]);
this.webServer.start();
InOrder ordered = inOrder((Object[]) initializers);
for (ServletContextInitializer initializer : initializers) {
then(initializer).should(ordered).onStartup(any(ServletContext.class));
}
}
use of cn.taketoday.framework.web.servlet.ServletContextInitializer in project today-framework by TAKETODAY.
the class ServletWebServerApplicationContext method selfInitialize.
private void selfInitialize(ServletContext servletContext) throws ServletException {
prepareWebApplicationContext(servletContext);
registerApplicationScope(servletContext);
WebApplicationContextUtils.registerEnvironmentBeans(getBeanFactory(), servletContext);
for (ServletContextInitializer beans : getServletContextInitializerBeans()) {
beans.onStartup(servletContext);
}
}
Aggregations