@Test
public void test_broadcast_multiple_rooms() {

    final SocketIoAdapter adapter = Mockito.mock(SocketIoAdapter.class);
    Mockito.doCallRealMethod().when(adapter)
            .broadcast(Mockito.any(Packet.class), Mockito.any(String[].class));
    Mockito.doAnswer(invocationOnMock -> {
        final Packet packet = invocationOnMock.getArgument(0);
        final String[] rooms = invocationOnMock.getArgument(1);
        final String[] socketsExcluded = invocationOnMock.getArgument(2);
        assertEquals(Parser.EVENT, packet.type);
        assertNotNull(packet.data);
        assertEquals(JSONArray.class, packet.data.getClass());
        assertEquals(1, ((JSONArray) packet.data).length());
        assertEquals("baz", ((JSONArray) packet.data).get(0));
        assertNotNull(rooms);
        assertArrayEquals(new String[] { "foo", "bar" }, rooms);
        assertNull(socketsExcluded);
        return null;
    }).when(adapter).broadcast(Mockito.any(Packet.class), Mockito.any(String[].class), Mockito.isNull());
    final SocketIoAdapter.AdapterFactory adapterFactory = Mockito.mock(SocketIoAdapter.AdapterFactory.class);
    Mockito.doAnswer(invocationOnMock -> adapter)
            .when(adapterFactory)
            .createAdapter(Mockito.any(SocketIoNamespaceImpl.class));
    final SocketIoServer server = Mockito.spy(new SocketIoServer(
            new EngineIoServer(),
            SocketIoServerOptions.newFromDefault()
                    .setAdapterFactory(adapterFactory)));
    final SocketIoNamespace namespace = server.namespace("/");
    namespace.broadcast(new String[] { "foo", "bar" }, "baz", null);
    Mockito.verify(adapter, Mockito.times(1))
            .broadcast(Mockito.any(Packet.class), Mockito.any(String[].class), Mockito.isNull());
}