views:

37

answers:

1

Hi,

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 clients, 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...

+1  A: 

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.

Robin
+1 Also consider having several XMPPConnection instances each one with its own PacketListener and BlockingQueue to test message routing or multiuser chats.
mrrtnn