InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("security/login-config2.xml");
InputStreamReader xmlReader = new InputStreamReader(is);
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
unmarshaller.mapFactoryToNamespace(uomf, "http://www.jboss.org/j2ee/schemas/XMLLoginModule");
PolicyConfig config = (PolicyConfig) unmarshaller.unmarshal(xmlReader, lcomf, null);
ApplicationPolicy aPolicy = (ApplicationPolicy)config.get("testXMLLoginModule");
AuthenticationInfo info = (AuthenticationInfo)aPolicy.getAuthenticationInfo();
assertTrue("test-xml-config != null", info != null);
AppConfigurationEntry[] entries = info.getAppConfigurationEntry();
assertTrue("entries.length == 1", entries.length == 1);
AppConfigurationEntry ace = entries[0];
assertTrue("org.jboss.security.auth.spi.XMLLoginModule",
ace.getLoginModuleName().equals("org.jboss.security.auth.spi.XMLLoginModule"));
Map options = ace.getOptions();
assertTrue("Options.size == 2", options.size() == 2);
String guest = (String) options.get("unauthenticatedIdentity");
assertTrue("guest", guest.equals("guest"));
Users users = (Users) options.get("userInfo");
Users.User user = users.getUser("jdukeman");
String name = user.getName();
assertTrue("name == jdukeman", name.equals("jdukeman"));
String passwrd = user.getPassword();
assertTrue("passwrd == anotherduke", passwrd.equals("anotherduke"));
String[] roleNames = user.getRoleNames();
//Take care of Map implementations on various platforms
assertTrue("roles in (Role2, Role3)",
roleNames[0].equals("Role2") && roleNames[1].equals("Role3") ||
roleNames[0].equals("Role3") && roleNames[1].equals("Role2"));
aPolicy = (ApplicationPolicy)config.get("testNoModuleOptions");
AuthenticationInfo testNoModuleOptions = (AuthenticationInfo)aPolicy.getAuthenticationInfo();
// AuthenticationInfo testNoModuleOptions = (AuthenticationInfo) config.get("testNoModuleOptions");
assertTrue("testNoModuleOptions != null", testNoModuleOptions != null);
AppConfigurationEntry[] testNoModuleOptionsEntries = testNoModuleOptions.getAppConfigurationEntry();
assertTrue("entries.length == 1", testNoModuleOptionsEntries.length == 1);
AppConfigurationEntry testNoModuleOptionsACE = testNoModuleOptionsEntries[0];