'Test handling a roster request callback.'

def testRosterCallback(self):

    self.stream_start()
    events = []
    def roster_callback(iq):
        events.append(u'roster_callback')
    t = threading.Thread(name=u'get_roster', target=self.xmpp.get_roster, kwargs={str(u'block'): False, str(u'callback'): roster_callback})
    t.start()
    self.send(u'\n                                        <iq    type="get"    id="1">\n                                                <query    xmlns="jabber:iq:roster"    />\n                                        </iq>\n                                ')
    self.recv(u'\n                                        <iq    type="result"    id="1">\n                                                <query    xmlns="jabber:iq:roster">\n                                                        <item    jid="user@localhost"\n                                                                                name="User"\n                                                                                subscription="both">\n                                                                <group>Friends</group>\n                                                                <group>Examples</group>\n                                                        </item>\n                                                </query>\n                                        </iq>\n                                ')
    t.join()
    time.sleep(0.1)
    self.failUnless((events == [u'roster_callback']), (u'Roster    timeout    event    not    triggered:    %s.' % events))
