Source code: com/sonoma/test/chapterSectionTest.java
1 /*
2 * chapterSectionTest.java
3 *
4 * Created on April 28, 2002, 12:28 PM
5 */
6
7 package com.sonoma.test;
8 import com.sonoma.*;
9 import org.w3c.dom.Document;
10
11 /**
12 *
13 * @author Administrator
14 * @version
15 */
16 public class chapterSectionTest extends Object {
17
18 /** Creates new chapterSectionTest */
19 public chapterSectionTest() {
20 }
21 public boolean addChapter(Document doc){
22 try{
23 SiteMenu dbc = new SiteMenu();
24 dbc.addChapter(doc,"xml55555","Test Chapter","tc1");
25 return true;
26 }catch(Exception e){
27 e.printStackTrace();
28 return false;
29 }
30
31 }
32 public boolean updateChapter(Document doc){
33 try{
34 SiteMenu dbc = new SiteMenu();
35 //old id , new title, new id
36 dbc.updateChapter(doc,"tc1","ms","Test Chapter2");
37 return true;
38 }catch(Exception e){
39 e.printStackTrace();
40 return false;
41 }
42 }
43 public boolean moveChapter(Document doc){
44 try{
45 SiteMenu dbc = new SiteMenu();
46 //old id , new title, new id
47 dbc.moveChapter(doc,"java","xml");
48 return true;
49 }catch(Exception e){
50 e.printStackTrace();
51 return false;
52 }
53 }
54 public boolean removeChild(Document doc){
55 try{
56 SiteMenu dbc = new SiteMenu();
57 //old id , new title, new id
58 dbc.removeChapter(doc,"xml");
59 return true;
60 }catch(Exception e){
61 e.printStackTrace();
62 return false;
63 }
64 }
65 public boolean removeSect1(Document doc){
66 try{
67 SiteMenu dbc = new SiteMenu();
68 //old id , new title, new id
69 dbc.removeSect1(doc,"home","projects");
70 return true;
71 }catch(Exception e){
72 e.printStackTrace();
73 return false;
74 }
75 }
76 public boolean moveSect1(Document doc){
77 try{
78 SiteMenu dbc = new SiteMenu();
79 dbc.moveSect1(doc,"xsurvey","projects","sonoma","projects");
80 return true;
81 }catch(Exception e){
82 e.printStackTrace();
83 return false;
84 }
85 }
86 public boolean addSect1(Document doc){
87 try{
88 SiteMenu dbc = new SiteMenu();
89 dbc.addSect1(doc,"NewTests","ts2","xsurveyadsfadsf","tc1");
90 return true;
91 }catch(Exception e){
92 e.printStackTrace();
93 return false;
94 }
95 }
96 public boolean updateSection(Document doc)
97 {
98 try{
99 SiteMenu dbc = new SiteMenu();
100 dbc.updateSect1(doc,"asdf","123","mxlJava","ms");
101 return true;
102 }catch(Exception e){
103 e.printStackTrace();
104 return false;
105 }
106
107 }
108
109 public static void main(String[] args){
110 chapterSectionTest test = new chapterSectionTest();
111 com.sonoma.XMLUtility myX = new com.sonoma.XMLUtility();
112 org.w3c.dom.Document d;
113 System.out.println("test started");
114 //test update paragraph
115 d = myX.loadDoc("c:\\sonomatest.xml");
116 System.out.println("doc loaded");
117 //test.addChapter(d);
118 // test.updateChapter(d);
119 test.updateSection(d);
120 //test.removeChild(d);
121 //test.moveChapter(d);
122
123 // test.removeSect1(d);
124 // test.moveSect1(d);
125 // test.addSect1(d);
126 myX.saveDoc(d,"c:\\sonomatestOut.xml");
127 }
128 }