Search in sources :

Example 6 with ScannedGenericBeanDefinition

use of org.springframework.context.annotation.ScannedGenericBeanDefinition in project spring-boot by spring-projects.

the class WebFilterHandlerTests method defaultFilterConfiguration.

@SuppressWarnings("unchecked")
@Test
public void defaultFilterConfiguration() throws IOException {
    ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(new SimpleMetadataReaderFactory().getMetadataReader(DefaultConfigurationFilter.class.getName()));
    this.handler.handle(scanned, this.registry);
    BeanDefinition filterRegistrationBean = this.registry.getBeanDefinition(DefaultConfigurationFilter.class.getName());
    MutablePropertyValues propertyValues = filterRegistrationBean.getPropertyValues();
    assertThat(propertyValues.get("asyncSupported")).isEqualTo(false);
    assertThat((EnumSet<DispatcherType>) propertyValues.get("dispatcherTypes")).containsExactly(DispatcherType.REQUEST);
    assertThat(((Map<String, String>) propertyValues.get("initParameters"))).isEmpty();
    assertThat((String[]) propertyValues.get("servletNames")).isEmpty();
    assertThat((String[]) propertyValues.get("urlPatterns")).isEmpty();
    assertThat(propertyValues.get("name")).isEqualTo(DefaultConfigurationFilter.class.getName());
    assertThat(propertyValues.get("filter")).isEqualTo(scanned);
}
Also used : SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) EnumSet(java.util.EnumSet) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 7 with ScannedGenericBeanDefinition

use of org.springframework.context.annotation.ScannedGenericBeanDefinition in project spring-boot by spring-projects.

the class WebFilterHandlerTests method getBeanDefinition.

BeanDefinition getBeanDefinition(Class<?> filterClass) throws IOException {
    ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(new SimpleMetadataReaderFactory().getMetadataReader(filterClass.getName()));
    this.handler.handle(scanned, this.registry);
    return this.registry.getBeanDefinition(filterClass.getName());
}
Also used : SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition)

Aggregations

ScannedGenericBeanDefinition (org.springframework.context.annotation.ScannedGenericBeanDefinition)7 SimpleMetadataReaderFactory (org.springframework.core.type.classreading.SimpleMetadataReaderFactory)7 Test (org.junit.Test)5 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)4 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)4 EnumSet (java.util.EnumSet)1