Search in sources :

Example 1 with ScannedGenericBeanDefinition

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

the class WebFilterHandlerTests method filterWithCustomName.

@Test
public void filterWithCustomName() throws IOException {
    ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(new SimpleMetadataReaderFactory().getMetadataReader(CustomNameFilter.class.getName()));
    this.handler.handle(scanned, this.registry);
    BeanDefinition filterRegistrationBean = this.registry.getBeanDefinition("custom");
    MutablePropertyValues propertyValues = filterRegistrationBean.getPropertyValues();
    assertThat(propertyValues.get("name")).isEqualTo("custom");
}
Also used : SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 2 with ScannedGenericBeanDefinition

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

the class WebListenerHandlerTests method listener.

@Test
public void listener() throws IOException {
    ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(new SimpleMetadataReaderFactory().getMetadataReader(TestListener.class.getName()));
    this.handler.handle(scanned, this.registry);
    this.registry.getBeanDefinition(TestListener.class.getName());
}
Also used : SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) Test(org.junit.Test)

Example 3 with ScannedGenericBeanDefinition

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

the class WebServletHandlerTests method defaultServletConfiguration.

@SuppressWarnings("unchecked")
@Test
public void defaultServletConfiguration() throws IOException {
    ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(new SimpleMetadataReaderFactory().getMetadataReader(DefaultConfigurationServlet.class.getName()));
    this.handler.handle(scanned, this.registry);
    BeanDefinition servletRegistrationBean = this.registry.getBeanDefinition(DefaultConfigurationServlet.class.getName());
    MutablePropertyValues propertyValues = servletRegistrationBean.getPropertyValues();
    assertThat(propertyValues.get("asyncSupported")).isEqualTo(false);
    assertThat(((Map<String, String>) propertyValues.get("initParameters"))).isEmpty();
    assertThat((Integer) propertyValues.get("loadOnStartup")).isEqualTo(-1);
    assertThat(propertyValues.get("name")).isEqualTo(DefaultConfigurationServlet.class.getName());
    assertThat((String[]) propertyValues.get("urlMappings")).isEmpty();
    assertThat(propertyValues.get("servlet")).isEqualTo(scanned);
}
Also used : SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 4 with ScannedGenericBeanDefinition

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

the class WebServletHandlerTests method servletWithCustomName.

@Test
public void servletWithCustomName() throws IOException {
    ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(new SimpleMetadataReaderFactory().getMetadataReader(CustomNameServlet.class.getName()));
    this.handler.handle(scanned, this.registry);
    BeanDefinition servletRegistrationBean = this.registry.getBeanDefinition("custom");
    MutablePropertyValues propertyValues = servletRegistrationBean.getPropertyValues();
    assertThat(propertyValues.get("name")).isEqualTo("custom");
}
Also used : SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) ScannedGenericBeanDefinition(org.springframework.context.annotation.ScannedGenericBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 5 with ScannedGenericBeanDefinition

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

the class WebServletHandlerTests 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