Skip to content

Commit

Permalink
Fix for Recording test case
Browse files Browse the repository at this point in the history
This refer to BS-156
  • Loading branch information
gvagenas committed Jun 27, 2018
1 parent 31a62d4 commit f97434c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Expand Up @@ -126,6 +126,8 @@ public class MockMediaGateway extends RestcommUntypedActor {
private NotificationRequest recordingRqnt;
private ActorRef recordingRqntSender;

private boolean recording = false;

public MockMediaGateway () {
super();
system = context().system();
Expand Down Expand Up @@ -364,11 +366,14 @@ public void onReceive (final Object message) throws Exception {
}

private void onReceiveTimeout (Object message) {
if (logger.isInfoEnabled()) {
logger.info("Max recording length reached");
getContext().setReceiveTimeout(Duration.Undefined());
if (recording) {
if (logger.isInfoEnabled()) {
logger.info("Max recording length reached");
}
stopRecording();
notify(recordingRqnt, recordingRqntSender);
}
stopRecording();
notify(recordingRqnt, recordingRqntSender);
}

private void writeRecording (File srcWaveFile, File outWaveFile, int duration) {
Expand Down Expand Up @@ -570,6 +575,7 @@ protected void notificationResponse (final Object message, final ActorRef sender

if (events != null && events.length > 0 && events[0].getEventIdentifier() != null) {
if (events[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) {
recording = true;
startTime = DateTime.now();
//Check for the Recording Length Timer parameter if the RQNT is about PlayRecord request
String[] paramsArray = ((EventName) events[0]).getEventIdentifier().getParms().split(" ");
Expand All @@ -593,7 +599,7 @@ protected void notificationResponse (final Object message, final ActorRef sender
} else if (events[0].getEventIdentifier().getName().equalsIgnoreCase("es")) {
String signal = ((EventName) events[0]).getEventIdentifier().getParms().split("=")[1];

if (signal.equalsIgnoreCase("pr")) {
if (signal.equalsIgnoreCase("pr") && recording) {
stopRecording();
}
} else if (events[0].getEventIdentifier().getName().equalsIgnoreCase("pa")) {
Expand Down Expand Up @@ -627,6 +633,7 @@ protected void notificationResponse (final Object message, final ActorRef sender

private void stopRecording () {
if (recordingFile != null) {
recording = false;
endTime = DateTime.now();
long recordingDuration = (int) ((endTime.getMillis() - startTime.getMillis()) / 1000);
try {
Expand Down
Expand Up @@ -613,11 +613,18 @@ public synchronized void testRecordCallWithAction() throws InterruptedException,
assertEquals(1,liveCalls);
assertEquals(1, liveCallsArraySize);

Thread.sleep(3000);
// Thread.sleep(3000);
// bobCall.disconnect();
//
// Thread.sleep(7000);

bobCall.disconnect();
bobCall.listenForDisconnect();

Thread.sleep(7000);
Thread.sleep(8000);

assertTrue(bobCall.waitForDisconnect(5000));

Thread.sleep(1000);

//Check recording
JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
Expand Down

0 comments on commit f97434c

Please sign in to comment.