1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-23 02:58:00 +01:00

test of sending message after sending a directed presence.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6481 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Alex Wenckus 2006-12-27 20:02:59 +00:00 committed by alex
parent dd6f76fcac
commit 7d9189e490
2 changed files with 43 additions and 2 deletions

View file

@ -36,11 +36,38 @@ public class MessageTest extends SmackTestCase {
super(arg0);
}
/**
* Will a user recieve a message from another after only sending the user a directed presence,
* or will Wildfire intercept for offline storage?
*/
public void testDirectPresence() {
getConnection(1).sendPacket(new Presence(Presence.Type.available));
Presence presence = new Presence(Presence.Type.available);
presence.setTo(getFullJID(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");
}
catch (XMPPException e) {
e.printStackTrace();
fail(e.getMessage());
}
Message message = (Message) collector.nextResult(2500);
assertNotNull("Message not recieved from remote user", message);
}
/**
* Check that when a client becomes unavailable all messages sent to the client are stored offline. So that when
* the client becomes available again the offline messages are received.
*/
public void testOfflineMessage() {
getConnection(0).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendPacket(new Presence(Presence.Type.available));
// Make user2 unavailable
getConnection(1).sendPacket(new Presence(Presence.Type.unavailable));
@ -122,6 +149,8 @@ public class MessageTest extends SmackTestCase {
* connections are not being closed.
*/
public void testHugeMessage() {
getConnection(0).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendPacket(new Presence(Presence.Type.available));
// User2 becomes available again
PacketCollector collector = getConnection(1).createPacketCollector(
new MessageTypeFilter(Message.Type.chat));
@ -154,4 +183,10 @@ public class MessageTest extends SmackTestCase {
protected int getMaxConnections() {
return 2;
}
@Override
protected boolean sendInitialPresence() {
return false;
}
}

View file

@ -60,7 +60,7 @@ public abstract class SmackTestCase extends TestCase {
/**
* Constructor for SmackTestCase.
* @param arg0
* @param arg0 arg for SmackTestCase
*/
public SmackTestCase(String arg0) {
super(arg0);
@ -216,7 +216,7 @@ public abstract class SmackTestCase extends TestCase {
}
}
// Login with the new test account
getConnection(i).login("user" + i, "user" + i);
getConnection(i).login("user" + i, "user" + i, "smack", sendInitialPresence());
}
// Let the server process the available presences
Thread.sleep(150);
@ -240,6 +240,10 @@ public abstract class SmackTestCase extends TestCase {
}
}
protected boolean sendInitialPresence() {
return true;
}
/**
* Initializes the context of the test case. We will first try to load the configuration from
* a file whose name is conformed by the test case class name plus an .xml extension
@ -269,6 +273,7 @@ public abstract class SmackTestCase extends TestCase {
}
}
catch (Exception e) {
/* Do Nothing */
}
}
@ -320,6 +325,7 @@ public abstract class SmackTestCase extends TestCase {
systemStream.close();
}
catch (Exception e) {
/* Do Nothing */
}
}
return parsedOK;