// Test parsing configuration resource that has maps in it
public void testMap() throws Exception {
ManagedBeanConfig mb = null;
ManagedPropertyConfig mp = null;
MapEntriesConfig entries = null;
MapEntryConfig entry = null;
// Wire up our FacesConfigConfig instance
parser.setFacesConfig(facesConfig);
assertTrue(facesConfig == parser.getFacesConfig());
// Make sure we do validating parses
parser.setValidating(true);
assertTrue(parser.isValidating());
// Parse resource 5
parser.setResource(this.getClass().getResource
("/org/apache/shale/tiger/config/test-config-5.xml"));
assertNotNull(parser.getResource());
parser.parse();
assertEquals(2, facesConfig.getManagedBeans().size());
// Validate bean "stringDateMap"
mb = facesConfig.getManagedBean("stringIntegerMap");
assertNotNull(mb);
assertEquals("stringIntegerMap", mb.getName());
assertEquals("none", mb.getScope());
assertEquals("java.util.TreeMap", mb.getType());
assertNull(mb.getListEntries());
assertNotNull(mb.getMapEntries());
assertEquals(0, mb.getProperties().size());
entries = mb.getMapEntries();
assertEquals("java.lang.String", entries.getKeyType());
assertEquals("java.lang.Integer", entries.getValueType());
assertEquals(4, entries.getEntries().size());
entry = entries.getEntries().get(0);
assertEquals("First", entry.getKey());
assertEquals("123", entry.getValue());
assertTrue(!entry.isExpression());
assertTrue(!entry.isNullValue());
entry = entries.getEntries().get(1);
assertEquals("Second", entry.getKey());
assertEquals("234", entry.getValue());
assertTrue(!entry.isExpression());
assertTrue(!entry.isNullValue());
entry = entries.getEntries().get(2);
assertEquals("Third", entry.getKey());
assertNull(entry.getValue());
assertTrue(!entry.isExpression());
assertTrue(entry.isNullValue());
entry = entries.getEntries().get(3);
assertEquals("Fourth", entry.getKey());
assertEquals("345", entry.getValue());
assertTrue(!entry.isExpression());
assertTrue(!entry.isNullValue());
// Validate bean "mapPropertiesBean"
mb = facesConfig.getManagedBean("mapPropertiesBean");
assertNotNull(mb);
assertEquals("mapPropertiesBean", mb.getName());
assertEquals("application", mb.getScope());
assertEquals("org.apache.shale.tiger.config.TestBean5", mb.getType());
assertNull(mb.getListEntries());
assertNull(mb.getMapEntries());
assertEquals(2, mb.getProperties().size());
mp = mb.getProperty("emptyMap");
assertNotNull(mp);
assertEquals("emptyMap", mp.getName());
assertNull(mp.getValue());
assertTrue(!mp.isExpression());
assertTrue(!mp.isNullValue());
assertNull(mp.getListEntries());
assertNotNull(mp.getMapEntries());
entries = mp.getMapEntries();
assertNull(entries.getKeyType());
assertNull(entries.getValueType());
assertEquals(3, entries.getEntries().size());
entry = entries.getEntries().get(0);
assertTrue(!entry.isExpression());
assertEquals("First Key", entry.getKey());
assertEquals("First Value", entry.getValue());
entry = entries.getEntries().get(1);
assertTrue(!entry.isExpression());
assertEquals("Second Key", entry.getKey());
assertEquals("Second Value", entry.getValue());
entry = entries.getEntries().get(2);
assertTrue(!entry.isExpression());
assertEquals("Third Key", entry.getKey());
assertEquals("Third Value", entry.getValue());
mp = mb.getProperty("fullMap");
assertNotNull(mp);
assertEquals("fullMap", mp.getName());
assertNull(mp.getValue());
assertTrue(!mp.isExpression());
assertTrue(!mp.isNullValue());
assertNull(mp.getListEntries());
assertNotNull(mp.getMapEntries());
entries = mp.getMapEntries();
assertNull(entries.getKeyType());
assertNull(entries.getValueType());
assertEquals(3, entries.getEntries().size());
entry = entries.getEntries().get(0);
assertTrue(!entry.isExpression());
assertEquals("First Key", entry.getKey());
assertEquals("First Value", entry.getValue());
entry = entries.getEntries().get(1);
assertTrue(!entry.isExpression());
assertEquals("Second Key", entry.getKey());
assertEquals("Second Value", entry.getValue());
entry = entries.getEntries().get(2);
assertTrue(!entry.isExpression());
assertEquals("Third Key", entry.getKey());
assertEquals("Third Value", entry.getValue());
}