@Bean @ConditionalOnBean(GroovyMarkupViewResolver.class) public LiteDeviceDelegatingViewResolver deviceDelegatingGroovyMarkupViewResolver( DeviceDelegatingViewResolverFactory factory, GroovyMarkupViewResolver viewResolver) { return factory.createViewResolver(viewResolver); }
@Bean @ConditionalOnMissingBean(name = "groovyMarkupViewResolver") public GroovyMarkupViewResolver groovyMarkupViewResolver() { GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver(); this.properties.applyToViewResolver(resolver); return resolver; }
@Test public void deviceDelegatingGroovyMarkupViewResolver() throws Exception { load(Collections.<Class<?>>singletonList(GroovyTemplateAutoConfiguration.class), "spring.mobile.devicedelegatingviewresolver.enabled:true"); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)) .hasSize(2); assertLiteDeviceDelegatingViewResolver( this.context.getBean(GroovyMarkupViewResolver.class), "deviceDelegatingGroovyMarkupViewResolver"); }
private MockHttpServletResponse render(String viewName, Locale locale) throws Exception { LocaleContextHolder.setLocale(locale); GroovyMarkupViewResolver resolver = this.context .getBean(GroovyMarkupViewResolver.class); View view = resolver.resolveViewName(viewName, locale); assertThat(view).isNotNull(); HttpServletRequest request = new MockHttpServletRequest(); request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context); MockHttpServletResponse response = new MockHttpServletResponse(); view.render(null, request, response); return response; }
private MockHttpServletResponse render(String viewName, Locale locale) throws Exception { LocaleContextHolder.setLocale(locale); GroovyMarkupViewResolver resolver = this.context .getBean(GroovyMarkupViewResolver.class); View view = resolver.resolveViewName(viewName, locale); assertThat(view, notNullValue()); HttpServletRequest request = new MockHttpServletRequest(); request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context); MockHttpServletResponse response = new MockHttpServletResponse(); view.render(null, request, response); return response; }
@Bean @ConditionalOnMissingBean(name = "groovyMarkupViewResolver") public GroovyMarkupViewResolver groovyMarkupViewResolver() { GroovyMarkupViewResolver resolver = super.groovyMarkupViewResolver(); resolver.setViewClass(FixGroovyMarkupView.class); return resolver; }
private GroovyMarkupRegistration() { super(new GroovyMarkupViewResolver()); getViewResolver().setSuffix(".tpl"); }
@Test public void groovyMarkup() { this.registry.groovy().prefix("/").suffix(".groovy").cache(true); GroovyMarkupViewResolver resolver = checkAndGetResolver(GroovyMarkupViewResolver.class); checkPropertyValues(resolver, "prefix", "/", "suffix", ".groovy", "cacheLimit", 1024); }
@Test public void groovyMarkupDefaultValues() { this.registry.groovy(); GroovyMarkupViewResolver resolver = checkAndGetResolver(GroovyMarkupViewResolver.class); checkPropertyValues(resolver, "prefix", "", "suffix", ".tpl"); }
@Test public void defaultConfiguration() { registerAndRefreshContext(); assertThat(this.context.getBean(GroovyMarkupViewResolver.class)).isNotNull(); }
@Test public void disableCache() { registerAndRefreshContext("spring.groovy.template.cache:false"); assertThat(this.context.getBean(GroovyMarkupViewResolver.class).getCacheLimit()) .isEqualTo(0); }
@Test public void defaultConfiguration() { registerAndRefreshContext(); assertThat(this.context.getBean(GroovyMarkupViewResolver.class), notNullValue()); }
@Test public void disableCache() { registerAndRefreshContext("spring.groovy.template.cache:false"); assertThat(this.context.getBean(GroovyMarkupViewResolver.class).getCacheLimit(), equalTo(0)); }