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();
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class ImportsContextCustomizerFactoryTests method getContextCustomizerWhenHasImportAnnotationShouldReturnCustomizer.
@Test
public void getContextCustomizerWhenHasImportAnnotationShouldReturnCustomizer() {
ContextCustomizer customizer = this.factory.createContextCustomizer(TestWithImport.class, null);
assertThat(customizer).isNotNull();
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class ImportsContextCustomizerFactoryTests method contextCustomizerEqualsAndHashCode.
@Test
public void contextCustomizerEqualsAndHashCode() throws Exception {
ContextCustomizer customizer1 = this.factory.createContextCustomizer(TestWithImport.class, null);
ContextCustomizer customizer2 = this.factory.createContextCustomizer(TestWithImport.class, null);
ContextCustomizer customizer3 = this.factory.createContextCustomizer(TestWithImportAndMetaImport.class, null);
ContextCustomizer customizer4 = this.factory.createContextCustomizer(TestWithSameImportAndMetaImport.class, null);
assertThat(customizer1.hashCode()).isEqualTo(customizer1.hashCode());
assertThat(customizer1.hashCode()).isEqualTo(customizer2.hashCode());
assertThat(customizer1).isEqualTo(customizer1).isEqualTo(customizer2).isNotEqualTo(customizer3);
assertThat(customizer3).isEqualTo(customizer4);
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class MockitoContextCustomizerFactoryTests method getContextCustomizerUsesMocksAsCacheKey.
@Test
public void getContextCustomizerUsesMocksAsCacheKey() throws Exception {
ContextCustomizer customizer = this.factory.createContextCustomizer(WithMockBeanAnnotation.class, null);
assertThat(customizer).isNotNull();
ContextCustomizer same = this.factory.createContextCustomizer(WithSameMockBeanAnnotation.class, null);
assertThat(customizer).isNotNull();
ContextCustomizer different = this.factory.createContextCustomizer(WithDifferentMockBeanAnnotation.class, null);
assertThat(different).isNotNull();
assertThat(customizer.hashCode()).isEqualTo(same.hashCode());
assertThat(customizer.hashCode()).isNotEqualTo(different.hashCode());
assertThat(customizer).isEqualTo(customizer);
assertThat(customizer).isEqualTo(same);
assertThat(customizer).isNotEqualTo(different);
}
use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.
the class MockitoContextCustomizerFactoryTests method getContextCustomizerWithoutAnnotationReturnsCustomizer.
@Test
public void getContextCustomizerWithoutAnnotationReturnsCustomizer() throws Exception {
ContextCustomizer customizer = this.factory.createContextCustomizer(NoMockBeanAnnotation.class, null);
assertThat(customizer).isNotNull();
}
Aggregations