diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-07-24 23:27:40 +0200 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-07-30 18:30:05 +0200 |
commit | 99fc21c915f17592eb82eefc164feb98376789c9 (patch) | |
tree | 6b52a18a6d721ff4c960e0018c2d04e0016a5190 /test | |
parent | 893e84b65d38b806633324f878e3f96bb774da39 (diff) | |
download | jitsi-99fc21c915f17592eb82eefc164feb98376789c9.zip jitsi-99fc21c915f17592eb82eefc164feb98376789c9.tar.gz jitsi-99fc21c915f17592eb82eefc164feb98376789c9.tar.bz2 |
More code clean-up and added tests for new role management approach.
Diffstat (limited to 'test')
4 files changed, 82 insertions, 18 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java b/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java index d853fe0..2761f9d 100644 --- a/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java +++ b/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java @@ -1,9 +1,14 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. See terms of license at gnu.org. + */ package net.java.sip.communicator.impl.protocol.irc; -import org.easymock.*; - -import net.java.sip.communicator.service.protocol.*; import junit.framework.*; +import net.java.sip.communicator.service.protocol.*; + +import org.easymock.*; public class ChatRoomMemberIrcImplTest extends TestCase @@ -139,19 +144,10 @@ public class ChatRoomMemberIrcImplTest ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom, "user", ChatRoomMemberRole.SILENT_MEMBER); - Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); - try - { - member.setRole(null); - Assert.fail("expected IAE because of null role"); - } - catch (IllegalArgumentException e) - { - // this is good - } + member.setRole(null); } - public void testRoleChange() + public void testRoleUnchange() { ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); ProtocolProviderService provider = @@ -160,9 +156,63 @@ public class ChatRoomMemberIrcImplTest "user", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); member.setRole(ChatRoomMemberRole.ADMINISTRATOR); - Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); + Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); } + public void testAddSignificantRole() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderService provider = + EasyMock.createMock(ProtocolProviderService.class); + ChatRoomMemberIrcImpl member = + new ChatRoomMemberIrcImpl(provider, chatroom, "user", + ChatRoomMemberRole.SILENT_MEMBER); + Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); + member.addRole(ChatRoomMemberRole.ADMINISTRATOR); + Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); + } + + public void testRemoveSignificantRole() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderService provider = + EasyMock.createMock(ProtocolProviderService.class); + ChatRoomMemberIrcImpl member = + new ChatRoomMemberIrcImpl(provider, chatroom, "user", + ChatRoomMemberRole.SILENT_MEMBER); + member.addRole(ChatRoomMemberRole.ADMINISTRATOR); + Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); + member.removeRole(ChatRoomMemberRole.ADMINISTRATOR); + Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); + } + + public void testAddInsignificantRole() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderService provider = + EasyMock.createMock(ProtocolProviderService.class); + ChatRoomMemberIrcImpl member = + new ChatRoomMemberIrcImpl(provider, chatroom, "user", + ChatRoomMemberRole.ADMINISTRATOR); + Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); + member.addRole(ChatRoomMemberRole.MEMBER); + Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); + } + + public void testRemoveInsignificantRole() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderService provider = + EasyMock.createMock(ProtocolProviderService.class); + ChatRoomMemberIrcImpl member = + new ChatRoomMemberIrcImpl(provider, chatroom, "user", + ChatRoomMemberRole.ADMINISTRATOR); + member.addRole(ChatRoomMemberRole.MEMBER); + Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); + member.removeRole(ChatRoomMemberRole.MEMBER); + Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); + } + public void testGetContact() { ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); diff --git a/test/net/java/sip/communicator/impl/protocol/irc/FormattedTextBuilderTest.java b/test/net/java/sip/communicator/impl/protocol/irc/FormattedTextBuilderTest.java index a3d3173..d2f6b92 100644 --- a/test/net/java/sip/communicator/impl/protocol/irc/FormattedTextBuilderTest.java +++ b/test/net/java/sip/communicator/impl/protocol/irc/FormattedTextBuilderTest.java @@ -1,3 +1,8 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. See terms of license at gnu.org. + */ package net.java.sip.communicator.impl.protocol.irc; import junit.framework.*; diff --git a/test/net/java/sip/communicator/impl/protocol/irc/ModeParserTest.java b/test/net/java/sip/communicator/impl/protocol/irc/ModeParserTest.java index eddf066..e584fb3 100644 --- a/test/net/java/sip/communicator/impl/protocol/irc/ModeParserTest.java +++ b/test/net/java/sip/communicator/impl/protocol/irc/ModeParserTest.java @@ -1,10 +1,14 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. See terms of license at gnu.org. + */ package net.java.sip.communicator.impl.protocol.irc; import java.util.*; -import net.java.sip.communicator.impl.protocol.irc.ModeParser.ModeEntry; - import junit.framework.*; +import net.java.sip.communicator.impl.protocol.irc.ModeParser.ModeEntry; public class ModeParserTest extends TestCase diff --git a/test/net/java/sip/communicator/impl/protocol/irc/ModeTest.java b/test/net/java/sip/communicator/impl/protocol/irc/ModeTest.java index 47c23ec..843bbe4 100644 --- a/test/net/java/sip/communicator/impl/protocol/irc/ModeTest.java +++ b/test/net/java/sip/communicator/impl/protocol/irc/ModeTest.java @@ -1,7 +1,12 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. See terms of license at gnu.org. + */ package net.java.sip.communicator.impl.protocol.irc; -import net.java.sip.communicator.service.protocol.*; import junit.framework.*; +import net.java.sip.communicator.service.protocol.*; public class ModeTest extends TestCase |