Skip to content

Commit 9eca128

Browse files
author
maria-farooq
authored
Merge pull request #2726 from RestComm/restcomm-1444
Restcomm 1444 - Fixes for TestDialVerb* test cases
2 parents c8b82ba + f055dd9 commit 9eca128

8 files changed

Lines changed: 55 additions & 47 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ private Notification notification(final int log, final int error, final String m
669669
}
670670

671671
ActorRef parser(final String xml) {
672+
if(logger.isDebugEnabled()) {
673+
logger.debug("About to create Parser for RCML "+xml);
674+
}
672675
final Props props = new Props(new UntypedActorFactory() {
673676
private static final long serialVersionUID = 1L;
674677

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ private void executeDialAction(final Object message, final ActorRef outboundCall
25622562
}
25632563
if (attribute != null && !dialActionExecuted) {
25642564
if(logger.isInfoEnabled()){
2565-
logger.info("Proceeding to execute Dial Action attribute");
2565+
logger.info("Proceeding to execute Dial Action attribute, dial verb : "+verb.toString());
25662566
}
25672567
this.dialActionExecuted = true;
25682568

@@ -3417,6 +3417,7 @@ public void postStop() {
34173417
call = null;
34183418
}
34193419

3420+
getContext().stop(parser);
34203421
getContext().stop(self());
34213422
postCleanup();
34223423
}

restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/rcml/Parser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
/**
4545
* @author quintana.thomas@gmail.com (Thomas Quintana)
4646
*/
47-
public final class Parser extends RestcommUntypedActor {
47+
public class Parser extends RestcommUntypedActor {
4848
private static Logger logger = Logger.getLogger(Parser.class);
4949
private Tag document;
5050
private Iterator<Tag> iterator;

restcomm/restcomm.mgcp/src/main/java/org/restcomm/connect/mgcp/MockMediaGateway.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,12 @@ public void onReceive (final Object message) throws Exception {
365365

366366
private void onReceiveTimeout (Object message) {
367367
if (logger.isInfoEnabled()) {
368-
logger.info("Max recording length reached");
368+
logger.info("MockMediaGatewat - Max recording length reached");
369369
}
370370
stopRecording();
371371
notify(recordingRqnt, recordingRqntSender);
372+
getContext().setReceiveTimeout(Duration.Undefined());
373+
372374
}
373375

374376
private void writeRecording (File srcWaveFile, File outWaveFile, int duration) {

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
import static org.junit.Assert.assertTrue;
4545
import org.junit.experimental.categories.Category;
4646
import org.restcomm.connect.commons.annotations.ParallelClassTests;
47-
import org.restcomm.connect.commons.annotations.WithInMinsTests;
4847
import org.restcomm.connect.testsuite.NetworkPortAssigner;
49-
import org.restcomm.connect.commons.annotations.UnstableTests;
5048
import org.restcomm.connect.testsuite.WebArchiveUtil;
5149

5250
/**
@@ -168,8 +166,9 @@ public void after() throws Exception {
168166

169167

170168
//Non regression test for https://github.com/Mobicents/RestComm/issues/612
169+
private final String actionUrlRcmlWithTimeLimit = "<Dial timeout=\"50\" timeLimit=\"5\"><Uri>sip:alice@127.0.0.1:" + alicePort + "</Uri></Dial>";
171170
@Test
172-
@Category({UnstableTests.class, FeatureAltTests.class})
171+
@Category({FeatureAltTests.class})
173172
public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURL() throws InterruptedException, ParseException {
174173

175174
stubFor(get(urlPathEqualTo("/1111"))
@@ -182,9 +181,11 @@ public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURL() throws I
182181
.willReturn(aResponse()
183182
.withStatus(200)
184183
.withHeader("Content-Type", "text/xml")
185-
.withBody(actionUrlRcml)));
184+
.withBody(actionUrlRcmlWithTimeLimit)));
185+
186+
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
187+
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
186188

187-
//Prepare Fotini phone to receive a call
188189
final SipCall aliceCall = alicePhone.createSipCall();
189190
aliceCall.listenForIncomingCall();
190191

@@ -231,7 +232,7 @@ public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURL() throws I
231232

232233
//Non regression test for https://github.com/Mobicents/RestComm/issues/612
233234
@Test
234-
@Category({UnstableTests.class, FeatureAltTests.class})
235+
@Category({FeatureAltTests.class})
235236
public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURLWithNullFinishOnKey() throws InterruptedException, ParseException {
236237

237238
stubFor(get(urlPathEqualTo("/1111"))
@@ -244,9 +245,8 @@ public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURLWithNullFin
244245
.willReturn(aResponse()
245246
.withStatus(200)
246247
.withHeader("Content-Type", "text/xml")
247-
.withBody(actionUrlRcml)));
248+
.withBody(actionUrlRcmlWithTimeLimit)));
248249

249-
//Prepare Fotini phone to receive a call
250250
final SipCall aliceCall = alicePhone.createSipCall();
251251
aliceCall.listenForIncomingCall();
252252

@@ -272,22 +272,20 @@ public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURLWithNullFin
272272

273273
//At this point bob leaves a voicemail
274274

275-
//Now Fotini should receive a call
276275
assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
277276
assertTrue(aliceCall.sendIncomingCallResponse(100, "Trying-Fotini", 600));
278277
assertTrue(aliceCall.sendIncomingCallResponse(180, "Ringing-Fotini", 600));
279278
String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
280279
assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Fotini", 3600, receivedBody, "application", "sdp", null, null));
281280
assertTrue(aliceCall.waitForAck(5000));
281+
282282
aliceCall.listenForDisconnect();
283283

284284
Thread.sleep(2000);
285285

286-
// hangup.
287-
288286
assertTrue(bobCall.disconnect());
289287

290-
assertTrue(aliceCall.waitForDisconnect(50 * 1000));
288+
assertTrue(aliceCall.waitForDisconnect(125 * 1000));
291289
assertTrue(aliceCall.respondToDisconnect());
292290
}
293291

@@ -339,7 +337,6 @@ public synchronized void testDialWithCustomHeaders() throws InterruptedException
339337
}
340338

341339
@Test
342-
@Category(UnstableTests.class)
343340
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
344341
public synchronized void testDialSip() throws InterruptedException, ParseException {
345342
stubFor(get(urlPathEqualTo("/1111"))

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.junit.Test;
1919
import org.junit.runner.RunWith;
2020
import org.restcomm.connect.commons.Version;
21-
import org.restcomm.connect.commons.annotations.UnstableTests;
2221
import org.restcomm.connect.testsuite.telephony.security.DigestServerAuthenticationMethod;
2322

2423
import javax.sip.address.SipURI;
@@ -161,7 +160,6 @@ public void after() throws Exception {
161160

162161
@Test
163162
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
164-
@Category(UnstableTests.class)
165163
public synchronized void testDialSip() throws InterruptedException, ParseException {
166164
stubFor(get(urlPathEqualTo("/1111"))
167165
.willReturn(aResponse()

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

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.restcomm.connect.testsuite.http.RestcommCallsTool;
2929

3030
import javax.sip.Dialog;
31+
import javax.sip.DialogState;
3132
import javax.sip.SipException;
3233
import javax.sip.address.SipURI;
3334
import javax.sip.header.FromHeader;
@@ -55,9 +56,8 @@
5556
import static org.junit.Assert.assertTrue;
5657
import org.junit.experimental.categories.Category;
5758
import org.restcomm.connect.commons.annotations.ParallelClassTests;
58-
import org.restcomm.connect.commons.annotations.WithInMinsTests;
59-
import org.restcomm.connect.testsuite.NetworkPortAssigner;
6059
import org.restcomm.connect.commons.annotations.UnstableTests;
60+
import org.restcomm.connect.testsuite.NetworkPortAssigner;
6161
import org.restcomm.connect.testsuite.WebArchiveUtil;
6262

6363
/**
@@ -91,7 +91,7 @@ public class TestDialVerbPartTwo {
9191
@Rule
9292
public WireMockRule wireMockRule = new WireMockRule(mockPort); // No-args constructor defaults to port 8080
9393
private String dialClientWithRecordingRcml = "<Response><Dial timeLimit=\"10\" timeout=\"10\" record=\"true\" action=\"http://127.0.0.1:" + mockPort + "/action\" method=\"GET\"><Client>alice</Client></Dial></Response>";
94-
private String dialConferenceWithDialActionRcml = "<Response><Dial action=\"http://127.0.0.1:" + mockPort + "/action\" method=\"GET\"><Conference>test</Conference></Dial></Response>";
94+
private String dialConferenceWithDialActionRcml = "<Response><Dial action=\"http://127.0.0.1:" + mockPort + "/action\" method=\"GET\"><Conference>test9876</Conference></Dial></Response>";
9595
private String dialClientWithRecordingRcml2 = "<Response><Dial timeLimit=\"10\" timeout=\"10\" record=\"true\" action=\"http://127.0.0.1:" + mockPort + "/action&sticky_numToDial=00306986971731\" method=\"GET\"><Client>alice</Client></Dial></Response>";
9696
private String dialRecordWithActionRcml = "<Response><Record action=\"http://127.0.0.1:" + mockPort + "/recordAction\" method=\"GET\" finishOnKey=\"*\" maxLength=\"10\" playBeep=\"true\"/></Response>";
9797
private String dialClientWithActionRcml = "<Response><Dial action=\"http://127.0.0.1:" + mockPort + "/action\" method=\"GET\"><Client>alice</Client></Dial></Response>";
@@ -166,20 +166,23 @@ public void before() throws Exception {
166166
@After
167167
public void after() throws Exception {
168168
if (bobPhone != null) {
169+
bobPhone.unregister(bobContact, 3600);
169170
bobPhone.dispose();
170171
}
171172
if (bobSipStack != null) {
172173
bobSipStack.dispose();
173174
}
174175

175-
if (aliceSipStack != null) {
176-
aliceSipStack.dispose();
177-
}
178176
if (alicePhone != null) {
177+
alicePhone.unregister(aliceContact, 3600);
179178
alicePhone.dispose();
180179
}
180+
if (aliceSipStack != null) {
181+
aliceSipStack.dispose();
182+
}
181183

182184
if (georgePhone != null) {
185+
georgePhone.unregister(georgeContact, 3600);
183186
georgePhone.dispose();
184187
}
185188
if (georgeSipStack != null) {
@@ -503,17 +506,20 @@ public synchronized void testDialConferenceWithDialActionNoRcml() throws Interru
503506
assertTrue(bobCall.waitForAnswer(5000));
504507
}
505508

506-
private String dialConferenceNoDialActionSendSMSRcml = "<Response><Dial><Conference>test</Conference></Dial>" +
509+
private String dialConferenceNoDialActionSendSMSRcml = "<Response><Dial><Conference>test12345</Conference></Dial>" +
507510
"<Sms to=\"bob\" from=\"+12223334499\">Hello World!</Sms></Response>";
508511
private String dialConferenceNoDialActionRcml = "<Response><Dial><Conference>test</Conference></Dial></Response>";
509512
@Test
510-
@Category({UnstableTests.class, FeatureAltTests.class})
513+
@Category({FeatureAltTests.class})
511514
public synchronized void testDialConferenceNoDialAction_SendSms() throws InterruptedException, ParseException {
515+
// wireMockRule.resetMappings();
512516
stubFor(get(urlPathEqualTo("/1111"))
513517
.willReturn(aResponse()
514518
.withStatus(200)
515519
.withHeader("Content-Type", "text/xml")
516-
.withBody(dialConferenceNoDialActionSendSMSRcml)));
520+
// .withBody(dialConferenceNoDialActionSendSMSRcml)));
521+
.withBody("<Response><Dial><Conference>test12345</Conference></Dial>" +
522+
"<Sms to=\"bob\" from=\"+12223334499\">Hello World!</Sms></Response>")));
517523

518524
// Phone2 register as alice
519525
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
@@ -543,15 +549,16 @@ public synchronized void testDialConferenceNoDialAction_SendSms() throws Interru
543549
assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
544550

545551
//Now bob is connected to the conference room
552+
bobCall.listenForMessage();
546553

547554
Thread.sleep(7000);
548555

549556
// hangup.
550557
bobCall.disconnect();
551558
assertTrue(bobCall.waitForAnswer(5000));
552559

553-
bobCall.listenForMessage();
554-
assertTrue(bobCall.waitForMessage(60 * 1000));
560+
561+
assertTrue(bobCall.waitForMessage(90 * 1000));
555562
assertTrue(bobCall.sendMessageResponse(200, "OK-Message Received", 3600));
556563
Request messageReceived = bobCall.getLastReceivedMessageRequest();
557564
assertTrue(new String(messageReceived.getRawContent()).equalsIgnoreCase("Hello World!"));
@@ -706,7 +713,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForApp()
706713
}
707714

708715
@Test //Test case for issue 320
709-
@Category({UnstableTests.class,FeatureAltTests.class})
716+
@Category({FeatureAltTests.class})
710717
public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppForThreeCalls() throws InterruptedException, ParseException, MalformedURLException {
711718
stubFor(get(urlPathEqualTo("/1111"))
712719
.willReturn(aResponse()
@@ -726,12 +733,14 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
726733

727734
// Phone2 register as alice
728735
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
729-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
736+
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 600, 600));
730737

731738
// Prepare second phone to receive call
732739
SipCall aliceCall = alicePhone.createSipCall();
740+
alicePhone.setLoopback(true);
733741
aliceCall.listenForIncomingCall();
734742

743+
735744
// Create outgoing call with first phone
736745
final SipCall bobCall = bobPhone.createSipCall();
737746
bobCall.initiateOutgoingCall(bobContact, dialRestcommWithStatusCallback, null, body, "application", "sdp", null, null);
@@ -838,11 +847,13 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
838847

839848
Thread.sleep(3000);
840849

850+
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 600, 600));
851+
841852
recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
842853
assertNotNull(recordings);
843854
assertTrue(recordings.size() >= 2);
844855
double duration = recordings.get(1).getAsJsonObject().get("duration").getAsDouble();
845-
assertEquals(3.0, duration, 0.5);
856+
assertEquals(7.0, duration, 1.0);
846857
assertNotNull(((JsonObject)recordings.get(1)).get("uri").getAsString());
847858

848859
/*
@@ -900,7 +911,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
900911
recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
901912
assertNotNull(recordings);
902913
assertTrue(recordings.size() >= 3);
903-
assertTrue("7.0".equalsIgnoreCase(((JsonObject)recordings.get(2)).get("duration").getAsString()));
914+
assertEquals(7.0, ((JsonObject)recordings.get(2)).get("duration").getAsDouble(), 1.0);
904915
assertNotNull(((JsonObject)recordings.get(2)).get("uri").getAsString());
905916

906917
logger.info("About to check the Status Callback Requests");
@@ -1002,7 +1013,6 @@ public synchronized void testRecordWithActionAndStatusCallbackForAppWithDisconne
10021013
}
10031014

10041015
@Test
1005-
@Category(UnstableTests.class)
10061016
//Test case for github issue 859
10071017
public synchronized void testRecordWithActionAndStatusCallbackForAppWithBobSendsFinishKey() throws InterruptedException, ParseException {
10081018
stubFor(get(urlPathEqualTo("/1111"))
@@ -1048,10 +1058,14 @@ public synchronized void testRecordWithActionAndStatusCallbackForAppWithBobSends
10481058
bobCall.sendInviteOkAck();
10491059
assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
10501060

1061+
bobCall.listenForDisconnect();
1062+
10511063
//Here we have Restcomm voice mail app for 10 sec
10521064
Thread.sleep(5000);
10531065

10541066
Dialog dialog = bobCall.getDialog();
1067+
assertNotNull(dialog);
1068+
assertEquals(DialogState.CONFIRMED, dialog.getState());
10551069
String infoBody = "\n" +
10561070
"Signal=*\n" +
10571071
"Duration=28";
@@ -1070,7 +1084,7 @@ public synchronized void testRecordWithActionAndStatusCallbackForAppWithBobSends
10701084
SipTransaction infoTransaction = bobPhone.sendRequestWithTransaction(info, false, dialog);
10711085
assertNotNull(infoTransaction);
10721086

1073-
bobCall.listenForDisconnect();
1087+
10741088
assertTrue(bobCall.waitForDisconnect(5000));
10751089
assertTrue(bobCall.respondToDisconnect());
10761090

@@ -1537,7 +1551,6 @@ public synchronized void testDialNumberRejectBusyRcml() throws InterruptedExcept
15371551

15381552
private String hangupActionRcml = "<Response><Hangup /></Response>";
15391553

1540-
@Category(UnstableTests.class)
15411554
@Test // (customised from testDialClientAliceWithRecordAndStatusCallbackForApp)
15421555
public synchronized void testDialClientAliceWithActionAndStatusCallbackForApp() throws InterruptedException, ParseException {
15431556
stubFor(get(urlPathEqualTo("/1111"))

0 commit comments

Comments
 (0)