1 58 package org.apache.ecs.vxml; 59 60 65 public class TestBed2 66 { 67 68 public void WeatherTest() 69 { 70 System.out.println("\nWeather.vxml"); 71 72 VXMLDocument doc = new VXMLDocument(); 73 Vxml vxml = new Vxml("1.0"); 74 Form form = new Form("weather_info"); 75 Block block = new Block(); 76 block.addElement("Welcome to the weather information service."); 77 Field field = new Field("city"); 78 Prompt prompt = new Prompt("What city?"); 79 Grammar grammar = new Grammar("city.gram","application/x-jsgf"); 80 Catch catchtag = new Catch("help"); 81 catchtag.addElement("Please speak the city for which you want the weather."); 82 field.addElement(prompt); 83 field.addElement(grammar); 84 field.addElement(catchtag); 85 86 form.addElement(block); 87 form.addElement(field); 88 form.addElement(new Block().addElement(new Submit("/servlet/weather", "city"))); 89 vxml.addElement(form); 90 91 doc.addElement(vxml); 92 93 System.out.println(doc.toString()); 94 } 95 96 public void CreditCard() 97 { 98 System.out.println("\nCreditCard.vxml"); 99 100 VXMLDocument doc = new VXMLDocument(); 101 Vxml vxml = new Vxml("1.0"); 102 Form form = new Form("get_card_info"); 103 Block block = new Block(); 104 block.addElement("We now need your credit card type, number, and expiration date."); 105 form.addElement(block); 106 107 Field field = new Field("card_type"); 108 Prompt prompt1 = new Prompt("What kind of credit card do you have?"); 109 Prompt prompt2 = new Prompt("Type of card?"); 110 prompt1.setBargein("false"); 111 prompt1.setCount("1"); 112 prompt2.setCount("2"); 113 114 Grammar grammar = new Grammar(); 115 grammar.addElement("visa {visa}"); 116 grammar.addElement("| master [card] {mastercard}"); 117 grammar.addElement("| amex {amex}"); 118 grammar.addElement("| american [express] {amex}"); 119 Help help = new Help("Please say Visa, Mastercard, or American Express."); 120 field.addElement(prompt1); 121 field.addElement(prompt2); 122 field.addElement(grammar); 123 field.addElement(help); 124 form.addElement(field); 125 126 127 vxml.addElement(form); 128 129 doc.addElement(vxml); 130 131 System.out.println(doc.toString()); 132 } 133 134 public void MenuTest() 135 { 136 System.out.println("\nMenuTest.vxml"); 137 138 VXMLDocument doc = new VXMLDocument(); 139 Vxml vxml = new Vxml("1.0"); 140 Menu menu1 = new Menu(); 141 Property prop = new Property(); 142 prop.setInputmodes("dtmf"); 143 menu1.addElement(prop); 144 Prompt prompt = new Prompt("For sports press 1, For weather press 2, For Stargazer astrophysics press 3."); 145 menu1.addElement(prompt); 146 menu1.addElement(new Choice("1","http://www.sports.example/vxml/start.vxml")); 147 menu1.addElement(new Choice("2","http://www.weather.example/intro.vxml")); 148 menu1.addElement(new Choice("3","http://www.stargazer.example/voice/astronews.vxml")); 149 vxml.addElement(menu1); 150 151 Menu menu2 = new Menu("true"); 152 menu2.addElement(prop); 153 menu2.addElement(prompt); 154 menu2.addElement(new Choice("http://www.sports.example/vxml/start.vxml")); 155 menu2.addElement(new Choice("http://www.weather.example/intro.vxml")); 156 menu2.addElement(new Choice("http://www.stargazer.example/voice/astronews.vxml")); 157 vxml.addElement(menu2); 158 159 Menu menu3 = new Menu("true"); 160 Prompt prompt2 = new Prompt("Welcome Home"); 161 Enumerate enum = new Enumerate(); 162 enum.addElement("For "); 163 enum.addElement(new Value("_prompt")); 164 enum.addElement(", press "); 165 enum.addElement(new Value("_dtmf")); 166 prompt2.addElement(enum); 167 menu3.addElement(prompt2); 168 Choice choice1 = new Choice("http://www.sports.example/vxml/start.vxml"); 169 Choice choice2 = new Choice("http://www.weather.example/intro.vxml"); 170 Choice choice3 = new Choice("http://www.stargazer.example/voice/astronews.vxml"); 171 choice1.addElement("sports"); 172 choice2.addElement("weather"); 173 choice3.addElement("Stargazer astrophysics news"); 174 menu3.addElement(choice1); 175 menu3.addElement(choice2); 176 menu3.addElement(choice3); 177 178 vxml.addElement(menu3); 179 180 System.out.println(vxml.toString()); 181 } 182 183 public void RepromptTest() 184 { 185 System.out.println("\nRepromptTest.vxml"); 186 187 VXMLDocument doc = new VXMLDocument(); 188 Vxml vxml = new Vxml("1.0"); 189 190 vxml.addElement(new Reprompt()); 191 192 doc.addElement(vxml); 193 194 System.out.println(doc.toString()); 195 } 196 197 198 public static void main(String[] args) 199 { 200 TestBed2 tb = new TestBed2(); 201 202 tb.WeatherTest(); 203 tb.CreditCard(); 204 tb.MenuTest(); 205 tb.RepromptTest(); 206 } 207 } 208 | Popular Tags |