mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-30 02:02:06 +01:00
Added test to ensure that extensions sent together with the group chat room invitation are received by the invitee. JM-135
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2449 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
a457af11fb
commit
e7bca260bc
1 changed files with 50 additions and 0 deletions
|
@ -62,6 +62,7 @@ import org.jivesoftware.smack.filter.*;
|
|||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
import org.jivesoftware.smackx.Form;
|
||||
import org.jivesoftware.smackx.packet.XHTMLExtension;
|
||||
|
||||
/**
|
||||
* Tests the new MUC functionalities.
|
||||
|
@ -316,6 +317,55 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testInvitationWithMessage() {
|
||||
final String[] answer = new String[2];
|
||||
try {
|
||||
// User2 joins the new room
|
||||
MultiUserChat muc2 = new MultiUserChat(getConnection(1), room);
|
||||
muc2.join("testbot2");
|
||||
|
||||
// User3 is listening to MUC invitations
|
||||
MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() {
|
||||
public void invitationReceived(
|
||||
XMPPConnection conn,
|
||||
String room,
|
||||
String inviter,
|
||||
String reason,
|
||||
String password,
|
||||
Message message) {
|
||||
// Indicate that the invitation was received
|
||||
answer[0] = reason;
|
||||
XHTMLExtension extension = (XHTMLExtension) message.getExtension("html",
|
||||
"http://jabber.org/protocol/xhtml-im");
|
||||
assertNotNull("An extension was not found in the invitation", extension);
|
||||
answer[1] = (String) extension.getBodies().next();
|
||||
}
|
||||
});
|
||||
|
||||
// User2 invites user3 to join to the room
|
||||
Message msg = new Message();
|
||||
XHTMLExtension xhtmlExtension = new XHTMLExtension();
|
||||
xhtmlExtension.addBody("<body>Meet me in this excellent room</body>");
|
||||
msg.addExtension(xhtmlExtension);
|
||||
muc2.invite(msg , getFullJID(2), "Meet me in this excellent room");
|
||||
Thread.sleep(350);
|
||||
|
||||
assertEquals(
|
||||
"Invitation was not received",
|
||||
"Meet me in this excellent room",
|
||||
answer[0]);
|
||||
assertEquals("Rejection was not received",
|
||||
"<body>Meet me in this excellent room</body>", answer[1]);
|
||||
|
||||
// User2 leaves the room
|
||||
muc2.leave();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testDiscoverJoinedRooms() {
|
||||
try {
|
||||
// Check that user1 has joined only to one room
|
||||
|
|
Loading…
Reference in a new issue