/**
*
* @throws Exception
*/
public void testPrincipalProviderConfig() throws Exception {
PrincipalProviderRegistry ppr = new ProviderRegistryImpl(null);
// standard config
Element xml = parseXML(new InputSource(new StringReader(PRINCIPAL_PROVIDER_CONFIG)), true);
LoginModuleConfig lmc = parser.parseSecurityConfig(xml).getLoginModuleConfig();
PrincipalProvider pp = ppr.registerProvider(lmc.getParameters());
assertEquals(pp, ppr.getProvider(pp.getClass().getName()));
assertEquals("org.apache.jackrabbit.core.security.principal.FallbackPrincipalProvider", pp.getClass().getName());
// config specifying an extra name
xml = parseXML(new InputSource(new StringReader(PRINCIPAL_PROVIDER_CONFIG1)), true);
lmc = parser.parseSecurityConfig(xml).getLoginModuleConfig();
pp = ppr.registerProvider(lmc.getParameters());
assertEquals(pp, ppr.getProvider("test"));
assertEquals("org.apache.jackrabbit.core.security.principal.FallbackPrincipalProvider", pp.getClass().getName());
// use alternative class config
xml = parseXML(new InputSource(new StringReader(PRINCIPAL_PROVIDER_CONFIG2)), true);
lmc = parser.parseSecurityConfig(xml).getLoginModuleConfig();
pp = ppr.registerProvider(lmc.getParameters());
assertEquals(pp, ppr.getProvider("test2"));
assertEquals("org.apache.jackrabbit.core.security.principal.FallbackPrincipalProvider", pp.getClass().getName());
// all 3 providers must be registered despite the fact the all configs
// specify the same provider class
assertEquals(3, ppr.getProviders().length);
}