aboutsummaryrefslogtreecommitdiffstats
path: root/test/net
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2014-11-09 03:18:36 +0100
committerDanny van Heumen <danny@dannyvanheumen.nl>2014-11-09 20:57:43 +0100
commit35a0fe89b41f76bf09d5333e0decb11d36e63cd7 (patch)
treed3c3b090d518f7c01501205aa030c625a3bbe1c5 /test/net
parentf0976299333992f08375d24761eeb8a8caf0818d (diff)
downloadjitsi-35a0fe89b41f76bf09d5333e0decb11d36e63cd7.zip
jitsi-35a0fe89b41f76bf09d5333e0decb11d36e63cd7.tar.gz
jitsi-35a0fe89b41f76bf09d5333e0decb11d36e63cd7.tar.bz2
Fine-tuned /me command and added unit tests.
Diffstat (limited to 'test/net')
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/command/MeTest.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/command/MeTest.java b/test/net/java/sip/communicator/impl/protocol/irc/command/MeTest.java
new file mode 100644
index 0000000..4e97ffe
--- /dev/null
+++ b/test/net/java/sip/communicator/impl/protocol/irc/command/MeTest.java
@@ -0,0 +1,86 @@
+package net.java.sip.communicator.impl.protocol.irc.command;
+
+import junit.framework.*;
+import net.java.sip.communicator.impl.protocol.irc.*;
+
+import org.easymock.*;
+
+import com.ircclouds.irc.api.*;
+
+public class MeTest extends TestCase
+{
+
+ public void testConstruction()
+ {
+ new Me();
+ }
+
+ public void testGoodInit()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Me me = new Me();
+ me.init(null, connection);
+ }
+
+ public void testBadInit()
+ {
+ ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
+ EasyMock.replay(provider);
+
+ Me me = new Me();
+ try
+ {
+ me.init(provider, null);
+ Assert.fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testNoMessage()
+ {
+ ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(provider, connection);
+
+ Me me = new Me();
+ me.init(provider, connection);
+ me.execute("#test", "/me");
+ }
+
+ public void testZeroLengthMessage()
+ {
+ ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(provider, connection);
+
+ Me me = new Me();
+ me.init(provider, connection);
+ try
+ {
+ me.execute("#test", "/me ");
+ Assert.fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testSendMessage()
+ {
+ ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ IRCApi client = EasyMock.createMock(IRCApi.class);
+ EasyMock.expect(connection.getClient()).andReturn(client);
+ client.act(EasyMock.eq("#test"), EasyMock.eq("says hello world!"));
+ EasyMock.expectLastCall();
+ EasyMock.replay(provider, connection, client);
+
+ Me me = new Me();
+ me.init(provider, connection);
+ me.execute("#test", "/me says hello world!");
+ }
+}