aboutsummaryrefslogtreecommitdiffstats
path: root/test/net/java/sip/communicator/impl/protocol/irc/MessageIrcImplTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/net/java/sip/communicator/impl/protocol/irc/MessageIrcImplTest.java')
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/MessageIrcImplTest.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/MessageIrcImplTest.java b/test/net/java/sip/communicator/impl/protocol/irc/MessageIrcImplTest.java
index 44e9987..02eabd2 100644
--- a/test/net/java/sip/communicator/impl/protocol/irc/MessageIrcImplTest.java
+++ b/test/net/java/sip/communicator/impl/protocol/irc/MessageIrcImplTest.java
@@ -2,6 +2,8 @@ package net.java.sip.communicator.impl.protocol.irc;
import junit.framework.*;
+import org.easymock.*;
+
public class MessageIrcImplTest
extends TestCase
{
@@ -46,4 +48,86 @@ public class MessageIrcImplTest
Assert.assertFalse(message.isAction());
Assert.assertTrue(message.isCommand());
}
+
+ public void testNewMessageFromIRC()
+ {
+ MessageIrcImpl message =
+ MessageIrcImpl.newMessageFromIRC("Hello world.");
+ Assert.assertEquals("Hello world.", message.getContent());
+ Assert.assertEquals(MessageIrcImpl.HTML_MIME_TYPE,
+ message.getContentType());
+ Assert.assertEquals(MessageIrcImpl.DEFAULT_MIME_ENCODING,
+ message.getEncoding());
+ Assert.assertNull(message.getSubject());
+ }
+
+ public void testNewActionFromIRC()
+ {
+ final String text = "Hello world.";
+
+ // Test with chat room member.
+ ChatRoomMemberIrcImpl chatRoomMember =
+ EasyMock.createMock(ChatRoomMemberIrcImpl.class);
+ EasyMock.expect(chatRoomMember.getContactAddress())
+ .andReturn("IamUser");
+ EasyMock.replay(chatRoomMember);
+ MessageIrcImpl message =
+ MessageIrcImpl.newActionFromIRC(chatRoomMember, text);
+ Assert.assertEquals(Utils.styleAsAction(text, "IamUser"),
+ message.getContent());
+ Assert.assertEquals(MessageIrcImpl.HTML_MIME_TYPE,
+ message.getContentType());
+ Assert.assertEquals(MessageIrcImpl.DEFAULT_MIME_ENCODING,
+ message.getEncoding());
+ Assert.assertNull(message.getSubject());
+
+ // Test with contact.
+ ContactIrcImpl contact = EasyMock.createMock(ContactIrcImpl.class);
+ EasyMock.expect(contact.getAddress()).andReturn("IamUser");
+ EasyMock.replay(contact);
+ message = MessageIrcImpl.newActionFromIRC(contact, text);
+ Assert.assertEquals(Utils.styleAsAction(text, "IamUser"),
+ message.getContent());
+ Assert.assertEquals(MessageIrcImpl.HTML_MIME_TYPE,
+ message.getContentType());
+ Assert.assertEquals(MessageIrcImpl.DEFAULT_MIME_ENCODING,
+ message.getEncoding());
+ Assert.assertNull(message.getSubject());
+
+ }
+
+ public void testNewNoticeFromIRC()
+ {
+ final String text = "Hello world.";
+
+ // Test with chat room member.
+ ChatRoomMemberIrcImpl chatRoomMember =
+ EasyMock.createMock(ChatRoomMemberIrcImpl.class);
+ EasyMock.expect(chatRoomMember.getContactAddress())
+ .andReturn("IamUser");
+ EasyMock.replay(chatRoomMember);
+ MessageIrcImpl message =
+ MessageIrcImpl.newNoticeFromIRC(chatRoomMember, text);
+ Assert.assertEquals(Utils.styleAsNotice(text, "IamUser"),
+ message.getContent());
+ Assert.assertEquals(MessageIrcImpl.HTML_MIME_TYPE,
+ message.getContentType());
+ Assert.assertEquals(MessageIrcImpl.DEFAULT_MIME_ENCODING,
+ message.getEncoding());
+ Assert.assertNull(message.getSubject());
+
+ // Test with contact.
+ ContactIrcImpl contact = EasyMock.createMock(ContactIrcImpl.class);
+ EasyMock.expect(contact.getAddress()).andReturn("IamUser");
+ EasyMock.replay(contact);
+ message = MessageIrcImpl.newNoticeFromIRC(contact, text);
+ Assert.assertEquals(Utils.styleAsNotice(text, "IamUser"),
+ message.getContent());
+ Assert.assertEquals(MessageIrcImpl.HTML_MIME_TYPE,
+ message.getContentType());
+ Assert.assertEquals(MessageIrcImpl.DEFAULT_MIME_ENCODING,
+ message.getEncoding());
+ Assert.assertNull(message.getSubject());
+
+ }
}