use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class TypeExcludeFiltersContextCustomizerFactoryTests method hashCodeAndEquals.
@Test
public void hashCodeAndEquals() throws Exception {
ContextCustomizer customizer1 = this.factory.createContextCustomizer(WithExcludeFilters.class, null);
ContextCustomizer customizer2 = this.factory.createContextCustomizer(WithSameExcludeFilters.class, null);
ContextCustomizer customizer3 = this.factory.createContextCustomizer(WithDifferentExcludeFilters.class, null);
assertThat(customizer1.hashCode()).isEqualTo(customizer2.hashCode());
assertThat(customizer1).isEqualTo(customizer1).isEqualTo(customizer2).isNotEqualTo(customizer3);
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class TypeExcludeFiltersContextCustomizerFactoryTests method getContextCustomizerShouldAddExcludeFilters.
@Test
public void getContextCustomizerShouldAddExcludeFilters() throws Exception {
ContextCustomizer customizer = this.factory.createContextCustomizer(WithExcludeFilters.class, null);
customizer.customizeContext(this.context, this.mergedContextConfiguration);
this.context.refresh();
TypeExcludeFilter filter = this.context.getBean(TypeExcludeFilter.class);
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NoAnnotation.class.getName());
assertThat(filter.match(metadataReader, metadataReaderFactory)).isFalse();
metadataReader = metadataReaderFactory.getMetadataReader(SimpleExclude.class.getName());
assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue();
metadataReader = metadataReaderFactory.getMetadataReader(TestClassAwareExclude.class.getName());
assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue();
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class TypeExcludeFiltersContextCustomizerFactoryTests method getContextCustomizerWhenHasNoAnnotationShouldReturnNull.
@Test
public void getContextCustomizerWhenHasNoAnnotationShouldReturnNull() throws Exception {
ContextCustomizer customizer = this.factory.createContextCustomizer(NoAnnotation.class, null);
assertThat(customizer).isNull();
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class TypeExcludeFiltersContextCustomizerFactoryTests method getContextCustomizerWhenHasAnnotationShouldReturnCustomizer.
@Test
public void getContextCustomizerWhenHasAnnotationShouldReturnCustomizer() throws Exception {
ContextCustomizer customizer = this.factory.createContextCustomizer(WithExcludeFilters.class, null);
assertThat(customizer).isNotNull();
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class ImportsContextCustomizerFactoryTests method contextCustomizerImportsBeans.
@Test
public void contextCustomizerImportsBeans() throws Exception {
ContextCustomizer customizer = this.factory.createContextCustomizer(TestWithImport.class, null);
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
customizer.customizeContext(context, mock(MergedContextConfiguration.class));
context.refresh();
assertThat(context.getBean(ImportedBean.class)).isNotNull();
}
Aggregations