1 58 package org.apache.ecs.vxml; 59 60 65 public class TestBed3 66 { 67 68 public void EmptyElements() 69 { 70 System.out.println("\nEmptyElements.vxml"); 71 72 VXMLDocument doc = new VXMLDocument(); 73 Vxml vxml = new Vxml("1.0"); 74 75 vxml.addElement(new Block()); 76 vxml.addElement(new Reprompt()); 77 vxml.addElement(new Disconnect()); 78 79 doc.addElement(vxml); 80 81 System.out.println(doc.toString()); 82 } 83 84 public void MiscElements() 85 { 86 System.out.println("\nMiscElements.vxml"); 87 88 VXMLDocument doc = new VXMLDocument(); 89 Vxml vxml = new Vxml("1.0"); 90 91 Initial init = new Initial("bypass_init"); 92 init.addElement(new Audio("hello.wav")); 93 init.addElement(new Break("medium")); 94 vxml.addElement(init); 95 96 Dtmf dtmf = new Dtmf("application/x-jsgf"); 97 dtmf.addElement("1 {van} | 2 {choc} | 3 {straw}"); 98 vxml.addElement(dtmf); 99 vxml.addElement(new Div("sentence")); 100 vxml.addElement(new Emp("Hello!")); 101 vxml.addElement(new Sayas("currency", "$123.50")); 102 vxml.addElement(new Noinput("I didn't hear anything, please try again")); 103 vxml.addElement(new Nomatch("Nothing matched, try again.", "1")); 104 vxml.addElement(new Error ("An Error has occurred")); 105 vxml.addElement(new Throw("nomatch")); 106 org.apache.ecs.vxml.Object obj = new org.apache.ecs.vxml.Object(); 107 obj.setName("debit"); 108 obj.setClassid("method://credit_card/gather_and_debit"); 109 obj.setData("http://www.recordings.example/prompts/credit/jesse.jar"); 110 obj.addElement (new Param("amount", "document.amt")); 111 obj.addElement (new Param("vendor", "vendor_num")); 112 vxml.addElement(obj); 113 114 115 doc.addElement(vxml); 116 System.out.println(doc.toString()); 117 } 118 119 public void IfTest() 120 { 121 System.out.println("\nIfTest.vxml"); 122 123 VXMLDocument doc = new VXMLDocument(); 124 Vxml vxml = new Vxml("1.0"); 125 126 If iftag = new If("city == 'LA'"); 127 iftag.addElement(new Assign("city", "Los Angeles")); 128 iftag.addElement(new Elseif("city == 'Philly'")); 129 iftag.addElement(new Assign("city", "Philadelphia")); 130 iftag.addElement(new Else()); 131 iftag.addElement(new Assign("city", "Unknown")); 132 vxml.addElement(iftag); 133 134 doc.addElement(vxml); 135 136 System.out.println(doc.toString()); 137 } 138 139 public void ScriptTest() 140 { 141 System.out.println("\nScript.vxml"); 142 143 VXMLDocument doc = new VXMLDocument(); 144 Vxml vxml = new Vxml("1.0"); 145 146 Script script = new Script(); 147 script.addElement("<![CDATA[\n" + 148 "function factorial(n) { return (n <= 1)? 1 : n * factorial(n-1); }" + 149 "]]>"); 150 151 vxml.addElement(script); 152 doc.addElement(vxml); 153 154 doc.output(System.out); 155 } 156 157 158 public static void main(String [] args) 159 { 160 TestBed3 tb = new TestBed3(); 161 162 tb.EmptyElements(); 163 tb.MiscElements(); 164 tb.IfTest(); 165 tb.ScriptTest(); 166 } 167 } 168 | Popular Tags |