@@ -1485,6 +1485,154 @@ public synchronized void testDialNumberRejectBusyRcml() throws InterruptedExcept
14851485 assertEquals (Response .BUSY_HERE , bobCall .getLastReceivedResponse ().getStatusCode ());
14861486 }
14871487
1488+ private String dialClientWithActionRcml = "<Response><Dial action=\" http://127.0.0.1:8090/action\" method=\" GET\" ><Client>alice</Client></Dial></Response>" ;
1489+ private String hangupActionRcml = "<Response><Hangup /></Response>" ;
1490+
1491+ @ Test // (customised from testDialClientAliceWithRecordAndStatusCallbackForApp)
1492+ public synchronized void testDialClientAliceWithActionAndStatusCallbackForApp () throws InterruptedException , ParseException {
1493+ stubFor (get (urlPathEqualTo ("/1111" ))
1494+ .willReturn (aResponse ()
1495+ .withStatus (200 )
1496+ .withHeader ("Content-Type" , "text/xml" )
1497+ .withBody (dialClientWithActionRcml )));
1498+
1499+ stubFor (get (urlPathEqualTo ("/action" ))
1500+ .willReturn (aResponse ()
1501+ .withStatus (200 )
1502+ .withHeader ("Content-Type" , "text/xml" )
1503+ .withBody (hangupActionRcml )));
1504+
1505+ stubFor (get (urlPathMatching ("/StatusCallBack.*" ))
1506+ .willReturn (aResponse ()
1507+ .withStatus (200 )));
1508+
1509+ // Phone2 register as alice
1510+ SipURI uri = aliceSipStack .getAddressFactory ().createSipURI (null , "127.0.0.1:5080" );
1511+ assertTrue (alicePhone .register (uri , "alice" , "1234" , aliceContact , 3600 , 3600 ));
1512+
1513+ // Prepare second phone to receive call
1514+ SipCall aliceCall = alicePhone .createSipCall ();
1515+ aliceCall .listenForIncomingCall ();
1516+
1517+ // Create outgoing call with first phone
1518+ final SipCall bobCall = bobPhone .createSipCall ();
1519+ bobCall .initiateOutgoingCall (bobContact , dialRestcommWithStatusCallback , null , body , "application" , "sdp" , null , null );
1520+ assertLastOperationSuccess (bobCall );
1521+ assertTrue (bobCall .waitOutgoingCallResponse (5 * 1000 ));
1522+ final int response = bobCall .getLastReceivedResponse ().getStatusCode ();
1523+ assertTrue (response == Response .TRYING || response == Response .RINGING );
1524+
1525+ if (response == Response .TRYING ) {
1526+ assertTrue (bobCall .waitOutgoingCallResponse (5 * 1000 ));
1527+ assertEquals (Response .RINGING , bobCall .getLastReceivedResponse ().getStatusCode ());
1528+ }
1529+
1530+ assertTrue (bobCall .waitOutgoingCallResponse (5 * 1000 ));
1531+ assertEquals (Response .OK , bobCall .getLastReceivedResponse ().getStatusCode ());
1532+
1533+ bobCall .sendInviteOkAck ();
1534+ assertTrue (!(bobCall .getLastReceivedResponse ().getStatusCode () >= 400 ));
1535+
1536+ assertTrue (aliceCall .waitForIncomingCall (3 * 1000 ));
1537+ assertTrue (aliceCall .sendIncomingCallResponse (Response .RINGING , "Ringing-Alice" , 3600 ));
1538+ String receivedBody = new String (aliceCall .getLastReceivedRequest ().getRawContent ());
1539+ assertTrue (aliceCall .sendIncomingCallResponse (Response .OK , "OK-Alice" , 3600 , receivedBody , "application" , "sdp" , null ,
1540+ null ));
1541+ assertTrue (aliceCall .waitForAck (5 * 1000 ));
1542+
1543+ Thread .sleep (3000 );
1544+
1545+ // hangup (must be as alice, the callee, hanging up in order to test the specific issue found)
1546+
1547+ aliceCall .disconnect ();
1548+ bobCall .listenForDisconnect ();
1549+ assertTrue (bobCall .waitForDisconnect (3 * 1000 ));
1550+ assertTrue (bobCall .respondToDisconnect ());
1551+
1552+ Thread .sleep (5000 );
1553+
1554+ logger .info ("About to check the Status Callback Requests" );
1555+ List <LoggedRequest > requests = findAll (getRequestedFor (urlPathMatching ("/StatusCallBack.*" )));
1556+
1557+ for (LoggedRequest loggedRequest : requests ) {
1558+ logger .info ("Status callback received: " + loggedRequest .getUrl ());
1559+ }
1560+ assertTrue (requests .size ()==3 );
1561+ }
1562+
1563+ private String dialTimeOutClientWithActionRcml = "<Response><Dial timeout=\" 3\" action=\" http://127.0.0.1:8090/action\" method=\" GET\" ><Client>alice</Client></Dial></Response>" ;
1564+
1565+ @ Test // (customised from testDialClientAliceWithRecordAndStatusCallbackForApp)
1566+ public synchronized void testDialTimeOutClientAliceWithActionAndStatusCallbackForApp () throws InterruptedException , ParseException {
1567+ stubFor (get (urlPathEqualTo ("/1111" ))
1568+ .willReturn (aResponse ()
1569+ .withStatus (200 )
1570+ .withHeader ("Content-Type" , "text/xml" )
1571+ .withBody (dialTimeOutClientWithActionRcml )));
1572+
1573+ stubFor (get (urlPathEqualTo ("/action" ))
1574+ .willReturn (aResponse ()
1575+ .withStatus (200 )
1576+ .withHeader ("Content-Type" , "text/xml" )
1577+ .withBody (hangupActionRcml )));
1578+
1579+ stubFor (get (urlPathMatching ("/StatusCallBack.*" ))
1580+ .willReturn (aResponse ()
1581+ .withStatus (200 )));
1582+
1583+ // Phone2 register as alice
1584+ SipURI uri = aliceSipStack .getAddressFactory ().createSipURI (null , "127.0.0.1:5080" );
1585+ assertTrue (alicePhone .register (uri , "alice" , "1234" , aliceContact , 3600 , 3600 ));
1586+
1587+ // Prepare second phone to receive call
1588+ SipCall aliceCall = alicePhone .createSipCall ();
1589+ aliceCall .listenForIncomingCall ();
1590+
1591+ // Create outgoing call with first phone
1592+ final SipCall bobCall = bobPhone .createSipCall ();
1593+ bobCall .initiateOutgoingCall (bobContact , dialRestcommWithStatusCallback , null , body , "application" , "sdp" , null , null );
1594+ assertLastOperationSuccess (bobCall );
1595+ assertTrue (bobCall .waitOutgoingCallResponse (5 * 1000 ));
1596+ final int response = bobCall .getLastReceivedResponse ().getStatusCode ();
1597+ assertTrue (response == Response .TRYING || response == Response .RINGING );
1598+
1599+ if (response == Response .TRYING ) {
1600+ assertTrue (bobCall .waitOutgoingCallResponse (5 * 1000 ));
1601+ assertEquals (Response .RINGING , bobCall .getLastReceivedResponse ().getStatusCode ());
1602+ }
1603+
1604+ assertTrue (bobCall .waitOutgoingCallResponse (5 * 1000 ));
1605+ assertEquals (Response .OK , bobCall .getLastReceivedResponse ().getStatusCode ());
1606+
1607+ bobCall .sendInviteOkAck ();
1608+ assertTrue (!(bobCall .getLastReceivedResponse ().getStatusCode () >= 400 ));
1609+
1610+ assertTrue (aliceCall .waitForIncomingCall (3 * 1000 ));
1611+ assertTrue (aliceCall .sendIncomingCallResponse (Response .RINGING , "Ringing-Alice" , 3600 ));
1612+
1613+ aliceCall .listenForCancel ();
1614+
1615+ SipTransaction cancelTransaction = aliceCall .waitForCancel (100 * 1000 );
1616+ assertNotNull (cancelTransaction );
1617+ assertTrue (aliceCall .respondToCancel (cancelTransaction , Response .OK , "Alice-OK-2-Cancel" , 3600 ));
1618+
1619+ // hangup (must be as alice, the callee, hanging up in order to test the specific issue found)
1620+
1621+ bobCall .listenForDisconnect ();
1622+ assertTrue (bobCall .waitForDisconnect (3 * 1000 ));
1623+ assertTrue (bobCall .respondToDisconnect ());
1624+
1625+ Thread .sleep (5000 );
1626+
1627+ logger .info ("About to check the Status Callback Requests" );
1628+ List <LoggedRequest > requests = findAll (getRequestedFor (urlPathMatching ("/StatusCallBack.*" )));
1629+
1630+ for (LoggedRequest loggedRequest : requests ) {
1631+ logger .info ("Status callback received: " + loggedRequest .getUrl ());
1632+ }
1633+ assertEquals (4 , requests .size ());
1634+ }
1635+
14881636 @ Deployment (name = "TestDialVerbPartTwo" , managed = true , testable = false )
14891637 public static WebArchive createWebArchiveNoGw () {
14901638 logger .info ("Packaging Test App" );
0 commit comments