2525import org .jitsi .jigasi .xmpp .*;
2626import org .jitsi .service .configuration .*;
2727import org .jitsi .xmpp .extensions .rayo .*;
28- import org .junit .jupiter .api .Test ;
2928import org .junit .jupiter .api .*;
3029import org .jxmpp .jid .*;
3130import org .jxmpp .jid .impl .*;
4342 * @author Pawel Domas
4443 * @author Nik Vaessen
4544 */
45+ @ Timeout (30 )
4646public class CallsHandlingTest
4747{
4848 private static OSGiHandler osgi ;
@@ -65,7 +65,6 @@ public static void setUpClass()
6565 osgi = new OSGiHandler ();
6666 var fw = osgi .init ();
6767 var start = System .nanoTime ();
68- Thread .sleep (5000 );
6968 while (fw .getState () != Framework .ACTIVE )
7069 {
7170 if (System .nanoTime () - start > TimeUnit .SECONDS .toNanos (5 ))
@@ -139,7 +138,7 @@ public void testIncomingSipCall()
139138
140139 // SipGateway ought to accept incoming sip call
141140 // once JVB conference is joined.
142- callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS , 1000 );
141+ callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS );
143142
144143 SipGatewaySession session
145144 = osgi .getSipGateway ().getActiveSessions ().get (0 );
@@ -155,7 +154,7 @@ public void testIncomingSipCall()
155154 CallManager .hangupCall (sipCall );
156155
157156 callStateWatch .waitForState (
158- session .getJvbCall (), CallState .CALL_ENDED , 1000 );
157+ session .getJvbCall (), CallState .CALL_ENDED );
159158 assertFalse (jvbConfRoom .isJoined ());
160159 }
161160
@@ -202,7 +201,7 @@ public void testOutgoingSipCall()
202201 // Remote SIP peer accepts
203202 CallManager .acceptCall (sipCall );
204203
205- callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS , 1000 );
204+ callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS );
206205
207206 GatewaySessionAsserts sessionWatch = new GatewaySessionAsserts ();
208207 sessionWatch .assertJvbRoomJoined (session , 2000 );
@@ -213,16 +212,16 @@ public void testOutgoingSipCall()
213212
214213 assertNotNull (chatRoom );
215214 assertTrue (chatRoom .isJoined ());
216- callStateWatch .waitForState (jvbCall , CallState .CALL_IN_PROGRESS , 1000 );
215+ callStateWatch .waitForState (jvbCall , CallState .CALL_IN_PROGRESS );
217216 assertEquals (CallState .CALL_IN_PROGRESS , jvbCall .getCallState ());
218217
219218 // Now tear down, SIP calee ends the call
220219 // then XMPP cal should be terminated and MUC room left
221220
222221 CallManager .hangupCall (sipCall );
223222
224- callStateWatch .waitForState (sipCall , CallState .CALL_ENDED , 1000 );
225- callStateWatch .waitForState (jvbCall , CallState .CALL_ENDED , 1000 );
223+ callStateWatch .waitForState (sipCall , CallState .CALL_ENDED );
224+ callStateWatch .waitForState (jvbCall , CallState .CALL_ENDED );
226225 assertFalse (chatRoom .isJoined ());
227226 }
228227
@@ -270,12 +269,11 @@ public void testFocusLeftTheRoomWithNoResume()
270269 // Focus will leave the room after inviting us to the conference
271270 focus .setLeaveRoomAfterInvite (true );
272271
273- CallStateListener callStateWatch = new CallStateListener ();
274-
275272 // Create incoming call
276- MockCall sipCall = sipProvider .getTelephony ().mockIncomingGatewayCall ("calee " , roomName );
273+ MockCall sipCall = sipProvider .getTelephony ().mockIncomingGatewayCall ("callee " , roomName );
277274
278- callStateWatch .waitForState (sipCall , CallState .CALL_ENDED , 2000 );
275+ var callStateWatch = new CallStateListener ();
276+ callStateWatch .waitForState (sipCall , CallState .CALL_ENDED );
279277
280278 // Now we expect SIP call to be terminated
281279 assertEquals (CallState .CALL_ENDED , focus .getCall ().getCallState ());
@@ -302,10 +300,10 @@ public void testFocusLeftTheRoomWithResume()
302300 // Create incoming call
303301 MockCall sipCall = sipProvider .getTelephony ().mockIncomingGatewayCall ("calee" , roomName );
304302
305- callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS , 2000 );
303+ callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS );
306304
307305 // Now we expect SIP call to be in progress, but xmpp call ended
308- callStateWatch .waitForState (focus .getCall (), CallState .CALL_ENDED , 2000 );
306+ callStateWatch .waitForState (focus .getCall (), CallState .CALL_ENDED );
309307 assertNull (focus .getChatRoom ());
310308
311309 AbstractGateway .setJvbInviteTimeout (origValue );
@@ -343,11 +341,8 @@ public void testCallControl()
343341 CallContext ctx = new CallContext (this );
344342 ctx .setDomain (serverName );
345343
346- org .jivesoftware .smack .packet .IQ result = callControl .handleDialIq (dialIq , ctx , null );
347-
348- assertNotNull (result );
349-
350- RefIq callRef = (RefIq ) result ;
344+ var callRef = callControl .handleDialIq (dialIq , ctx , null );
345+ assertNotNull (callRef );
351346
352347 String callUri = callRef .getUri ();
353348 assertEquals ("xmpp:" , callUri .substring (0 , 5 ));
@@ -364,7 +359,7 @@ public void testCallControl()
364359
365360 CallStateListener callStateWatch = new CallStateListener ();
366361
367- callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS , 1000 );
362+ callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS );
368363
369364 Jid callResource = JidCreate .from (callUri .substring (5 )); //remove xmpp:
370365
@@ -377,7 +372,7 @@ public void testCallControl()
377372 Call xmppCall = session .getJvbCall ();
378373
379374 // We joined JVB conference call
380- callStateWatch .waitForState (xmppCall , CallState .CALL_IN_PROGRESS , 1000 );
375+ callStateWatch .waitForState (xmppCall , CallState .CALL_IN_PROGRESS );
381376
382377 ChatRoom conferenceChatRoom = session .getJvbChatRoom ();
383378
@@ -389,8 +384,8 @@ public void testCallControl()
389384 // FIXME: validate result
390385 callControl .handleHangUp (hangUp );
391386
392- callStateWatch .waitForState (xmppCall , CallState .CALL_ENDED , 1000 );
393- callStateWatch .waitForState (sipCall , CallState .CALL_ENDED , 1000 );
387+ callStateWatch .waitForState (xmppCall , CallState .CALL_ENDED );
388+ callStateWatch .waitForState (sipCall , CallState .CALL_ENDED );
394389 assertFalse (conferenceChatRoom .isJoined ());
395390 }
396391
@@ -419,7 +414,7 @@ public void testDefaultJVbRoomProperty()
419414
420415 // SipGateway ought to accept incoming sip call
421416 // once JVB conference is joined.
422- callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS , 2000 );
417+ callStateWatch .waitForState (sipCall , CallState .CALL_IN_PROGRESS );
423418
424419 // Now tear down, SIP calee ends the call
425420 // then XMPP cal should be terminated and MUC room left
@@ -435,8 +430,8 @@ public void testDefaultJVbRoomProperty()
435430
436431 CallManager .hangupCall (sipCall );
437432
438- callStateWatch .waitForState (xmppCall , CallState .CALL_ENDED , 1000 );
439- callStateWatch .waitForState (sipCall , CallState .CALL_ENDED , 1000 );
433+ callStateWatch .waitForState (xmppCall , CallState .CALL_ENDED );
434+ callStateWatch .waitForState (sipCall , CallState .CALL_ENDED );
440435 assertFalse (jvbRoom .isJoined ());
441436 }
442437
@@ -458,9 +453,9 @@ public void testSimultaneousCalls()
458453
459454 CallStateListener callStateWatch = new CallStateListener ();
460455
461- callStateWatch .waitForState (sipCall1 , CallState .CALL_IN_PROGRESS , 1000 );
462- callStateWatch .waitForState (sipCall2 , CallState .CALL_IN_PROGRESS , 1000 );
463- callStateWatch .waitForState (sipCall3 , CallState .CALL_IN_PROGRESS , 1000 );
456+ callStateWatch .waitForState (sipCall1 , CallState .CALL_IN_PROGRESS );
457+ callStateWatch .waitForState (sipCall2 , CallState .CALL_IN_PROGRESS );
458+ callStateWatch .waitForState (sipCall3 , CallState .CALL_IN_PROGRESS );
464459
465460 // Check peers are not on hold
466461 CallPeerStateListener peerStateWatch = new CallPeerStateListener ();
@@ -492,9 +487,9 @@ public void testSimultaneousCalls()
492487 CallManager .hangupCall (sipCall2 );
493488 CallManager .hangupCall (sipCall3 );
494489
495- callStateWatch .waitForState (jvbCall1 , CallState .CALL_ENDED , 1000 );
496- callStateWatch .waitForState (jvbCall2 , CallState .CALL_ENDED , 1000 );
497- callStateWatch .waitForState (jvbCall3 , CallState .CALL_ENDED , 1000 );
490+ callStateWatch .waitForState (jvbCall1 , CallState .CALL_ENDED );
491+ callStateWatch .waitForState (jvbCall2 , CallState .CALL_ENDED );
492+ callStateWatch .waitForState (jvbCall3 , CallState .CALL_ENDED );
498493
499494 assertEquals (CallState .CALL_ENDED , sipCall1 .getCallState ());
500495 assertEquals (CallState .CALL_ENDED , sipCall2 .getCallState ());
@@ -530,7 +525,7 @@ public void testNoFocusInTheRoom()
530525
531526 // Assert incoming call state
532527 callStateWatch .waitForState (
533- sipCall1 , CallState .CALL_INITIALIZATION , 1000 );
528+ sipCall1 , CallState .CALL_INITIALIZATION );
534529
535530 // We expect to have 1 active sessions
536531 List <SipGatewaySession > sessions = gatewaySessions .getSessions (1000 );
@@ -551,7 +546,7 @@ public void testNoFocusInTheRoom()
551546 assertNull (jvbCall1 );
552547
553548 callStateWatch .waitForState (
554- sipCall1 , CallState .CALL_ENDED , jvbInviteTimeout + 200 );
549+ sipCall1 , CallState .CALL_ENDED );
555550
556551 assertFalse (jvbRoom1 .isJoined ());
557552
0 commit comments