menu = builder.endMenu();
final Map buffers = new HashMap();
MenuModelVisitor setupMapVisitor = new AbstractMenuModelHandler() {
// javadoc inherited
protected boolean handle(MenuItem item) {
buffers.put(item, locator.getMenuBuffer(item));
return false;
}
// javadoc inherited
protected boolean handle(MenuItemGroup group) {
buffers.put(group, locator.getMenuBuffer(group));
return true;
}
// javadoc inherited
protected boolean handle(Menu menu) {
buffers.put(menu, locator.getMenuBuffer(menu));
return true;
}
};
setupMapVisitor.visit(menu);
MenuModelVisitor checkVisitor = new AbstractMenuModelHandler() {
// javadoc inherited
protected boolean handle(MenuItem item) {
assertSame("item's buffer not as",
buffers.get(item),
locator.getMenuBuffer(item));
return true;
}
// javadoc inherited
protected boolean handle(MenuItemGroup group) {
assertSame("group's buffer not as",
buffers.get(group),
locator.getMenuBuffer(group));
return true;
}
// javadoc inherited
protected boolean handle(Menu menu) {
assertSame("menu's buffer not as",
buffers.get(menu),
locator.getMenuBuffer(menu));
return false;
}
};
checkVisitor.visit(menu);
assertSame("menu and first child should share same buffer",
buffers.get(menu),
buffers.get(menu.get(0)));