aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/command/JoinTest.java98
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/command/ModeTest.java94
2 files changed, 192 insertions, 0 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/command/JoinTest.java b/test/net/java/sip/communicator/impl/protocol/irc/command/JoinTest.java
new file mode 100644
index 0000000..3819f33
--- /dev/null
+++ b/test/net/java/sip/communicator/impl/protocol/irc/command/JoinTest.java
@@ -0,0 +1,98 @@
+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 JoinTest
+ extends TestCase
+{
+
+ public void testConstruction()
+ {
+ new Join();
+ }
+
+ public void testGoodInit()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Join join = new Join();
+ join.init(null, connection);
+ }
+
+ public void testBadInit()
+ {
+ ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
+ EasyMock.replay(provider);
+
+ Join join = new Join();
+ try
+ {
+ join.init(provider, null);
+ Assert.fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testEmptyJoin()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Join join = new Join();
+ join.init(null, connection);
+ join.execute("#test", "/join");
+ }
+
+ public void testJoinEmptyChannelNoPassword()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Join join = new Join();
+ join.init(null, connection);
+ try
+ {
+ join.execute("#test", "/join ");
+ Assert.fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testJoinWithChannelNoPassword()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ IRCApi client = EasyMock.createMock(IRCApi.class);
+ EasyMock.expect(connection.getClient()).andReturn(client);
+ client.joinChannel(EasyMock.eq("#test"), EasyMock.eq(""));
+ EasyMock.expectLastCall();
+ EasyMock.replay(connection, client);
+
+ Join join = new Join();
+ join.init(null, connection);
+ join.execute("#test", "/join #test");
+ }
+
+ public void testJoinWithChannelWithPassword()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ IRCApi client = EasyMock.createMock(IRCApi.class);
+ EasyMock.expect(connection.getClient()).andReturn(client);
+ client.joinChannel(EasyMock.eq("#test"), EasyMock.eq("top-secret"));
+ EasyMock.expectLastCall();
+ EasyMock.replay(connection, client);
+
+ Join join = new Join();
+ join.init(null, connection);
+ join.execute("#test", "/join #test top-secret");
+ }
+}
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/command/ModeTest.java b/test/net/java/sip/communicator/impl/protocol/irc/command/ModeTest.java
new file mode 100644
index 0000000..9c582e3
--- /dev/null
+++ b/test/net/java/sip/communicator/impl/protocol/irc/command/ModeTest.java
@@ -0,0 +1,94 @@
+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 ModeTest
+ extends TestCase
+{
+
+ public void testConstruction()
+ {
+ new Mode();
+ }
+
+ public void testGoodInit()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Mode mode = new Mode();
+ mode.init(null, connection);
+ }
+
+ public void testBadInit()
+ {
+ ProtocolProviderServiceIrcImpl provider =
+ EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
+ EasyMock.replay(provider);
+
+ Mode mode = new Mode();
+ try
+ {
+ mode.init(provider, null);
+ Assert.fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testEmptyCommand()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Mode mode = new Mode();
+ mode.init(null, connection);
+ mode.execute("#test", "/mode");
+ }
+
+ public void testEmptyModeLine()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Mode mode = new Mode();
+ mode.init(null, connection);
+ mode.execute("#test", "/mode ");
+ }
+
+ public void testSpacesModeLine()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ EasyMock.replay(connection);
+
+ Mode mode = new Mode();
+ mode.init(null, connection);
+ try
+ {
+ mode.execute("#test", "/mode ");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testCorrectModeCommand()
+ {
+ IrcConnection connection = EasyMock.createMock(IrcConnection.class);
+ IRCApi client = EasyMock.createMock(IRCApi.class);
+ EasyMock.expect(connection.getClient()).andReturn(client);
+ client.changeMode(EasyMock.eq("#test +o ThaDud3"));
+ EasyMock.expectLastCall();
+ EasyMock.replay(connection, client);
+
+ Mode mode = new Mode();
+ mode.init(null, connection);
+ mode.execute("#test", "/mode +o ThaDud3");
+ }
+}