use of org.springframework.web.context.ContextLoader in project spring-framework by spring-projects.
the class RedirectViewTests method updateTargetUrlWithContextLoader.
@Test
public void updateTargetUrlWithContextLoader() throws Exception {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.registerSingleton("requestDataValueProcessor", RequestDataValueProcessorWrapper.class);
MockServletContext servletContext = new MockServletContext();
ContextLoader contextLoader = new ContextLoader(wac);
contextLoader.initWebApplicationContext(servletContext);
try {
RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class);
wac.getBean(RequestDataValueProcessorWrapper.class).setRequestDataValueProcessor(mockProcessor);
RedirectView rv = new RedirectView();
rv.setUrl("/path");
given(mockProcessor.processUrl(request, "/path")).willReturn("/path?key=123");
rv.render(new ModelMap(), request, response);
verify(mockProcessor).processUrl(request, "/path");
} finally {
contextLoader.closeWebApplicationContext(servletContext);
}
}
use of org.springframework.web.context.ContextLoader in project spring-framework by spring-projects.
the class SpringConfiguratorTests method setup.
@Before
public void setup() {
this.servletContext = new MockServletContext();
this.webAppContext = new AnnotationConfigWebApplicationContext();
this.webAppContext.register(Config.class);
this.contextLoader = new ContextLoader(this.webAppContext);
this.contextLoader.initWebApplicationContext(this.servletContext);
this.configurator = new SpringConfigurator();
}
Aggregations