1 19 20 36 37 import java.io.*; 38 import java.util.*; 39 import org.w3c.dom.*; 40 41 import menus.*; 42 43 44 public class TestPositions extends BaseTest { 45 public static void main(String [] argv) { 46 TestPositions o = new TestPositions(); 47 if (argv.length > 0) 48 o.setDocumentDir(argv[0]); 49 try { 50 o.run(); 51 } catch (Exception e) { 52 e.printStackTrace(); 53 System.exit(1); 54 } 55 System.exit(0); 56 } 57 58 public void run() throws Exception { 59 Menus menus; 60 61 this.readDocument(); 62 63 out("creating the bean graph"); 64 menus = Menus.read(doc); 65 66 out("bean graph created"); 68 menus.write(out); 69 70 out("Check to make sure that elements with the same name get put into the right spot"); 71 Foo foo = menus.getFoo(); 72 check(foo.sizeName() == 2, "There are 2 names"); 73 check("name2".equals(foo.getName2()), "name2 is in the right spot"); 74 check("name3".equals(foo.getName3()), "name3 is in the right spot"); 75 76 out("Adding some colors to the menu."); 77 Menu menu = menus.getMenu(0); 78 menu.addMenuItem("red"); 79 menu.addMenuItem("magenta"); 80 menu.addMenuItem("blue"); 81 menu.addSeparator(new Separator()); 82 menu.addMenuItem("cyan"); 83 menu.addSeparator(new Separator()); 84 menu.addMenuItem("green"); 85 menus.write(out); 86 check(8 == menu.sizeMenuItem(), "sizeMenuItem="+menu.sizeMenuItem()); 87 out(menu.getMenuItem()); 88 89 out("Replacing menu items with many numbers"); 90 menu.setMenuItem(new String [] {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}); 91 menus.write(out); 92 93 out("Removing 7"); 94 menu.removeMenuItem("7"); 95 menus.write(out); 96 97 out("Replacing menu items with few letters"); 98 menu.setMenuItem(new String [] {"a", "b", "c"}); 99 menus.write(out); 100 } 101 } 102 | Popular Tags |