use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.
the class AbstractChatTest method testSendMessageProperties.
public void testSendMessageProperties() throws Exception {
final Map sendprops = new HashMap();
sendprops.put("prop2", "that");
// Send the whole thing
chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), null, IChatMessage.Type.CHAT, null, null, sendprops);
sleep(SLEEPTIME);
assertHasEvent(receivedChatMessages, IChatMessage.class);
final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
assertNull(message.getSubject());
assertTrue(message.getBody().equals(""));
assertTrue(message.getType().equals(IChatMessage.Type.CHAT));
final Map props = message.getProperties();
assertNotNull(props);
assertTrue(props.size() == 1);
final String val = (String) props.get("prop2");
assertNotNull(val);
assertEquals(val, "that");
}
use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.
the class AbstractChatTest method testSendIM2.
public void testSendIM2() throws Exception {
final Map sendprops = new HashMap();
sendprops.put("prop1", "this");
final ID sendthreadid = IDFactory.getDefault().createStringID("thread1");
// Send the whole thing
chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), sendthreadid, IChatMessage.Type.CHAT, "subject1", "uvwxyz", sendprops);
sleep(SLEEPTIME);
assertHasEvent(receivedChatMessages, IChatMessage.class);
final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
// For some reason, the smack library doesn't seem to get this right.
// assertTrue(message.getThreadID().equals(sendthreadid));
assertTrue(message.getSubject().equals("subject1"));
assertTrue(message.getBody().equals("uvwxyz"));
assertTrue(message.getType().equals(IChatMessage.Type.CHAT));
final Map props = message.getProperties();
assertNotNull(props);
assertTrue(props.size() == 1);
final String val = (String) props.get("prop1");
assertNotNull(val);
assertEquals(val, "this");
}
use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.
the class IMBot method handleMessageEvent.
public void handleMessageEvent(IIMMessageEvent event) {
if (event instanceof IChatMessageEvent) {
IChatMessageEvent imEvent = (IChatMessageEvent) event;
IChatMessage message = imEvent.getChatMessage();
List commands = bot.getCommands();
for (int i = 0; i < commands.size(); i++) {
IIMMessageHandlerEntry entry = (IIMMessageHandlerEntry) commands.get(i);
entry.handleIMMessage(message);
}
}
}
Aggregations