1 19 35 36 import java.io.*; 37 import java.util.*; 38 import org.w3c.dom.*; 39 40 import purchaseorder.*; 41 42 43 public class TestPurchaseOrder extends BaseTest { 44 public static void main(String [] argv) { 45 TestPurchaseOrder o = new TestPurchaseOrder(); 46 if (argv.length > 0) 47 o.setDocumentDir(argv[0]); 48 try { 49 o.run(); 50 } catch (Exception e) { 51 e.printStackTrace(); 52 System.exit(1); 53 } 54 System.exit(0); 55 } 56 57 public void run() throws Exception { 58 PurchaseOrder po; 59 60 this.readDocument(); 61 62 out("creating the bean graph"); 63 po = PurchaseOrder.read(doc); 64 65 out("bean graph created"); 67 po.write(out); 68 69 out("Adjusting shipTo"); 70 USAddress shipTo = new USAddress(); 71 po.setShipTo(shipTo); 72 shipTo.setCountry("B&B's are us"); 73 shipTo.setName("To you & me"); 74 po.write(out); 75 76 out("Adding a Daffodil"); 77 Items items = po.getItems(); 78 Item item = new Item(); 79 item.setProductName("Daffodil"); 80 item.setQuantity(3); 81 item.setUSPrice(new java.math.BigDecimal ("1.00")); 82 item.setComment("Yellow & Green"); 83 int position = items.addItem(item); 84 po.write(out); 85 86 check(items.getItem(position) == item, "addItem returned correct position"); 87 88 out("Removing that Daffodil"); 89 items.removeItem(item); 90 po.write(out); 91 92 Item[] itemsArray = items.getItem(); 93 97 check(items.sizeItem() == 2, "sizeItem should return 2"); 98 99 PurchaseOrder po2 = new PurchaseOrder(po); 100 check(po != po2, "po should not be po2"); 101 check(po.equals(po2), "po should equal po2"); 102 check(po2.equals(po), "po2 should equal po"); 103 107 108 po._setSchemaLocation("flurp"); 109 po.write(out); 110 } 111 } 112 | Popular Tags |