assertEquals("*", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getProfile());
assertEquals("links", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getSkin());
assertEquals("@", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getOptions());
// test page resident menu definitions
Page page = pageManager.getPage("/test001.psml");
assertNotNull(page);
menus = page.getMenuDefinitions();
assertNotNull(menus);
assertEquals(1, menus.size());
simpleMenu = (MenuDefinition)menus.get(0);
assertNotNull(simpleMenu);
assertEquals("simple", simpleMenu.getName());
assertNotNull(simpleMenu.getMenuElements());
assertEquals(2, simpleMenu.getMenuElements().size());
// test writing page menu definitions
page = pageManager.getPage(this.testPage002);
page.setMenuDefinitions(new ArrayList());
MenuDefinition newMenu = page.newMenuDefinition();
newMenu.setName("updated-menu");
newMenu.setSkin("tabs");
newMenu.setMenuElements(new ArrayList());
MenuSeparatorDefinition newSeparator = page.newMenuSeparatorDefinition();
newSeparator.setText("-- Updated Menu --");
newMenu.getMenuElements().add(newSeparator);
MenuOptionsDefinition newOptions0 = page.newMenuOptionsDefinition();
newOptions0.setOptions("/*.psml");
newOptions0.setRegexp(true);
newMenu.getMenuElements().add(newOptions0);
MenuOptionsDefinition newOptions1 = page.newMenuOptionsDefinition();
newOptions1.setOptions("/folder0");
newMenu.getMenuElements().add(newOptions1);
MenuDefinition newNestedMenu = page.newMenuDefinition();
newNestedMenu.setOptions("/*/");
newNestedMenu.setRegexp(true);
newMenu.getMenuElements().add(newNestedMenu);
MenuExcludeDefinition newExcludeMenu = page.newMenuExcludeDefinition();
newExcludeMenu.setName("exclude-menu");
newMenu.getMenuElements().add(newExcludeMenu);
MenuIncludeDefinition newIncludeMenu = page.newMenuIncludeDefinition();
newIncludeMenu.setName("include-menu");
newIncludeMenu.setNest(true);
newMenu.getMenuElements().add(newIncludeMenu);
page.getMenuDefinitions().add(newMenu);
try
{
pageManager.updatePage(page);
}
catch (Exception e)
{
String errmsg = "Exception in page update: " + e.toString();
e.printStackTrace();
System.err.println(errmsg);
assertNotNull(errmsg, null);
}
page = pageManager.getPage(this.testPage002);
assertNotNull(page.getMenuDefinitions());
assertEquals(1, page.getMenuDefinitions().size());
assertNotNull(((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements());
assertEquals(6,((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements().size());
assertTrue(((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements().get(0) instanceof MenuSeparatorDefinition);
assertTrue(((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements().get(1) instanceof MenuOptionsDefinition);
assertTrue(((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements().get(2) instanceof MenuOptionsDefinition);
assertTrue(((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements().get(3) instanceof MenuDefinition);
assertTrue(((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements().get(4) instanceof MenuExcludeDefinition);
assertTrue(((MenuDefinition)page.getMenuDefinitions().get(0)).getMenuElements().get(5) instanceof MenuIncludeDefinition);
// test writing folder menu definitions
folder = pageManager.getFolder(this.testFolder2);
folder.setMenuDefinitions(new ArrayList());
newMenu = folder.newMenuDefinition();