01: /**
02: *
03: */package org.acegisecurity.config;
04:
05: import javax.servlet.Filter;
06:
07: import org.acegisecurity.context.HttpSessionContextIntegrationFilter;
08: import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
09: import org.springframework.beans.factory.support.RootBeanDefinition;
10: import org.springframework.context.ApplicationContext;
11: import org.springframework.context.support.ClassPathXmlApplicationContext;
12:
13: import junit.framework.TestCase;
14:
15: /**
16: * @author vpuri
17: *
18: */
19: public class HttpSessionContextIntegrationParserTest extends TestCase {
20:
21: public void testApplicationContext() {
22: ApplicationContext context = new ClassPathXmlApplicationContext(
23: "org/acegisecurity/config/session-context-integration-defaults.xml");
24: ConfigurableListableBeanFactory clbf = (ConfigurableListableBeanFactory) context
25: .getAutowireCapableBeanFactory();
26:
27: String[] names = clbf.getBeanNamesForType(Filter.class);
28: assertEquals(1, names.length);
29:
30: // check bean name
31: RootBeanDefinition definition = (RootBeanDefinition) clbf
32: .getBeanDefinition(names[0]);
33: assertEquals(HttpSessionContextIntegrationFilter.class,
34: definition.getBeanClass());
35:
36: // check properties
37: //get the bean
38: HttpSessionContextIntegrationFilter filter = (HttpSessionContextIntegrationFilter) context
39: .getBean("httpSessionContextIntegrationFilter");
40: assertFalse(filter.isAllowSessionCreation());
41: assertNotNull(definition.getPropertyValues().getPropertyValue(
42: "allowSessionCreation"));
43: assertFalse(filter.isForceEagerSessionCreation());
44: assertFalse(filter.isCloneFromHttpSession());
45: }
46:
47: }
|