diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImplTest.java | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImplTest.java b/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImplTest.java index 8381e40..ef18049 100644 --- a/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImplTest.java +++ b/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImplTest.java @@ -25,7 +25,7 @@ public class ChatRoomIrcImplTest this.stackMock = EasyMock.createMock(IrcStack.class); EasyMock.expect(this.providerMock.getIrcStack()).andReturn(stackMock); EasyMock.expect(this.stackMock.getChannelTypes()).andReturn( - Collections.unmodifiableSet(Sets.newHashSet('#', '$'))); + Collections.unmodifiableSet(Sets.newHashSet('#', '&'))); } //@Test @@ -78,12 +78,17 @@ public class ChatRoomIrcImplTest } //@Test(expected = IllegalArgumentException.class) - public void testIllegalNameBadPrefix() + public void testTooLongName() { EasyMock.replay(this.providerMock, this.stackMock); try { - new ChatRoomIrcImpl("!test", this.providerMock); + new ChatRoomIrcImpl( + "thisjustalittlebittoolongtobeachannelnamethereforeiexpectthe" + + "testtofailsoweshallseifthisisthecasethisjustalittlebit" + + "toolongtobeachannelnamethereforeiexpectthetesttofails" + + "orweshallseeifthisisthecaseorweshallseeifthisisthecase", + this.providerMock); fail("Should have failed with IAE."); } catch (IllegalArgumentException e) @@ -91,6 +96,14 @@ public class ChatRoomIrcImplTest } } + //@Test + public void testAutoPrefixBadChannelName() + { + EasyMock.replay(this.providerMock, this.stackMock); + ChatRoomIrcImpl room = new ChatRoomIrcImpl("!test", this.providerMock); + Assert.assertEquals("#!test", room.getIdentifier()); + } + //@Test(expected = IllegalArgumentException.class) public void testIllegalNameSpace() { @@ -431,4 +444,36 @@ public class ChatRoomIrcImplTest { } } + + /** + * Test creating chat room with alternative prefix. Special check to ensure + * that we don't forget about less often used prefixes. + */ + // @Test + public void testChatRoomWithAlternativePrefix() + { + EasyMock.replay(this.providerMock, this.stackMock); + ChatRoomIrcImpl alternative = + new ChatRoomIrcImpl("&MyAlternative-channel-prefix", + this.providerMock); + Assert.assertEquals("&MyAlternative-channel-prefix", + alternative.getIdentifier()); + } + + public void testOnlyAlternativeChannelTypesWithDefault() + { + ProtocolProviderServiceIrcImpl specialProviderMock = + EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); + IrcStack specialStackMock = EasyMock.createMock(IrcStack.class); + EasyMock.expect(specialProviderMock.getIrcStack()).andReturn( + specialStackMock); + EasyMock.expect(specialStackMock.getChannelTypes()).andReturn( + Sets.newHashSet('&')); + EasyMock.replay(specialProviderMock, specialStackMock); + ChatRoomIrcImpl alternative = + new ChatRoomIrcImpl("channel-name-without-prefix", + specialProviderMock); + Assert.assertEquals("#channel-name-without-prefix", + alternative.getIdentifier()); + } } |