1 19 import java.io.*; 20 import book.*; 21 22 import org.netbeans.modules.schema2beans.*; 23 24 25 public class TestValid extends BaseTest 26 { 27 public static void main(String [] argv) { 28 BaseTest o = new TestValid(); 29 if (argv.length > 0) 30 o.setDocumentDir(argv[0]); 31 try { 32 o.run(); 33 } catch (Exception e) { 34 e.printStackTrace(); 35 System.exit(1); 36 } 37 System.exit(0); 38 } 39 40 public void run() 41 throws Exception 42 { 43 readDocument(); 44 45 Book book = Book.createGraph(this.doc); 47 48 out("Current XML document:"); 49 book.write(System.out); 50 51 out("Should add paperback after chapter:"); 52 book.setPaperback(true); 53 book.write(System.out); 54 55 out("Should add summary after paperback:"); 56 book.setSummary("Summary of the book"); 57 book.write(System.out); 58 59 out("Should add chapter before paperback"); 60 Chapter c = new Chapter(); 61 c.setTitle("title1"); 62 book.addChapter(c); 63 c = new Chapter(); 64 c.setTitle("title2"); 65 book.addChapter(c); 66 c = new Chapter(); 67 c.setTitle("title3"); 68 book.addChapter(c); 69 c = new Chapter(); 70 c.setTitle("title4"); 71 book.addChapter(c); 72 c = new Chapter(); 73 c.setTitle("title5"); 74 book.addChapter(c); 75 76 Chapter[] c2 = book.getChapter(); 78 c = c2[2]; 79 c2[2] = c2[0]; 80 c2[0] = c; 81 c = c2[3]; 82 c2[3] = c2[1]; 83 c2[1] = c; 84 book.setChapter(c2); 85 86 out(book); 87 88 out("Should add title as the first property of book:"); 89 book.setTitle("Title of the book"); 90 out(book); 91 92 out("Should add price as the last property of book:"); 93 book.setPrice("19.99"); 94 out(book); 95 96 out("Should add isbn before the price:"); 97 book.setIsbn("120394857"); 98 out(book); 99 100 out("Should add ending at the end of the chapter:"); 101 c = book.getChapter(0); 102 c.setEnding("And this is how this chapter ends."); 103 out(book); 104 105 out("Should add conclusion before the ending"); 106 c.setConclusion("And this concludes this chapter."); 107 out(book); 108 109 out("Should add Note with year before copyright"); 110 Note n = new Note(); 111 n.setYear("2000"); 112 n.setCopyright("1997"); 113 book.setNote(n); 114 out(book); 115 116 out("Should set Note with date before copyright"); 117 n = new Note(); 118 n.setDate("2001"); 119 n.setCopyright("1996"); 120 book.setNote(n); 121 out(book); 122 } 123 } 124 125 | Popular Tags |