testDirectPresence

Hi

Another instalment in my quest to get the Smack tests to run against a different server.

In the test below, from MessageTest.java, the test code expects a message at the end to be non-null. In fact, the message is null and the test fails.

I have copied the test code below interspersed with the messages taken from the Smack debug tool. The message AKcTl-20 is the last message to appear in the debug, which implies that there is no message to collected as there is nothing being sent by my server when the test code expects there to be.

I can’t really tell who is right here though, the test code or my server.

Many thanks

Nathan

/**

  • Will a user recieve a message from another after only sending the user a directed presence,

  • or will Wildfire intercept for offline storage?

  • User1 becomes lines. User0 never sent an available presence to the server but

  • instead sent one to User1. User1 sends a message to User0. Should User0 get the

  • message?

*/

public void testDirectPresence() {

getConnection(1).sendPacket(new Presence(Presence.Type.available));

Presence presence = new Presence(Presence.Type.available);

presence.setTo(getBareJID(1));

getConnection(0).sendPacket(presence);

PacketCollector collector = getConnection(0)

.createPacketCollector(new MessageTypeFilter(Message.Type.chat));

try {

getConnection(1).getChatManager().createChat(getBareJID(0), null).sendMessage(“Test 1”);

Test 1

gQvkt0

}

catch (XMPPException e) {

e.printStackTrace();

fail(e.getMessage());

}

Message message = (Message) collector.nextResult(2500);

Message is null, test fails.

assertNotNull(“Message not recieved from remote user”, message);

Good work on all the issues you are finding, but I do have to say that I think there are probably quite a few of these tests that should not be running against a real server at all.

The majority of testing of Smacks functionality should be tested using a mock version of the server (DummyConnection or ThreadedDummyConnection) so the tests will be limited to the expected results based on the specification. These would basically then be closer to unit tests instead of integration tests, and can be much more consistent in their running when they don’t rely on an external resource.

Certainly some of the packet reading and writing tests will require an external server, but the ideal would be to have no server at all. That would make for reliable tests for CI purposes.

We will get there eventually I suppose.

Hi

I agree that some of these tests should be mocked rather than against a live server, but that doesn’t help me understand what should be happening here :slight_smile:

Also, it is very useful to be able to test the library against different servers as that helps us see where server behaviours differ. At least two of the patches I have created are related to differences in server behaviours that are within specification bounds.

If we have that chat I suggested about the build, perhaps we can touch upon this as well?

Many thanks

Nathan