1 52 53 package org.jivesoftware.smackx; 54 55 import org.jivesoftware.smack.*; 56 import org.jivesoftware.smack.packet.Message; 57 import org.jivesoftware.smack.test.SmackTestCase; 58 import org.jivesoftware.smack.filter.PacketFilter; 59 import org.jivesoftware.smack.filter.PacketExtensionFilter; 60 61 66 public class GroupChatInvitationTest extends SmackTestCase { 67 68 private PacketCollector collector = null; 69 70 74 public GroupChatInvitationTest(String arg0) { 75 super(arg0); 76 } 77 78 public void testInvitation() { 79 try { 80 GroupChatInvitation invitation = new GroupChatInvitation("test@" + getChatDomain()); 81 Message message = new Message(getBareJID(1)); 82 message.setBody("Group chat invitation!"); 83 message.addExtension(invitation); 84 getConnection(0).sendPacket(message); 85 86 Thread.sleep(250); 87 88 Message result = (Message)collector.pollResult(); 89 assertNotNull("Message not delivered correctly.", result); 90 91 GroupChatInvitation resultInvite = (GroupChatInvitation)result.getExtension("x", 92 "jabber:x:conference"); 93 94 assertEquals("Invitation not to correct room", "test@" + getChatDomain(), 95 resultInvite.getRoomAddress()); 96 } 97 catch (Exception e) { 98 fail(e.getMessage()); 99 } 100 } 101 102 protected void setUp() throws Exception { 103 super.setUp(); 104 PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference"); 106 collector = getConnection(1).createPacketCollector(filter); 107 } 108 109 protected void tearDown() throws Exception { 110 collector.cancel(); 112 113 super.tearDown(); 114 } 115 116 protected int getMaxConnections() { 117 return 2; 118 } 119 } | Popular Tags |