org.jivesoftware.util
Class ConnectionUtils

java.lang.Object
  extended by org.jivesoftware.util.ConnectionUtils

public class ConnectionUtils
extends java.lang.Object

A collection of utility methods to create mocked XMPP connections.

Author:
Henning Staib

Constructor Summary
ConnectionUtils()
           
 
Method Summary
static Connection createMockedConnection(Protocol protocol, java.lang.String initiatorJID, java.lang.String xmppServer)
          Creates a mocked XMPP connection that stores every packet that is send over this connection in the given protocol instance and returns the predefined answer packets form the protocol instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionUtils

public ConnectionUtils()
Method Detail

createMockedConnection

public static Connection createMockedConnection(Protocol protocol,
                                                java.lang.String initiatorJID,
                                                java.lang.String xmppServer)
Creates a mocked XMPP connection that stores every packet that is send over this connection in the given protocol instance and returns the predefined answer packets form the protocol instance.

This mocked connection can used to collect packets that require a reply using a PacketCollector.

 
   PacketCollector collector = connection.createPacketCollector(new PacketFilter());
   connection.sendPacket(packet);
   Packet reply = collector.nextResult();
 
 

Parameters:
protocol - protocol helper containing answer packets
initiatorJID - the user associated to the XMPP connection
xmppServer - the XMPP server associated to the XMPP connection
Returns:
a mocked XMPP connection