menu.add(item);
frame.getContentPane().add(menuBar);
frame.pack();
frame.show();
assertEquals(0, menuItemUI.getPath().length);
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(new MenuElement[] { menuBar, menu, menu.getPopupMenu(), item });
assertEquals(4, menuItemUI.getPath().length);
assertSame(menuBar, menuItemUI.getPath()[0]);
assertSame(menu, menuItemUI.getPath()[1]);
assertSame(menu.getPopupMenu(), menuItemUI.getPath()[2]);
assertSame(item, menuItemUI.getPath()[3]);
manager
.setSelectedPath(new MenuElement[] { menuBar, item2, menu2, menu.getPopupMenu() });
assertEquals(5, menuItemUI.getPath().length);
assertSame(menuBar, menuItemUI.getPath()[0]);
assertSame(item2, menuItemUI.getPath()[1]);
assertSame(menu2, menuItemUI.getPath()[2]);
assertSame(menu.getPopupMenu(), menuItemUI.getPath()[3]);
assertSame(item, menuItemUI.getPath()[4]);
manager.setSelectedPath(new MenuElement[] { menuBar });
assertEquals(1, menuItemUI.getPath().length);
assertSame(item, menuItemUI.getPath()[0]);
manager.clearSelectedPath();
assertEquals(0, menuItemUI.getPath().length);
frame.dispose();
}