@Test public void importsAreSelected() throws Exception { AnnotationMetadata annotationMetadata = new SimpleMetadataReaderFactory() .getMetadataReader(ImportFreemarker.class.getName()) .getAnnotationMetadata(); String[] imports = this.importSelector.selectImports(annotationMetadata); assertThat(imports).containsExactly(FreeMarkerAutoConfiguration.class.getName()); }
@Test public void multipleImportsAreFound() throws Exception { AnnotationMetadata annotationMetadata = new SimpleMetadataReaderFactory() .getMetadataReader(MultipleImports.class.getName()) .getAnnotationMetadata(); String[] imports = this.importSelector.selectImports(annotationMetadata); assertThat(imports).containsOnly(FreeMarkerAutoConfiguration.class.getName(), ThymeleafAutoConfiguration.class.getName()); }
@Test public void deviceDelegatingFreemarkerViewResolver() throws Exception { load(Collections.<Class<?>>singletonList(FreeMarkerAutoConfiguration.class), "spring.mobile.devicedelegatingviewresolver.enabled:true"); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)) .hasSize(2); assertLiteDeviceDelegatingViewResolver( this.context.getBean(FreeMarkerViewResolver.class), "deviceDelegatingFreemarkerViewResolver"); }
@Test public void deviceDelegatingViewResolverDisabled() throws Exception { load(Arrays.asList(FreeMarkerAutoConfiguration.class, GroovyTemplateAutoConfiguration.class, MustacheAutoConfiguration.class, ThymeleafAutoConfiguration.class), "spring.mobile.devicedelegatingviewresolver.enabled:false"); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)) .hasSize(0); }
@Test public void classExclusionsAreApplied() { configureExclusions(new String[] { FreeMarkerAutoConfiguration.class.getName() }, new String[0], new String[0]); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName()); }
@Test public void propertyExclusionsAreApplied() { configureExclusions(new String[0], new String[0], new String[] { FreeMarkerAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName()); }
@Test public void severalPropertyExclusionsAreApplied() { configureExclusions(new String[0], new String[0], new String[] { FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName()); }
@Test public void severalPropertyYamlExclusionsAreApplied() { configureExclusions(new String[0], new String[0], new String[0]); this.environment.setProperty("spring.autoconfigure.exclude[0]", FreeMarkerAutoConfiguration.class.getName()); this.environment.setProperty("spring.autoconfigure.exclude[1]", VelocityAutoConfiguration.class.getName()); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName()); }
@Test public void combinedExclusionsAreApplied() { configureExclusions(new String[] { VelocityAutoConfiguration.class.getName() }, new String[] { FreeMarkerAutoConfiguration.class.getName() }, new String[] { ThymeleafAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 3); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName(), ThymeleafAutoConfiguration.class.getName()); }
@Test public void classExclusionsAreApplied() { configureExclusions(new String[] { FreeMarkerAutoConfiguration.class.getName() }, new String[0], new String[0]); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports.length, is(equalTo(getAutoConfigurationClassNames().size() - 1))); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(), contains(FreeMarkerAutoConfiguration.class.getName())); }
@Test public void propertyExclusionsAreApplied() { configureExclusions(new String[0], new String[0], new String[] { FreeMarkerAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports.length, is(equalTo(getAutoConfigurationClassNames().size() - 1))); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(), contains(FreeMarkerAutoConfiguration.class.getName())); }
@Test public void severalPropertyExclusionsAreApplied() { configureExclusions(new String[0], new String[0], new String[] { FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports.length, is(equalTo(getAutoConfigurationClassNames().size() - 2))); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(), containsInAnyOrder(FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName())); }
@Test public void combinedExclusionsAreApplied() { configureExclusions(new String[] { VelocityAutoConfiguration.class.getName() }, new String[] { FreeMarkerAutoConfiguration.class.getName() }, new String[] { ThymeleafAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports.length, is(equalTo(getAutoConfigurationClassNames().size() - 3))); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(), containsInAnyOrder(FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName(), ThymeleafAutoConfiguration.class.getName())); }
@Test public void importsAreSelected() { String[] value = new String[] { FreeMarkerAutoConfiguration.class.getName() }; configureValue(value); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports, equalTo(value)); }
@Test public void freemarkerAutoConfigurationWasImported() { assertThat(this.applicationContext) .has(importedAutoConfiguration(FreeMarkerAutoConfiguration.class)); }
@Test public void propertyExclusionsAreNotApplied() { configureValue(new String[] { FreeMarkerAutoConfiguration.class.getName() }); this.importSelector.selectImports(this.annotationMetadata); verifyZeroInteractions(this.environment); }