Skip to content

Commit 967d0e5

Browse files
committed
fixed zendesk#34319
1 parent e16f5ef commit 967d0e5

2 files changed

Lines changed: 156 additions & 0 deletions

File tree

restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/VoiceInterpreter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public final class VoiceInterpreter extends BaseVoiceInterpreter {
189189
private ActorRef confSubVoiceInterpreter;
190190
private Attribute dialRecordAttribute;
191191
private boolean dialActionExecuted = false;
192+
private boolean dialCompletedStatusCallBackExecuted = false;
192193
private ActorRef sender;
193194
private boolean liveCallModification = false;
194195
private boolean recordingCall = true;
@@ -2521,6 +2522,7 @@ public void execute(final Object message) throws Exception {
25212522
}
25222523
dialChildren = null;
25232524
callback();
2525+
dialCompletedStatusCallBackExecuted = true;
25242526
return;
25252527
} else if (dialBranches != null && dialBranches.contains(sender)) {
25262528
if (logger.isInfoEnabled()) {
@@ -2995,6 +2997,11 @@ public void execute(final Object message) throws Exception {
29952997
if (!dialActionExecuted) {
29962998
executeDialAction(message, outboundCall);
29972999
callback(true);
3000+
dialCompletedStatusCallBackExecuted = true;
3001+
}
3002+
3003+
if (!dialCompletedStatusCallBackExecuted) {
3004+
callback();
29983005
}
29993006
// XXX review bridge cleanup!!
30003007

restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwo.java

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,155 @@ public synchronized void testDialNumberRejectBusyRcml() throws InterruptedExcept
14841484
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
14851485
assertEquals(Response.BUSY_HERE, bobCall.getLastReceivedResponse().getStatusCode());
14861486
}
1487+
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+
String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
1613+
1614+
aliceCall.listenForCancel();
1615+
1616+
SipTransaction cancelTransaction = aliceCall.waitForCancel(100 * 1000);
1617+
assertNotNull(cancelTransaction);
1618+
assertTrue(aliceCall.respondToCancel(cancelTransaction, Response.OK, "Alice-OK-2-Cancel", 3600));
1619+
1620+
// hangup (must be as alice, the callee, hanging up in order to test the specific issue found)
1621+
1622+
bobCall.listenForDisconnect();
1623+
assertTrue(bobCall.waitForDisconnect(3 * 1000));
1624+
assertTrue(bobCall.respondToDisconnect());
1625+
1626+
Thread.sleep(5000);
1627+
1628+
logger.info("About to check the Status Callback Requests");
1629+
List<LoggedRequest> requests = findAll(getRequestedFor(urlPathMatching("/StatusCallBack.*")));
1630+
1631+
for (LoggedRequest loggedRequest : requests) {
1632+
logger.info("Status callback received: " + loggedRequest.getUrl());
1633+
}
1634+
assertTrue(requests.size()==4);
1635+
}
14871636

14881637
@Deployment(name = "TestDialVerbPartTwo", managed = true, testable = false)
14891638
public static WebArchive createWebArchiveNoGw() {

0 commit comments

Comments
 (0)