* executed and attribute dependencies are calculated.
*/
public void testResolveAttributeDependencies() {
Map<String, Definition> defs = new HashMap<String, Definition>();
Definition def = new Definition();
def.setName("parent.def1");
def.setTemplate("/test1.jsp");
Attribute attr = new Attribute();
attr.setName("attr1");
attr.setValue("tiles.def2");
attr.setType("definition");
def.addAttribute(attr);
defs.put(def.getName(), def);
def = new Definition();
def.setName("parent.notype.def1");
def.setTemplate("/test1.jsp");
attr = new Attribute();
attr.setName("attr1");
attr.setValue("tiles.def2");
// Don't set the type
def.addAttribute(attr);
defs.put(def.getName(), def);
def = new Definition();
def.setName("tiles.def2");
defs.put(def.getName(), def);
Definitions definitions = new DefinitionsImpl();
try {
definitions.addDefinitions(defs);
definitions.addDefinitions(defs, Locale.ITALIAN);
} catch (NoSuchDefinitionException e) {
fail("Test failure: " + e);
}
Definition 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);
}