2004-06-03 18:19:30 +02:00
|
|
|
/**
|
2006-11-22 23:55:37 +01:00
|
|
|
* $RCSfile$
|
|
|
|
* $Revision$
|
|
|
|
* $Date$
|
|
|
|
*
|
2013-04-07 21:15:32 +02:00
|
|
|
* Copyright 2004 Jive Software.
|
2006-11-22 23:55:37 +01:00
|
|
|
*
|
2013-02-07 15:19:47 +01:00
|
|
|
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2006-11-22 23:55:37 +01:00
|
|
|
*
|
2013-02-07 15:19:47 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2006-11-22 23:55:37 +01: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.
|
2006-11-22 23:55:37 +01:00
|
|
|
*/
|
2004-06-03 18:19:30 +02:00
|
|
|
|
|
|
|
package org.jivesoftware.smack;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import org.jivesoftware.smack.packet.Message;
|
2004-07-12 15:36:13 +02:00
|
|
|
import org.jivesoftware.smack.test.SmackTestCase;
|
2006-11-22 23:55:37 +01:00
|
|
|
import org.jivesoftware.smack.filter.ThreadFilter;
|
2004-06-03 18:19:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests the chat functionality.
|
2006-11-22 23:55:37 +01:00
|
|
|
*
|
2004-06-03 18:19:30 +02:00
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
2004-07-12 15:36:13 +02:00
|
|
|
public class ChatTest extends SmackTestCase {
|
2004-06-03 18:19:30 +02:00
|
|
|
|
|
|
|
public ChatTest(String arg0) {
|
|
|
|
super(arg0);
|
|
|
|
}
|
|
|
|
|
2004-07-12 15:36:13 +02:00
|
|
|
public void testProperties() {
|
2004-06-03 18:19:30 +02:00
|
|
|
try {
|
2006-11-22 23:55:37 +01:00
|
|
|
Chat newChat = getConnection(0).getChatManager().createChat(getFullJID(1), null);
|
|
|
|
PacketCollector collector = getConnection(1)
|
|
|
|
.createPacketCollector(new ThreadFilter(newChat.getThreadID()));
|
2004-06-03 18:19:30 +02:00
|
|
|
|
2006-11-22 23:55:37 +01:00
|
|
|
Message msg = new Message();
|
2004-06-03 18:19:30 +02:00
|
|
|
|
|
|
|
msg.setSubject("Subject of the chat");
|
|
|
|
msg.setBody("Body of the chat");
|
|
|
|
msg.setProperty("favoriteColor", "red");
|
|
|
|
msg.setProperty("age", 30);
|
|
|
|
msg.setProperty("distance", 30f);
|
|
|
|
msg.setProperty("weight", 30d);
|
|
|
|
msg.setProperty("male", true);
|
|
|
|
msg.setProperty("birthdate", new Date());
|
|
|
|
newChat.sendMessage(msg);
|
|
|
|
|
2006-11-22 23:55:37 +01:00
|
|
|
Message msg2 = (Message) collector.nextResult(2000);
|
|
|
|
|
2004-06-03 18:19:30 +02:00
|
|
|
assertNotNull("No message was received", msg2);
|
|
|
|
assertEquals("Subjects are different", msg.getSubject(), msg2.getSubject());
|
|
|
|
assertEquals("Bodies are different", msg.getBody(), msg2.getBody());
|
|
|
|
assertEquals(
|
2006-11-22 23:55:37 +01:00
|
|
|
"favoriteColors are different",
|
|
|
|
msg.getProperty("favoriteColor"),
|
|
|
|
msg2.getProperty("favoriteColor"));
|
2004-06-03 18:19:30 +02:00
|
|
|
assertEquals(
|
2006-11-22 23:55:37 +01:00
|
|
|
"ages are different",
|
|
|
|
msg.getProperty("age"),
|
|
|
|
msg2.getProperty("age"));
|
2004-06-03 18:19:30 +02:00
|
|
|
assertEquals(
|
2006-11-22 23:55:37 +01:00
|
|
|
"distances are different",
|
|
|
|
msg.getProperty("distance"),
|
|
|
|
msg2.getProperty("distance"));
|
2004-06-03 18:19:30 +02:00
|
|
|
assertEquals(
|
2006-11-22 23:55:37 +01:00
|
|
|
"weights are different",
|
|
|
|
msg.getProperty("weight"),
|
|
|
|
msg2.getProperty("weight"));
|
2004-06-03 18:19:30 +02:00
|
|
|
assertEquals(
|
2006-11-22 23:55:37 +01:00
|
|
|
"males are different",
|
|
|
|
msg.getProperty("male"),
|
|
|
|
msg2.getProperty("male"));
|
2004-06-03 18:19:30 +02:00
|
|
|
assertEquals(
|
2006-11-22 23:55:37 +01:00
|
|
|
"birthdates are different",
|
|
|
|
msg.getProperty("birthdate"),
|
|
|
|
msg2.getProperty("birthdate"));
|
2004-06-03 18:19:30 +02:00
|
|
|
}
|
|
|
|
catch (XMPPException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
fail(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-12 15:36:13 +02:00
|
|
|
protected int getMaxConnections() {
|
|
|
|
return 2;
|
2004-06-03 18:19:30 +02:00
|
|
|
}
|
|
|
|
}
|