use of org.springframework.web.context.ConfigurableWebApplicationContext in project spring-boot by spring-projects.
the class MappingsEndpointTests method servletWebMappings.
@Test
void servletWebMappings() {
Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
new WebApplicationContextRunner(contextSupplier).withUserConfiguration(EndpointConfiguration.class, ServletWebConfiguration.class).run((context) -> {
ContextMappings contextMappings = contextMappings(context);
assertThat(contextMappings.getParentId()).isNull();
assertThat(contextMappings.getMappings()).containsOnlyKeys("dispatcherServlets", "servletFilters", "servlets");
Map<String, List<DispatcherServletMappingDescription>> dispatcherServlets = mappings(contextMappings, "dispatcherServlets");
assertThat(dispatcherServlets).containsOnlyKeys("dispatcherServlet");
List<DispatcherServletMappingDescription> handlerMappings = dispatcherServlets.get("dispatcherServlet");
assertThat(handlerMappings).hasSize(1);
List<ServletRegistrationMappingDescription> servlets = mappings(contextMappings, "servlets");
assertThat(servlets).hasSize(1);
List<FilterRegistrationMappingDescription> filters = mappings(contextMappings, "servletFilters");
assertThat(filters).hasSize(1);
});
}
use of org.springframework.web.context.ConfigurableWebApplicationContext in project spring-boot by spring-projects.
the class MappingsEndpointTests method servletWebMappingsWithAdditionalDispatcherServlets.
@Test
void servletWebMappingsWithAdditionalDispatcherServlets() {
Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
new WebApplicationContextRunner(contextSupplier).withUserConfiguration(EndpointConfiguration.class, ServletWebConfiguration.class, CustomDispatcherServletConfiguration.class).run((context) -> {
ContextMappings contextMappings = contextMappings(context);
Map<String, List<DispatcherServletMappingDescription>> dispatcherServlets = mappings(contextMappings, "dispatcherServlets");
assertThat(dispatcherServlets).containsOnlyKeys("dispatcherServlet", "customDispatcherServletRegistration", "anotherDispatcherServletRegistration");
assertThat(dispatcherServlets.get("dispatcherServlet")).hasSize(1);
assertThat(dispatcherServlets.get("customDispatcherServletRegistration")).hasSize(1);
assertThat(dispatcherServlets.get("anotherDispatcherServletRegistration")).hasSize(1);
});
}
use of org.springframework.web.context.ConfigurableWebApplicationContext in project spring-framework by spring-projects.
the class MessageTagTests method nullMessageSource.
@Test
void nullMessageSource() throws JspException {
PageContext pc = createPageContext();
ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext) RequestContextUtils.findWebApplicationContext((HttpServletRequest) pc.getRequest(), pc.getServletContext());
ctx.close();
MessageTag tag = new MessageTag();
tag.setPageContext(pc);
tag.setCode("test");
tag.setVar("testvar2");
tag.doStartTag();
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
}
use of org.springframework.web.context.ConfigurableWebApplicationContext in project pentaho-platform by pentaho.
the class JAXRSServlet method getAppContext.
@VisibleForTesting
protected ApplicationContext getAppContext() {
ConfigurableWebApplicationContext wac = new XmlWebApplicationContext() {
@Override
protected Resource getResourceByPath(String path) {
return new FileSystemResource(new File(path));
}
};
wac.setServletContext(getServletContext());
wac.setServletConfig(getServletConfig());
wac.setNamespace(getServletName());
String springFile = PentahoSystem.getApplicationContext().getSolutionPath(// $NON-NLS-1$ //$NON-NLS-2$
"system" + File.separator + "pentahoServices.spring.xml");
wac.setConfigLocations(new String[] { springFile });
wac.addBeanFactoryPostProcessor(new PentahoBeanScopeValidatorPostProcessor());
wac.refresh();
return wac;
}
use of org.springframework.web.context.ConfigurableWebApplicationContext in project pentaho-platform by pentaho.
the class SystemGwtRpc method createAppContext.
// Visible For Testing
@NonNull
ApplicationContext createAppContext() {
WebApplicationContext parent = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
ConfigurableWebApplicationContext wac = new XmlWebApplicationContext() {
@Override
protected Resource getResourceByPath(@NonNull String path) {
return new FileSystemResource(new File(path));
}
};
wac.setParent(parent);
wac.setServletContext(getServletContext());
// This code was previously part of the GwtRpcProxyServlet class.
// There were/are really no known uses of this class.
// The only declared System, GWT-RPC service is /ws/gwt/unifiedRepository and is not used by any Pentaho code.
//
// No access to servlet config. Used to be passed, when this code was part of GwtRpcProxyServlet class.
// The GwtRpcProxyServlet servlet had no init parameters configured.
// wac.setServletConfig( getServletConfig() );
// J.I.C. Used to be created with getServerName(), in the GwtRpcProxyServlet class.
wac.setNamespace("GwtRpcProxyServlet");
String springFile = PentahoSystem.getApplicationContext().getSolutionPath("system" + File.separator + "pentahoServices.spring.xml");
wac.setConfigLocations(springFile);
wac.refresh();
return wac;
}
Aggregations