te an XMPP packet PacketCollector collector = connection.createPacketCollector(new PacketIDFilter()); connection.sendPacket(packet); Packet reply = collector.nextResult(); } public void testMethod() { // create protocol Protocol protocol = new Protocol(); // create mocked connection Connection connection = ConnectionUtils.createMockedConnection(protocol, "user@xmpp-server", "xmpp-server"); // add reply packet to protocol Packet reply = new Packet(); protocol.add(reply); // call method to test methodToTest(); // verify protocol protocol.verifyAll(); } Additionally to adding the response to the protocol instance you can pass verifications that will be executed when {@link #verifyAll()} is invoked.(See {@link Verification} for more details.)
If the {@link #printProtocol} flag is set to true {@link #verifyAll()} willalso print out the XML messages in the order they are sent to the console. This may be useful to inspect the whole protocol "by hand".
@author Henning Staib