Automating XMPP server testing with multiple client instances
I'm working on a test suite for XMPP server. Currently I have implemented a client able to connect, create account, send stanzas taken from XML file, receive the reply, store it in another file and compare that with the expected output. I can create several clien开发者_如何学Gots, but I'm looking for concurrent operation.
How do I go about making multiple clients to communicate with each other? My vision - put the clients into separate threads and provide commands like 'wait for reply'.
Any advice is appreciated...
All done on same thread in a single testcase.
- Create outgoing connection as user 1.
- Create incoming connection as user 2.
- Register PacketListener for your test stanza which writes to a BlockingQueue on incoming connection.
- Write stanza on outgoing connection.
- Call take() on the queue and test results.
Note: The PacketListener will get called on a separate thread spawned internally by Smack, which is why you need the BlockingQueue to coordinate the send and the reply.
精彩评论