public class FilterBeanDefinitionParserTest extends TestCase {
public void testFilter() throws Exception {
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.setServletContext(new AttributeServletContext());
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(new ClassPathResource("org/impalaframework/web/spring/config/filterbeancontext.xml"));
context.refresh();
assertEquals("initValue", MyFilter2.getConfigParam());
Map<String, FilterFactoryBean> factoryBeans = context.getBeansOfType(FilterFactoryBean.class);
assertEquals(3, factoryBeans.size());
Map<String, Filter> s = context.getBeansOfType(Filter.class);
assertEquals(3, s.size());
Map<String, ? extends FilterFactoryBean> beans = context.getBeansOfType(InternalFrameworkIntegrationFilterFactoryBean.class);
assertEquals(1, beans.size());
InternalFrameworkIntegrationFilterFactoryBean firstValue = (InternalFrameworkIntegrationFilterFactoryBean) ObjectMapUtils.getFirstValue(beans);
assertEquals("delegator", firstValue.getFilterName());
beans = context.getBeansOfType(ExtendedFilterFactoryBean.class);
assertEquals(1, beans.size());
ExtendedFilterFactoryBean extendedFactoryBean = (ExtendedFilterFactoryBean) ObjectMapUtils.getFirstValue(beans);
assertEquals("extraValue", extendedFactoryBean.getExtraAttribute());