use of org.springframework.web.servlet.view.InternalResourceView in project spring-framework by spring-projects.
the class ViewMethodReturnValueHandlerTests method returnView.
@Test
public void returnView() throws Exception {
InternalResourceView view = new InternalResourceView("testView");
this.handler.handleReturnValue(view, createReturnValueParam("view"), this.mavContainer, this.webRequest);
assertSame(view, this.mavContainer.getView());
}
use of org.springframework.web.servlet.view.InternalResourceView in project spring-framework by spring-projects.
the class FreeMarkerViewTests method freeMarkerViewResolver.
@Test
public void freeMarkerViewResolver() throws Exception {
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
configurer.setConfiguration(new TestConfiguration());
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(new MockServletContext());
wac.getBeanFactory().registerSingleton("configurer", configurer);
wac.refresh();
FreeMarkerViewResolver vr = new FreeMarkerViewResolver("prefix_", "_suffix");
vr.setApplicationContext(wac);
View view = vr.resolveViewName("test", Locale.CANADA);
assertEquals("Correct view class", FreeMarkerView.class, view.getClass());
assertEquals("Correct URL", "prefix_test_suffix", ((FreeMarkerView) view).getUrl());
view = vr.resolveViewName("non-existing", Locale.CANADA);
assertNull(view);
view = vr.resolveViewName("redirect:myUrl", Locale.getDefault());
assertEquals("Correct view class", RedirectView.class, view.getClass());
assertEquals("Correct URL", "myUrl", ((RedirectView) view).getUrl());
view = vr.resolveViewName("forward:myUrl", Locale.getDefault());
assertEquals("Correct view class", InternalResourceView.class, view.getClass());
assertEquals("Correct URL", "myUrl", ((InternalResourceView) view).getUrl());
}
Aggregations