Search in sources :

Example 21 with ContextCustomizer

use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.

the class PropertyMappingContextCustomizerFactoryTests method getContextCustomizerWhenHasAttributeMappingShouldReturnCustomizer.

@Test
public void getContextCustomizerWhenHasAttributeMappingShouldReturnCustomizer() {
    ContextCustomizer customizer = this.factory.createContextCustomizer(AttributeMapping.class, null);
    assertThat(customizer).isNotNull();
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) Test(org.junit.Test)

Example 22 with ContextCustomizer

use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.

the class PropertyMappingContextCustomizerFactoryTests method propertyMappingShouldNotBeUsedWithComponent.

@Test
public void propertyMappingShouldNotBeUsedWithComponent() throws Exception {
    ContextCustomizer customizer = this.factory.createContextCustomizer(AttributeMapping.class, null);
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(ConfigMapping.class);
    customizer.customizeContext(context, null);
    this.thrown.expect(BeanCreationException.class);
    this.thrown.expectMessage("The @PropertyMapping annotation " + "@PropertyMappingContextCustomizerFactoryTests.TypeMappingAnnotation " + "cannot be used in combination with the @Component annotation @Configuration");
    context.refresh();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ContextCustomizer(org.springframework.test.context.ContextCustomizer) Test(org.junit.Test)

Example 23 with ContextCustomizer

use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.

the class ImportsContextCustomizerFactoryTests method getContextCustomizerWhenHasMetaImportAnnotationShouldReturnCustomizer.

@Test
public void getContextCustomizerWhenHasMetaImportAnnotationShouldReturnCustomizer() {
    ContextCustomizer customizer = this.factory.createContextCustomizer(TestWithMetaImport.class, null);
    assertThat(customizer).isNotNull();
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) Test(org.junit.Test)

Example 24 with ContextCustomizer

use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.

the class MockitoContextCustomizerFactoryTests method getContextCustomizerWithAnnotationReturnsCustomizer.

@Test
public void getContextCustomizerWithAnnotationReturnsCustomizer() throws Exception {
    ContextCustomizer customizer = this.factory.createContextCustomizer(WithMockBeanAnnotation.class, null);
    assertThat(customizer).isNotNull();
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) Test(org.junit.Test)

Example 25 with ContextCustomizer

use of org.springframework.test.context.ContextCustomizer in project spring-boot by spring-projects.

the class ImportsContextCustomizerFactoryTests method getContextCustomizerWhenHasNoImportAnnotationShouldReturnNull.

@Test
public void getContextCustomizerWhenHasNoImportAnnotationShouldReturnNull() {
    ContextCustomizer customizer = this.factory.createContextCustomizer(TestWithNoImport.class, null);
    assertThat(customizer).isNull();
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) Test(org.junit.Test)

Aggregations

ContextCustomizer (org.springframework.test.context.ContextCustomizer)25 Test (org.junit.Test)22 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 ArrayList (java.util.ArrayList)2 MergedContextConfiguration (org.springframework.test.context.MergedContextConfiguration)2 LinkedHashSet (java.util.LinkedHashSet)1 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)1 TypeExcludeFilter (org.springframework.boot.context.TypeExcludeFilter)1 ServletContextApplicationContextInitializer (org.springframework.boot.web.servlet.support.ServletContextApplicationContextInitializer)1 ApplicationContextInitializer (org.springframework.context.ApplicationContextInitializer)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)1 MetadataReader (org.springframework.core.type.classreading.MetadataReader)1 MetadataReaderFactory (org.springframework.core.type.classreading.MetadataReaderFactory)1 SimpleMetadataReaderFactory (org.springframework.core.type.classreading.SimpleMetadataReaderFactory)1 ContextConfigurationAttributes (org.springframework.test.context.ContextConfigurationAttributes)1 ContextCustomizerFactory (org.springframework.test.context.ContextCustomizerFactory)1 ContextLoader (org.springframework.test.context.ContextLoader)1 SmartContextLoader (org.springframework.test.context.SmartContextLoader)1