// Second client must remain in long poll mode
assertEquals(1, connects2.size());
// Third client must be in normal poll mode
assertTrue(connects3.size() > 1);
Message lastConnect3 = new LinkedList<>(connects3).getLast();
Map<String,Object> advice3 = lastConnect3.getAdvice();
assertNotNull(advice3);
assertSame(Boolean.TRUE, advice3.get("multiple-clients"));
// Wait for the first and second clients to re-issue a long poll
Thread.sleep(timeout);
// First and second clients must still be in long poll mode
assertEquals(2, connects1.size());
assertEquals(2, connects2.size());
// Abort abruptly the first client
// Third client must switch to long poll
client1.abort();
// Sleep another timeout to be sure client1 does not poll
Thread.sleep(timeout);
assertEquals(2, connects1.size());
// Loop until client3 switched to long poll
for (int i = 0; i < 10; ++i)
{
lastConnect3 = new LinkedList<>(connects3).getLast();
advice3 = lastConnect3.getAdvice();
if (advice3 == null || !advice3.containsKey("multiple-clients"))
break;
Thread.sleep(timeout / 10);
}
lastConnect3 = new LinkedList<>(connects3).getLast();
advice3 = lastConnect3.getAdvice();
assertTrue(advice3 == null || !advice3.containsKey("multiple-clients"));
disconnectBayeuxClient(client2);
disconnectBayeuxClient(client3);