1 52 53 package org.jivesoftware.smack; 54 55 import java.util.Date ; 56 57 import org.jivesoftware.smack.packet.Message; 58 import org.jivesoftware.smack.test.SmackTestCase; 59 60 61 66 public class ChatTest extends SmackTestCase { 67 68 72 public ChatTest(String arg0) { 73 super(arg0); 74 } 75 76 public void testProperties() { 77 try { 78 Chat newChat = getConnection(0).createChat(getFullJID(1)); 79 Chat newChat2 = new Chat(getConnection(1), getFullJID(0), newChat.getThreadID()); 80 81 Message msg = newChat.createMessage(); 82 83 msg.setSubject("Subject of the chat"); 84 msg.setBody("Body of the chat"); 85 msg.setProperty("favoriteColor", "red"); 86 msg.setProperty("age", 30); 87 msg.setProperty("distance", 30f); 88 msg.setProperty("weight", 30d); 89 msg.setProperty("male", true); 90 msg.setProperty("birthdate", new Date ()); 91 newChat.sendMessage(msg); 92 93 Message msg2 = newChat2.nextMessage(2000); 94 assertNotNull("No message was received", msg2); 95 assertEquals("Subjects are different", msg.getSubject(), msg2.getSubject()); 96 assertEquals("Bodies are different", msg.getBody(), msg2.getBody()); 97 assertEquals( 98 "favoriteColors are different", 99 msg.getProperty("favoriteColor"), 100 msg2.getProperty("favoriteColor")); 101 assertEquals( 102 "ages are different", 103 msg.getProperty("age"), 104 msg2.getProperty("age")); 105 assertEquals( 106 "distances are different", 107 msg.getProperty("distance"), 108 msg2.getProperty("distance")); 109 assertEquals( 110 "weights are different", 111 msg.getProperty("weight"), 112 msg2.getProperty("weight")); 113 assertEquals( 114 "males are different", 115 msg.getProperty("male"), 116 msg2.getProperty("male")); 117 assertEquals( 118 "birthdates are different", 119 msg.getProperty("birthdate"), 120 msg2.getProperty("birthdate")); 121 } 122 catch (XMPPException e) { 123 e.printStackTrace(); 124 fail(e.getMessage()); 125 } 126 } 127 128 protected int getMaxConnections() { 129 return 2; 130 } 131 } 132 | Popular Tags |