* executed and attribute dependencies are calculated.
*/
public void testResolveAttributeDependencies() {
Map defs = new HashMap();
ComponentDefinition def = new ComponentDefinition();
def.setName("parent.def1");
def.setTemplate("/test1.jsp");
ComponentAttribute attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("tiles.def2");
attr.setType("definition");
def.addAttribute(attr);
defs.put(def.getName(), def);
def = new ComponentDefinition();
def.setName("parent.notype.def1");
def.setTemplate("/test1.jsp");
attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("tiles.def2");
// Don't set the type
def.addAttribute(attr);
defs.put(def.getName(), def);
def = new ComponentDefinition();
def.setName("tiles.def2");
defs.put(def.getName(), def);
ComponentDefinitions definitions = new ComponentDefinitionsImpl();
try {
definitions.addDefinitions(defs);
definitions.addDefinitions(defs, Locale.ITALIAN);
} catch (NoSuchDefinitionException e) {
fail("Test failure: " + e);
}
ComponentDefinition newDef = definitions.getDefinition("parent.def1");
assertNotNull("Parent definition not found.", newDef);
Object newAttr = newDef.getAttribute("attr1");
assertNotNull("Dependent attribute not found.", newAttr);
newDef = definitions.getDefinition("parent.notype.def1");
assertNotNull("Parent definition not found.", newDef);
newAttr = newDef.getAttribute("attr1");
assertNotNull("Dependent attribute not found.", newAttr);
assertEquals("Incorrect dependent attribute name.", "tiles.def2",
newAttr);
// Part of the test for locale-specific definitions.
newDef = definitions.getDefinition("parent.def1", Locale.ITALIAN);
assertNotNull("Parent definition not found.", newDef);
newAttr = newDef.getAttribute("attr1");
assertNotNull("Dependent attribute not found.", newAttr);
newDef = definitions.getDefinition("parent.notype.def1",
Locale.ITALIAN);
assertNotNull("Parent definition not found.", newDef);
newAttr = newDef.getAttribute("attr1");
assertNotNull("Dependent attribute not found.", newAttr);
assertEquals("Incorrect dependent attribute name.", "tiles.def2",
newAttr);
}