1 58 package org.apache.ecs.vxml; 59 60 65 public class TestBed1 66 { 67 68 public void HelloWorldTest() 69 { 70 System.out.println("\nHelloWorld.vxml"); 71 72 VXMLDocument doc = new VXMLDocument(); 73 Vxml vxml = new Vxml("1.0"); 74 Form form = new Form(); 75 Block block = new Block(); 76 block.addElement("Hello World!"); 77 form.addElement(block); 78 vxml.addElement(form); 79 doc.addElement(vxml); 80 81 System.out.println(doc.toString()); 82 } 83 84 public void DrinkTest() 85 { 86 System.out.println("\nDrink.vxml"); 87 88 VXMLDocument doc = new VXMLDocument(); 89 Vxml vxml = new Vxml("1.0"); 90 Form form = new Form(); 91 Field field = new Field("drink"); 92 Prompt prompt = new Prompt(); 93 prompt.addElement("Would you like coffee, tea, milk, or nothing?"); 94 Grammar grammar = new Grammar("drink.gram", "application/x-jsgf"); 95 Block block = new Block(); 96 block.addElement(new Submit("http://www.drink.example/drink2.asp")); 97 field.addElement(prompt); 98 field.addElement(grammar); 99 form.addElement(field); 100 form.addElement(block); 101 vxml.addElement(form); 102 103 doc.addElement(vxml); 104 105 System.out.println(doc.toString()); 106 107 } 108 109 public void MetaTest() 110 { 111 System.out.println("\nMeta.vxml"); 112 113 VXMLDocument doc = new VXMLDocument(); 114 Vxml vxml = new Vxml("1.0"); 115 vxml.addElement(new Meta().setAuthor("John Doe")); 116 vxml.addElement(new Meta().setMaintainer("hello-support@hi.example")); 117 vxml.addElement(new Var("hi", "'Hello World!'")); 118 Form form = new Form(); 119 Block block = new Block(); 120 block.addElement(new Value("hi")); 121 block.addElement(new Goto("#say_goodbye")); 122 form.addElement(block); 123 vxml.addElement(form); 124 Form form2 = new Form("say_goodbye"); 125 Block block2 = new Block(); 126 block2.addElement("Goodbye!"); 127 form2.addElement(block2); 128 vxml.addElement(form2); 129 130 doc.addElement(vxml); 131 132 System.out.println(doc.toString()); 133 } 134 135 public void LinkTest() 136 { 137 System.out.println("\nLink.vxml"); 138 139 VXMLDocument doc = new VXMLDocument(); 140 Vxml vxml = new Vxml("1.0"); 141 Var var = new Var("bye", "'Ciao'"); 142 Link link = new Link(); 143 link.setNext("operator_xfer.vxml"); 144 Grammar grammar = new Grammar(); 145 grammar.addElement(" operator "); 146 link.addElement(grammar); 147 vxml.addElement(var); 148 vxml.addElement(link); 149 150 doc.addElement(vxml); 151 152 System.out.println(doc.toString()); 153 } 154 155 public void ExitTest() 156 { 157 System.out.println("\nExit.vxml"); 158 159 VXMLDocument doc = new VXMLDocument(); 160 Vxml vxml = new Vxml("1.0"); 161 Form form = new Form("say_goodbye"); 162 Field field = new Field("answer", "boolean"); 163 Prompt prompt = new Prompt(); 164 prompt.addElement("Shall we say "); 165 prompt.addElement(new Value("application.bye")); 166 Filled filled = new Filled(); 167 If iftag = new If("answer"); 168 iftag.addElement(new Exit()); 169 filled.addElement(iftag); 170 filled.addElement(new Clear("answer")); 171 172 field.addElement(prompt); 173 field.addElement(filled); 174 form.addElement(field); 175 vxml.addElement(form); 176 177 doc.addElement(vxml); 178 179 System.out.println(doc.toString()); 180 } 181 182 public void FilledTest() 183 { 184 System.out.println("\nFilled.vxml"); 185 186 VXMLDocument doc = new VXMLDocument(); 187 Vxml vxml = new Vxml("1.0"); 188 Form form = new Form("billing_adjustment"); 189 Var var1 = new Var("account_number"); 190 Var var2 = new Var("home_phone"); 191 Subdialog sub = new Subdialog(); 192 sub.setName("accountinfo"); 193 sub.setSrc("acct_info.vxml#basic"); 194 Filled filled = new Filled(); 195 filled.addElement (new Assign("account_number", "accountinfo.acctnum")); 196 filled.addElement (new Assign("home_phone", "accountinfo.acctphone")); 197 sub.addElement(filled); 198 Field field = new Field(); 199 field.setName("adjustment_amount"); 200 field.setType("currency"); 201 Prompt prompt = new Prompt(" What is the value of your account adjustment?"); 202 Filled filled2 = new Filled(); 203 filled2.addElement(new Submit("/cgi-bin/updateaccount")); 204 field.addElement(prompt); 205 field.addElement(filled2); 206 207 form.addElement(var1); 208 form.addElement(var2); 209 form.addElement(sub); 210 form.addElement(field); 211 vxml.addElement(form); 212 213 doc.addElement(vxml); 214 215 System.out.println(doc.toString()); 216 } 217 218 public void ReturnTest() 219 { 220 System.out.println("\nReturn.vxml"); 221 222 VXMLDocument doc = new VXMLDocument(); 223 Vxml vxml = new Vxml("1.0"); 224 Form form = new Form("basic"); 225 form.addElement( 226 new Field("acctnum", "digits").addElement( 227 new Prompt(" What is your account number?"))); 228 Field field = new Field("acctphone", "phone"); 229 field.addElement(new Prompt(" What is your home telephone number?")); 230 Filled filled = new Filled(); 231 filled.addElement(new Return("acctnum acctphone")); 232 field.addElement(filled); 233 form.addElement(field); 234 vxml.addElement(form); 235 236 doc.addElement(vxml); 237 238 System.out.println(doc.toString()); 239 } 240 241 public static void main(String [] args) 242 { 243 TestBed1 tb = new TestBed1(); 244 245 tb.HelloWorldTest(); 246 tb.DrinkTest(); 247 tb.MetaTest(); 248 tb.LinkTest(); 249 tb.ExitTest(); 250 tb.FilledTest(); 251 tb.ReturnTest(); 252 } 253 } 254 | Popular Tags |