01: package org.acegisecurity.config;
02:
03: import java.util.List;
04:
05: import junit.framework.TestCase;
06:
07: import org.acegisecurity.AccessDecisionManager;
08: import org.acegisecurity.vote.AuthenticatedVoter;
09: import org.springframework.beans.factory.config.BeanDefinition;
10: import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
11: import org.springframework.beans.factory.support.ManagedList;
12: import org.springframework.beans.factory.support.RootBeanDefinition;
13: import org.springframework.context.ApplicationContext;
14: import org.springframework.context.support.ClassPathXmlApplicationContext;
15:
16: public class AuthorizationManagerBeanDefinitionParserTests extends
17: TestCase {
18:
19: public void testParsingBeanDefinition() {
20: ApplicationContext context = new ClassPathXmlApplicationContext(
21: "org/acegisecurity/config/authorization-manager.xml");
22: ConfigurableListableBeanFactory bf = (ConfigurableListableBeanFactory) context
23: .getAutowireCapableBeanFactory();
24: String[] beanNames = bf
25: .getBeanNamesForType(AccessDecisionManager.class);
26: assertEquals(1, beanNames.length);
27: BeanDefinition def = (RootBeanDefinition) bf
28: .getBeanDefinition(beanNames[0]);
29: assertNotNull(def);
30: List decisionVoters = (ManagedList) def.getPropertyValues()
31: .getPropertyValue("decisionVoters").getValue();
32: assertEquals(2, decisionVoters.size());
33: assertEquals("org.acegisecurity.vote.RoleVoter",
34: ((BeanDefinition) decisionVoters.get(0))
35: .getBeanClassName());
36: assertEquals("org.acegisecurity.vote.AuthenticatedVoter",
37: ((BeanDefinition) decisionVoters.get(1))
38: .getBeanClassName());
39: }
40: }
|