scenario2.xml

Upload: rakaangga

Post on 30-May-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Scenario2.XML

    1/5

    /home/raka/NetBeansProjects/bastard-demo/scenarios/scenario2.xml

    1 2 3 4 eq(mediator("isStarted()"), true)5 6 7 8

    9 10 Description of step 111 12 list("test alice->bob", "test carl->dave")13 mediator("getConvergedTestInstance(#ctInstanceID)") 14 ref(ctInstanceID)15 "192.168.1.102"16 2506017 "callback.com"18 "192.168.1.102:15060"19 "192.168.1.102:8080"20 list("alice", "carl")21 list("bob", "dave")22 23 24 25 Initialize the ctInstance

    26 34 35 36 Go to the landing page, QUERY partyB's status, and verify it's currently UNKNOWN37

    43 ConvergedTestInstance ctInstance = action.getArgument("ctInstance");44 System.out.println("BEGIN X: " + ctInstance);4546 WebClient webClient = new WebClient();4748 //go to the landing page49 HtmlPage presenceStatusPage = webClient.getPage("http://" + action.getArgument("webServer")50 + "/ConvergedServletApplication/presencestatus.jsp");5152 //QUERY partyB's status53 HtmlForm mainForm = presenceStatusPage.getFormByName("main");54 HtmlTextInput userURITxtField = (HtmlTextInput) mainForm.getInputByName("userURI");55 userURITxtField.setValueAttribute("sip:" + action.getArgument("partyB") + "@" + action.getArgument("domainName"));56 HtmlSelect presenceStatusSelect = (HtmlSelect) mainForm.getElementById("presenceStatus");57 presenceStatusSelect.getOptionByValue("QUERY").setSelected(true);58 HtmlSubmitInput submitBtn = (HtmlSubmitInput) mainForm.getInputByName("submitBtn");59

    60 //submit the form, get the response (new page)61 presenceStatusPage = submitBtn.click();6263 //verify that partyB's status is UNKNOWN64 mainForm = presenceStatusPage.getFormByName("main");65 presenceStatusSelect = (HtmlSelect) mainForm.getElementById("presenceStatus");66 Assert.assertEquals("UNKNOWN", presenceStatusSelect.getSelectedOptions().get(0).getValueAttribute());6768 //verify that nobody is currently asking to be notified about the change in partyB's status69 HtmlElement additionalMsgText = presenceStatusPage.getElementById("additionalMsgTxt");70 Assert.assertEquals("No interest for sip:" + action.getArgument("partyB") + "@" + action.getArgument("domainName"), add71

    cenario2.xml file:///home/raka/scenario2.xml.h

    of 5 02/22/2010 11:10

  • 8/14/2019 Scenario2.XML

    2/5

    72 ctInstance.setVariable("webClient", webClient);73 ctInstance.setVariable("presenceStatusPage", presenceStatusPage);7475 System.out.println("END X: " + ctInstance);7677 return null;78 ]]>79 80 81 Update partyB's status to NOT_AVAILABLE and verify nobody is currently interested in status change of partyB.

    134 SIPAgent partyA = ctInstance.createAgent(action.getArgument("partyA"));135 partyA.setProxy(action.getArgument("sipServer"));136 partyA.register(action.getArgument("domainName"), "", "");137 ctInstance.processSIP(2000);138139 //make the call to partyB140 partyA.call("sip:" + action.getArgument("partyB") + "@" + action.getArgument("domainName"),141 "sip:" + action.getArgument("partyA") + "@" + action.getArgument("domainName"));142 ctInstance.processSIP(2000);143 Assert.assertThat(partyA, CATMatchers.connected());144145 //verify that the OK response received by partyA has the o=Voxpilot in the body.

    cenario2.xml file:///home/raka/scenario2.xml.h

    2 of 5 02/22/2010 11:10

  • 8/14/2019 Scenario2.XML

    3/5

    146 //that's the only way we have -- with our current implementation -- to know whether the call147 //from alice is answered by IVR or not.148 Assert.assertTrue(partyA.getLastRecvdSDPAsString().contains("o=Voxpilot"));149150 //wait 5 seconds, and simulate keypress 1151 ctInstance.processSIP(2000);152 partyA.sendDTMF("1");153154 //wait 5 seconds, and verify that the IVR disconnects the call after receiving the DTMF155 ctInstance.processSIP(2000);156 Assert.assertThat(partyA, CATMatchers.disconnected());157158 //recycle partyA so it can be used for another call session.159 partyA.recycle();160 ctInstance.setVariable("partyA", partyA);161162 System.out.println("END B: " + ctInstance);163164 return null;165 ]]>166 167 168 Trigger the callback and verify the states of the call169

    191 //launch partyB's softphone192 SIPAgent partyB = ctInstance.createAgent(action.getArgument("partyB"));193 partyB.setProxy(action.getArgument("sipServer"));194 partyB.register(action.getArgument("domainName"), "", "");195 ctInstance.processSIP(2000);196197 //update partyB's status to AVAILABLE198 mainForm = presenceStatusPage.getFormByName("main");199 userURITxtField = (HtmlTextInput) mainForm.getInputByName("userURI");200 userURITxtField.setValueAttribute("sip:" + action.getArgument("partyB") + "@" + action.getArgument("domainName"));201 presenceStatusSelect = (HtmlSelect) mainForm.getElementById("presenceStatus");202 presenceStatusSelect.getOptionByValue("AVAILABLE").setSelected(true);203 submitBtn = (HtmlSubmitInput) mainForm.getInputByName("submitBtn");204205 //submit the form, get the response (new page)206 presenceStatusPage = submitBtn.click();207

    208 //verify that partyA got called209 ctInstance.processSIP(2000);210 Assert.assertThat(partyA, CATMatchers.recvdRequest("INVITE"));211212 partyA.sendResponse(SIPResponse.RINGING);213 ctInstance.processSIP(2000);214 CommandId cID = partyA.answer();215216 //verify that partyA is now connected217 ctInstance.processSIP(2000);218 Assert.assertThat(partyA, CATMatchers.connected());219

    cenario2.xml file:///home/raka/scenario2.xml.h

    3 of 5 02/22/2010 11:10

  • 8/14/2019 Scenario2.XML

    4/5

    220 //verify that partyA was greeted by IVR221 partyA.getLastRecvdSDPAsString().contains("o=Voxpilot");222223 //now we need to know the content of the OK sent out by partyA.224 String sdpSentByPartyAOnInitialInviteFromAS = null;225226 for (MessageExchangeRecord mer : ((SIPAgentImpl) partyA).getMessageHistory()) {227 if (mer.getState().equals(CATState.Invited) && mer.getOperation().equals(Operation.MsgSent) &&228 mer.getMessage() instanceof Response) {229 Response responseFromPartyA = (Response) mer.getMessage();230 if (responseFromPartyA.getStatusCode() == Response.OK) {231 if (responseFromPartyA.getContent() instanceof byte[]) {232 sdpSentByPartyAOnInitialInviteFromAS = new String((byte[]) responseFromPartyA.getContent());233 } else {234 sdpSentByPartyAOnInitialInviteFromAS = responseFromPartyA.getContent().toString();235 }236 break;237 }238 }239 }240241 //verify that partyB got called242 ctInstance.processSIP(2000);243 Assert.assertThat(partyB, CATMatchers.invited());244245 partyB.answer();246247 //verify that partyB is connected248 ctInstance.processSIP(2000);249 Assert.assertThat(partyB, CATMatchers.connected());250251 //we need to know the sdp sent by partyB252 String sdpSentByPartyB = null;253 for (MessageExchangeRecord mer : ((SIPAgentImpl) partyB).getMessageHistory()) {254 if (mer.getState().equals(CATState.Invited) && mer.getOperation().equals(Operation.MsgSent) &&255 mer.getMessage() instanceof Response) {256 Response responseFromPartyB = (Response) mer.getMessage();257 if (responseFromPartyB.getStatusCode() == Response.OK) {258 if (responseFromPartyB.getContent() instanceof byte[]) {259 sdpSentByPartyB = new String((byte[]) responseFromPartyB.getContent());260 } else {261 sdpSentByPartyB = responseFromPartyB.getContent().toString();262 }263 break;264 }

    265 }266 }267268 //verify that at the end partyA has the SDP sent by partyB, and partyB has the SDP sent by partyA (they're exchanging voice269 Assert.assertTrue(partyA.getLastRecvdSDPAsString().equals(sdpSentByPartyB));270 Assert.assertTrue(partyB.getLastRecvdSDPAsString().equals(sdpSentByPartyAOnInitialInviteFromAS));271272 ctInstance.processSIP(2000);273 partyA.end();274275 //verify that partyB is also disconnected276 ctInstance.processSIP(2000);277 Assert.assertThat(partyB, CATMatchers.disconnected());278279 System.out.println("END C: " + ctInstance);280281 return null;

    282 ]]>283 284 285 Release the ctInstance286

    cenario2.xml file:///home/raka/scenario2.xml.h

    4 of 5 02/22/2010 11:10

  • 8/14/2019 Scenario2.XML

    5/5

    294 295 296 297 298 299

    cenario2.xml file:///home/raka/scenario2.xml.h

    5 of 5 02/22/2010 11:10