2003-10-12 06:40:08 +02:00
|
|
|
/**
|
|
|
|
*
|
2013-02-07 15:19:47 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2003-10-12 06:40:08 +02:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2013-02-07 15:19:47 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2003-10-12 06:40:08 +02:00
|
|
|
*
|
2013-02-07 15:19:47 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2003-10-12 06:40:08 +02:00
|
|
|
*
|
2013-02-07 15:19:47 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2003-10-12 06:40:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.jivesoftware.smackx;
|
|
|
|
|
|
|
|
import org.jivesoftware.smack.*;
|
|
|
|
import org.jivesoftware.smack.packet.Message;
|
2004-07-12 15:36:13 +02:00
|
|
|
import org.jivesoftware.smack.test.SmackTestCase;
|
2003-10-12 06:40:08 +02:00
|
|
|
import org.jivesoftware.smack.filter.PacketFilter;
|
2015-02-26 18:41:17 +01:00
|
|
|
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
2003-10-12 06:40:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Matt Tucker
|
|
|
|
*/
|
2004-07-12 15:36:13 +02:00
|
|
|
public class GroupChatInvitationTest extends SmackTestCase {
|
2003-10-12 06:40:08 +02:00
|
|
|
|
2017-01-03 11:12:34 +01:00
|
|
|
private StanzaCollector collector = null;
|
2003-10-12 06:40:08 +02:00
|
|
|
|
2004-07-12 15:36:13 +02:00
|
|
|
/**
|
|
|
|
* Constructor for GroupChatInvitationTest.
|
|
|
|
* @param arg0
|
|
|
|
*/
|
|
|
|
public GroupChatInvitationTest(String arg0) {
|
|
|
|
super(arg0);
|
|
|
|
}
|
|
|
|
|
2003-10-12 06:40:08 +02:00
|
|
|
public void testInvitation() {
|
|
|
|
try {
|
2004-07-12 15:36:13 +02:00
|
|
|
GroupChatInvitation invitation = new GroupChatInvitation("test@" + getChatDomain());
|
|
|
|
Message message = new Message(getBareJID(1));
|
2003-10-12 06:40:08 +02:00
|
|
|
message.setBody("Group chat invitation!");
|
|
|
|
message.addExtension(invitation);
|
2015-03-04 21:44:43 +01:00
|
|
|
getConnection(0).sendStanza(message);
|
2003-10-12 06:40:08 +02:00
|
|
|
|
|
|
|
Thread.sleep(250);
|
|
|
|
|
|
|
|
Message result = (Message)collector.pollResult();
|
|
|
|
assertNotNull("Message not delivered correctly.", result);
|
|
|
|
|
|
|
|
GroupChatInvitation resultInvite = (GroupChatInvitation)result.getExtension("x",
|
|
|
|
"jabber:x:conference");
|
|
|
|
|
2004-07-12 15:36:13 +02:00
|
|
|
assertEquals("Invitation not to correct room", "test@" + getChatDomain(),
|
2003-10-12 06:40:08 +02:00
|
|
|
resultInvite.getRoomAddress());
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
fail(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void setUp() throws Exception {
|
|
|
|
super.setUp();
|
2004-07-12 15:36:13 +02:00
|
|
|
// Register listener for groupchat invitations.
|
2015-02-26 18:41:17 +01:00
|
|
|
PacketFilter filter = new StanzaExtensionFilter("x", "jabber:x:conference");
|
2017-01-03 11:12:34 +01:00
|
|
|
collector = getConnection(1).createStanzaCollector(filter);
|
2003-10-12 06:40:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void tearDown() throws Exception {
|
2004-07-12 15:36:13 +02:00
|
|
|
// Cancel the packet collector so that no more results are queued up
|
|
|
|
collector.cancel();
|
2003-10-12 06:40:08 +02:00
|
|
|
|
2004-07-12 15:36:13 +02:00
|
|
|
super.tearDown();
|
|
|
|
}
|
2003-10-12 06:40:08 +02:00
|
|
|
|
2004-07-12 15:36:13 +02:00
|
|
|
protected int getMaxConnections() {
|
|
|
|
return 2;
|
2003-10-12 06:40:08 +02:00
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|