diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-11-09 20:53:39 +0100 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-11-09 20:57:43 +0100 |
commit | da53b1f81012fa99d5090c2c587fef370d3c0de7 (patch) | |
tree | 17998d9bebb724e7c06e24b0298e4096770c78db /test | |
parent | 35a0fe89b41f76bf09d5333e0decb11d36e63cd7 (diff) | |
download | jitsi-da53b1f81012fa99d5090c2c587fef370d3c0de7.zip jitsi-da53b1f81012fa99d5090c2c587fef370d3c0de7.tar.gz jitsi-da53b1f81012fa99d5090c2c587fef370d3c0de7.tar.bz2 |
Fine-tuned commands Mode, Join + added unit tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/net/java/sip/communicator/impl/protocol/irc/command/JoinTest.java | 98 | ||||
-rw-r--r-- | test/net/java/sip/communicator/impl/protocol/irc/command/ModeTest.java | 94 |
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"); + } +} |