1 19 24 25 import java.io.*; 26 import java.util.*; 27 import org.w3c.dom.*; 28 29 import org.netbeans.modules.schema2beans.*; 30 import java.beans.*; 31 import book.*; 32 33 34 public class TestMdd extends BaseTest 35 { 36 public static void main(String [] argv) { 37 BaseTest o = new TestMdd(); 38 if (argv.length > 0) 39 o.setDocumentDir(argv[0]); 40 try { 41 o.run(); 42 } catch (Exception e) { 43 e.printStackTrace(); 44 System.exit(1); 45 } 46 System.exit(0); 47 } 48 49 public void run() 50 throws Exception 51 { 52 Book book; 53 54 this.readDocument(); 55 out("creating the bean graph"); 56 book = Book.createGraph(doc); 58 out("bean graph created"); 59 60 { 62 setTest("get non scalar wrapper object"); 63 Object obj = book.getDate(); 64 check(obj instanceof book.MyDate); 65 out(obj.toString()); 66 67 setTest("get float scalar value"); 68 float f = book.getPrice(); 69 float ref = (float)10.95; 70 float f2 = (float)9.99; 71 check(f == ref); 72 out("Setting new price to " + f2); 73 book.setPrice(f2); 74 f = book.getPrice(); 75 check(f == f2); 76 out("Price and date should match", book.dumpDomNode(2)); 77 } 78 79 { 81 setTest("get char scalar value"); 82 Index idx = book.getIndex(0); 83 char c = idx.getAlpha(); 84 check(c == 'a'); 85 idx.setAlpha('x'); 86 check(idx.getAlpha() == 'x'); 87 out("Alpha should be 'x'", idx.dumpDomNode(2)); 88 } 89 90 { 92 setTest("get int/int[] scalar values"); 93 Ref ref = book.getIndex(0).getRef(0); 94 int[] i = ref.getLine(); 95 check(i.length == 3); 96 check(ref.getPage() == 22); 97 check(i[0] == 12); 98 check(i[1] == 22); 99 check(i[2] == 32); 100 i[2] = 323; 101 ref.setLine(i); 102 check(ref.getPage() == 22); 103 check(ref.getLine(0) == 12); 104 check(ref.getLine(1) == 22); 105 check(ref.getLine(2) == 323); 106 out("Lines should be 12/22/323", ref.dumpDomNode(2)); 107 } 108 } 109 } 110 111 112 | Popular Tags |