use of cn.taketoday.web.servlet.view.InternalResourceViewResolver in project today-infrastructure by TAKETODAY.
the class ContentNegotiatingViewResolverTests method nestedViewResolverIsNotSpringBean.
@Test
public void nestedViewResolverIsNotSpringBean() throws Exception {
StaticWebServletApplicationContext webAppContext = new StaticWebServletApplicationContext();
webAppContext.setServletContext(new MockServletContext());
webAppContext.refresh();
InternalResourceViewResolver nestedResolver = new InternalResourceViewResolver();
nestedResolver.setApplicationContext(webAppContext);
nestedResolver.setViewClass(InternalResourceView.class);
viewResolver.setViewResolvers(new ArrayList<>(Arrays.asList(nestedResolver)));
FixedContentNegotiationStrategy fixedStrategy = new FixedContentNegotiationStrategy(MediaType.TEXT_HTML);
viewResolver.setContentNegotiationManager(new ContentNegotiationManager(fixedStrategy));
viewResolver.afterPropertiesSet();
String viewName = "view";
Locale locale = Locale.ENGLISH;
View result = viewResolver.resolveViewName(viewName, locale);
assertThat(result).as("Invalid view").isNotNull();
}
use of cn.taketoday.web.servlet.view.InternalResourceViewResolver in project today-infrastructure by TAKETODAY.
the class ViewResolverTests method cacheRemoval.
@Test
public void cacheRemoval() throws Exception {
this.wac.refresh();
InternalResourceViewResolver vr = new InternalResourceViewResolver();
vr.setViewClass(JstlView.class);
vr.setApplicationContext(this.wac);
View view = vr.resolveViewName("example1", Locale.getDefault());
View cached = vr.resolveViewName("example1", Locale.getDefault());
assertThat(cached).isSameAs(view);
vr.removeFromCache("example1", Locale.getDefault());
cached = vr.resolveViewName("example1", Locale.getDefault());
// the chance of having the same reference (hashCode) twice is negligible.
assertThat(cached).as("removed from cache").isNotSameAs(view);
}
use of cn.taketoday.web.servlet.view.InternalResourceViewResolver in project today-infrastructure by TAKETODAY.
the class WebMvcAutoConfiguration method defaultViewResolver.
@Component
@ConditionalOnMissingBean
public InternalResourceViewResolver defaultViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix(this.mvcProperties.getView().getPrefix());
resolver.setSuffix(this.mvcProperties.getView().getSuffix());
return resolver;
}
use of cn.taketoday.web.servlet.view.InternalResourceViewResolver in project today-framework by TAKETODAY.
the class ViewResolverRegistryTests method customViewResolver.
@Test
public void customViewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver("/", ".jsp");
this.registry.viewResolver(viewResolver);
assertThat(this.registry.getViewResolvers().get(0)).isSameAs(viewResolver);
}
use of cn.taketoday.web.servlet.view.InternalResourceViewResolver in project today-framework by TAKETODAY.
the class ViewResolverRegistryTests method jspDefaultValues.
@Test
public void jspDefaultValues() {
this.registry.jsp();
InternalResourceViewResolver resolver = checkAndGetResolver(InternalResourceViewResolver.class);
checkPropertyValues(resolver, "prefix", "/WEB-INF/", "suffix", ".jsp");
}
Aggregations