use of cn.taketoday.web.view.RedirectView in project today-framework by TAKETODAY.
the class ViewControllerRegistryTests method getRedirectView.
private RedirectView getRedirectView(String path) {
ParameterizableViewController controller = getController(path);
assertThat(controller.getViewName()).isNull();
assertThat(controller.getView()).isNotNull();
assertThat(controller.getView().getClass()).isEqualTo(RedirectView.class);
return (RedirectView) controller.getView();
}
use of cn.taketoday.web.view.RedirectView in project today-infrastructure by TAKETODAY.
the class FreeMarkerViewTests method freeMarkerViewResolver.
@Test
public void freeMarkerViewResolver() throws Exception {
MockServletContext sc = new MockServletContext();
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
configurer.setConfiguration(new TestConfiguration());
StaticWebServletApplicationContext wac = new StaticWebServletApplicationContext();
wac.setServletContext(sc);
wac.getBeanFactory().registerSingleton("configurer", configurer);
wac.refresh();
FreeMarkerViewResolver vr = new FreeMarkerViewResolver("prefix_", "_suffix");
vr.setApplicationContext(wac);
View view = vr.resolveViewName("test", Locale.CANADA);
assertThat(view.getClass()).as("Correct view class").isEqualTo(FreeMarkerView.class);
assertThat(((FreeMarkerView) view).getUrl()).as("Correct URL").isEqualTo("prefix_test_suffix");
view = vr.resolveViewName("non-existing", Locale.CANADA);
assertThat(view).isNull();
view = vr.resolveViewName("redirect:myUrl", Locale.getDefault());
assertThat(view.getClass()).as("Correct view class").isEqualTo(RedirectView.class);
assertThat(((RedirectView) view).getUrl()).as("Correct URL").isEqualTo("myUrl");
view = vr.resolveViewName("forward:myUrl", Locale.getDefault());
assertThat(view.getClass()).as("Correct view class").isEqualTo(InternalResourceView.class);
assertThat(((InternalResourceView) view).getUrl()).as("Correct URL").isEqualTo("myUrl");
}
Aggregations