diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-10-11 21:50:55 +0200 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-10-28 22:33:32 +0100 |
commit | 8ec14739c1bbba18c8c1544fa3db5c7d864673f3 (patch) | |
tree | 507270c2591e94b9e1d97bfe1944026d9b07deb5 | |
parent | db8ab9f8b275e12c66cdf067ed808dc719d806bf (diff) | |
download | jitsi-8ec14739c1bbba18c8c1544fa3db5c7d864673f3.zip jitsi-8ec14739c1bbba18c8c1544fa3db5c7d864673f3.tar.gz jitsi-8ec14739c1bbba18c8c1544fa3db5c7d864673f3.tar.bz2 |
Implemented 'ban' operation + fine tuning and TODO markers.
9 files changed, 178 insertions, 63 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java b/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java index 6ac97cc..a1b8d7f 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ChannelManager.java @@ -25,6 +25,8 @@ import com.ircclouds.irc.api.state.*; * * TODO Do we need to cancel any join channel operations still in progress? * + * TODO Check ISUPPORT 'CHANNELLEN' for maximum channel name length. + * * @author Danny van Heumen */ public class ChannelManager @@ -342,7 +344,8 @@ public class ChannelManager { ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(this.provider, chatRoom, - user.getNick(), ChatRoomMemberRole.SILENT_MEMBER); + user.getNick(), user.getIdent(), user.getHostname(), + ChatRoomMemberRole.SILENT_MEMBER); ChatRoomMemberRole role; for (IRCUserStatus status : channel.getStatusesForUser(user)) { @@ -368,6 +371,8 @@ public class ChannelManager /** * Set the subject of the specified chat room. * + * TODO check ISUPPORT for maximum topic length + * * @param chatroom The chat room for which to set the subject. * @param subject The subject. */ @@ -476,17 +481,24 @@ public class ChannelManager * trouble. */ public void banParticipant(final ChatRoomIrcImpl chatroom, - final ChatRoomMember member, final String reason) + final ChatRoomMemberIrcImpl member, final String reason) throws OperationFailedException { - // TODO Implement banParticipant. - throw new OperationFailedException("Not implemented yet.", - OperationFailedException.NOT_SUPPORTED_OPERATION); + if (!this.connectionState.isConnected()) + { + return; + } + kickParticipant(chatroom, member, reason); + this.irc.changeMode(String.format("%s +b %s!%s@%s", + chatroom.getIdentifier(), "*", + member.getIdent(), member.getHostname())); } /** * Kick channel member. * + * TODO Check ISUPPORT 'KICKLEN' for maximum kick message length. + * * @param chatroom channel to kick from * @param member member to kick * @param reason kick message to deliver @@ -723,9 +735,12 @@ public class ChannelManager return; } final String user = msg.getSource().getNick(); + final String ident = msg.getSource().getIdent(); + final String host = msg.getSource().getHostname(); final ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(ChannelManager.this.provider, - this.chatroom, user, ChatRoomMemberRole.SILENT_MEMBER); + this.chatroom, user, ident, host, + ChatRoomMemberRole.SILENT_MEMBER); this.chatroom.fireMemberPresenceEvent(member, null, ChatRoomMemberPresenceChangeEvent.MEMBER_JOINED, null); } @@ -946,7 +961,8 @@ public class ChannelManager MessageIrcImpl.newMessageFromIRC(msg.getText()); final ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(ChannelManager.this.provider, - this.chatroom, msg.getSource().getNick(), + this.chatroom, msg.getSource().getNick(), msg.getSource() + .getIdent(), msg.getSource().getHostname(), ChatRoomMemberRole.MEMBER); this.chatroom.fireMessageReceivedEvent(message, member, new Date(), ChatRoomMessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED); @@ -968,7 +984,8 @@ public class ChannelManager String userNick = msg.getSource().getNick(); ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(ChannelManager.this.provider, - this.chatroom, userNick, ChatRoomMemberRole.MEMBER); + this.chatroom, userNick, msg.getSource().getIdent(), msg + .getSource().getHostname(), ChatRoomMemberRole.MEMBER); MessageIrcImpl message = MessageIrcImpl.newActionFromIRC(member, msg.getText()); this.chatroom.fireMessageReceivedEvent(message, member, new Date(), @@ -991,7 +1008,8 @@ public class ChannelManager final String userNick = msg.getSource().getNick(); final ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(ChannelManager.this.provider, - this.chatroom, userNick, ChatRoomMemberRole.MEMBER); + this.chatroom, userNick, msg.getSource().getIdent(), msg + .getSource().getHostname(), ChatRoomMemberRole.MEMBER); final MessageIrcImpl message = MessageIrcImpl.newNoticeFromIRC(member, msg.getText()); this.chatroom.fireMessageReceivedEvent(message, member, new Date(), @@ -1217,7 +1235,8 @@ public class ChannelManager // an IRC server as a chat room member? member = new ChatRoomMemberIrcImpl(ChannelManager.this.provider, - this.chatroom, "", ChatRoomMemberRole.ADMINISTRATOR); + this.chatroom, "", "", "", + ChatRoomMemberRole.ADMINISTRATOR); } else if (source instanceof IRCUser) { diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java index dae0bf1..3bca2b7 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java @@ -437,10 +437,17 @@ public class ChatRoomIrcImpl public void banParticipant(final ChatRoomMember chatRoomMember, final String reason) throws OperationFailedException { + if (!(chatRoomMember instanceof ChatRoomMemberIrcImpl)) + { + LOGGER + .trace("Cannot ban chat room member that is not an instance of " + + ChatRoomMemberIrcImpl.class.getCanonicalName()); + return; + } final IrcConnection connection = this.parentProvider.getIrcStack().getConnection(); - connection.getChannelManager().banParticipant(this, chatRoomMember, - reason); + connection.getChannelManager().banParticipant(this, + (ChatRoomMemberIrcImpl) chatRoomMember, reason); } /** diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java index 678dfe1..19a9472 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImpl.java @@ -38,6 +38,16 @@ public class ChatRoomMemberIrcImpl private String contactID; /** + * The ident of the contact. + */ + private final String ident; + + /** + * The host name of the contact. + */ + private final String hostname; + + /** * The provider that created us. */ private final ProtocolProviderServiceIrcImpl parentProvider; @@ -58,13 +68,15 @@ public class ChatRoomMemberIrcImpl * chat room belongs * @param chatRoom the chat room, where this member is joined * @param contactID the nickname of the member + * @param ident ident of member + * @param hostname host name of member * @param chatRoomMemberRole the role that this member has in the * corresponding chat room */ public ChatRoomMemberIrcImpl( final ProtocolProviderServiceIrcImpl parentProvider, - final ChatRoom chatRoom, final String contactID, - final ChatRoomMemberRole chatRoomMemberRole) + final ChatRoom chatRoom, final String contactID, final String ident, + final String hostname, final ChatRoomMemberRole chatRoomMemberRole) { if (parentProvider == null) { @@ -83,6 +95,16 @@ public class ChatRoomMemberIrcImpl throw new IllegalArgumentException("contact ID cannot be null"); } this.contactID = contactID; + if (ident == null) + { + throw new IllegalArgumentException("ident cannot be null"); + } + this.ident = ident; + if (hostname == null) + { + throw new IllegalArgumentException("hostname cannot be null"); + } + this.hostname = hostname; if (chatRoomMemberRole == null) { throw new IllegalArgumentException("member role cannot be null"); @@ -125,6 +147,26 @@ public class ChatRoomMemberIrcImpl } /** + * Return the contact ident. + * + * @return returns ident + */ + public String getIdent() + { + return this.ident; + } + + /** + * Return the contact host name. + * + * @return returns host name + */ + public String getHostname() + { + return this.hostname; + } + + /** * Returns the name of this member as it is known in its containing * chat room (i.e. a nickname). The name returned by this method, may * sometimes match the string returned by getContactID() which is actually diff --git a/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java b/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java index 694b5ca..2423a5f 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java @@ -20,6 +20,9 @@ import com.ircclouds.irc.api.state.*; /** * IRC Connection. * + * TODO Find out how irc-api responds to losing a connection (no response). Does + * it use ping/pong messages to determine connectivity? + * * Common IRC network facilities: * 1. NickServ - nick related services * 2. ChanServ - channel related services @@ -30,19 +33,6 @@ import com.ircclouds.irc.api.state.*; public class IrcConnection { /** - * TODO In the far far future ... - * - * <p> - * Some of the less pressing features that may one day be useful ... - * </p> - * - * <pre> - * - Handle 404 ERR_CANNOTSENDTOCHAN in case of +n channel mode and not - * joined to the channel where you send a message to. - * </pre> - */ - - /** * Logger. */ private static final Logger LOGGER = Logger.getLogger(IrcConnection.class); diff --git a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java index 2f320e3..f3a2ec7 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java @@ -25,8 +25,6 @@ import com.ircclouds.irc.api.listeners.*; /** * An implementation of IRC using the irc-api library. * - * TODO Find out how irc-api responds to losing a connection (no response). Does it use ping/pong messages to determine connectivity? - * * @author Danny van Heumen */ public class IrcStack diff --git a/src/net/java/sip/communicator/impl/protocol/irc/MessageManager.java b/src/net/java/sip/communicator/impl/protocol/irc/MessageManager.java index 3f66c7d..2f3c025 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/MessageManager.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/MessageManager.java @@ -19,7 +19,8 @@ import com.ircclouds.irc.api.state.*; /** * Manager for message-related operations. * - * FIXME MessageManager may miss some quick events such as NickServ messages right after establishing a connection. + * FIXME MessageManager may miss some quick events such as NickServ messages + * right after establishing a connection. * * @author Danny van Heumen */ diff --git a/src/net/java/sip/communicator/impl/protocol/irc/OperationSetMultiUserChatIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/OperationSetMultiUserChatIrcImpl.java index e40451f..b98bc9b 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/OperationSetMultiUserChatIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/OperationSetMultiUserChatIrcImpl.java @@ -355,10 +355,9 @@ public class OperationSetMultiUserChatIrcImpl } else { - return new ChatRoomMemberIrcImpl( - ircProvider, - serverChatRoom, - ircProvider.getAccountID().getService(), + return new ChatRoomMemberIrcImpl(ircProvider, serverChatRoom, + ircProvider.getAccountID().getService(), "", ircProvider + .getAccountID().getServerAddress(), ChatRoomMemberRole.GUEST); } } diff --git a/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java b/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java index b9ce37c..6e5c694 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java @@ -151,6 +151,8 @@ public class PresenceManager * Set new prepared away message for later moment when IRC connection is set * to away. * + * TODO Check ISUPPORT 'AWAYLEN' for maximum away message length. + * * @param message the away message to prepare * @return returns message after verification */ 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 43da6d1..39af2d9 100644 --- a/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java +++ b/test/net/java/sip/communicator/impl/protocol/irc/ChatRoomMemberIrcImplTest.java @@ -19,8 +19,8 @@ public class ChatRoomMemberIrcImplTest ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); try { - new ChatRoomMemberIrcImpl(null, chatroom, "user", - ChatRoomMemberRole.SILENT_MEMBER); + new ChatRoomMemberIrcImpl(null, chatroom, "user", "user", + "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.fail("should throw IAE for parent provider instance"); } catch (IllegalArgumentException e) @@ -35,8 +35,8 @@ public class ChatRoomMemberIrcImplTest EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); try { - new ChatRoomMemberIrcImpl(provider, null, "user", - ChatRoomMemberRole.SILENT_MEMBER); + new ChatRoomMemberIrcImpl(provider, null, "user", "user", + "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.fail("should throw IAE for ChatRoom instance"); } catch (IllegalArgumentException e) @@ -52,7 +52,41 @@ public class ChatRoomMemberIrcImplTest EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); try { - new ChatRoomMemberIrcImpl(provider, chatroom, null, + new ChatRoomMemberIrcImpl(provider, chatroom, null, "user", + "host.name", ChatRoomMemberRole.SILENT_MEMBER); + Assert.fail("should throw IAE for ChatRoom instance"); + } + catch (IllegalArgumentException e) + { + // this is good + } + } + + public void testConstructorNullIdent() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderServiceIrcImpl provider = + EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); + try + { + new ChatRoomMemberIrcImpl(provider, chatroom, "user", null, + "host.name", ChatRoomMemberRole.SILENT_MEMBER); + Assert.fail("should throw IAE for ChatRoom instance"); + } + catch (IllegalArgumentException e) + { + // this is good + } + } + + public void testConstructorNullHostname() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderServiceIrcImpl provider = + EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); + try + { + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", null, ChatRoomMemberRole.SILENT_MEMBER); Assert.fail("should throw IAE for ChatRoom instance"); } @@ -69,7 +103,8 @@ public class ChatRoomMemberIrcImplTest EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); try { - new ChatRoomMemberIrcImpl(provider, chatroom, "user", null); + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", + "host.name", null); Assert.fail("should throw IAE for ChatRoom instance"); } catch (IllegalArgumentException e) @@ -84,7 +119,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); Assert.assertNotNull(new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER)); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER)); } public void testCheckGetters() @@ -93,7 +128,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertEquals(provider, member.getProtocolProvider()); Assert.assertEquals(chatroom, member.getChatRoom()); Assert.assertEquals("user", member.getContactAddress()); @@ -107,8 +142,8 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", - ChatRoomMemberRole.SILENT_MEMBER); + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", + "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertEquals("user", member.getContactAddress()); Assert.assertEquals("user", member.getName()); try @@ -128,7 +163,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertEquals("user", member.getContactAddress()); Assert.assertEquals("user", member.getName()); member.setName("myNewName"); @@ -142,7 +177,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); member.setRole(null); } @@ -153,7 +188,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); member.setRole(ChatRoomMemberRole.ADMINISTRATOR); Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); @@ -165,7 +200,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertSame(ChatRoomMemberRole.SILENT_MEMBER, member.getRole()); member.addRole(ChatRoomMemberRole.ADMINISTRATOR); @@ -178,7 +213,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); member.addRole(ChatRoomMemberRole.ADMINISTRATOR); Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); @@ -192,7 +227,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", "host.name", ChatRoomMemberRole.ADMINISTRATOR); Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); member.addRole(ChatRoomMemberRole.MEMBER); @@ -205,7 +240,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", "host.name", ChatRoomMemberRole.ADMINISTRATOR); member.addRole(ChatRoomMemberRole.MEMBER); Assert.assertSame(ChatRoomMemberRole.ADMINISTRATOR, member.getRole()); @@ -223,7 +258,7 @@ public class ChatRoomMemberIrcImplTest EasyMock.expect(provider.getPersistentPresence()).andReturn(pp); EasyMock.replay(provider); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertNull(member.getContact()); } @@ -234,7 +269,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "user", + new ChatRoomMemberIrcImpl(provider, chatroom, "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertNull(member.getAvatar()); } @@ -245,7 +280,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertTrue(member.equals(member)); } @@ -255,7 +290,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertFalse(member.equals(null)); } @@ -265,7 +300,7 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertFalse(member.equals(new Object())); } @@ -275,11 +310,11 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member1 = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); ProtocolProviderServiceIrcImpl provider2 = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member2 = new ChatRoomMemberIrcImpl(provider2, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertFalse(member1.equals(member2)); } @@ -289,9 +324,9 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member1 = new ChatRoomMemberIrcImpl(provider, chatroom, - "user", ChatRoomMemberRole.SILENT_MEMBER); + "user", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); ChatRoomMemberIrcImpl member2 = new ChatRoomMemberIrcImpl(provider, chatroom, - "susy", ChatRoomMemberRole.SILENT_MEMBER); + "susy", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertFalse(member1.equals(member2)); } @@ -301,9 +336,9 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member1 = new ChatRoomMemberIrcImpl(provider, chatroom, - "susy", ChatRoomMemberRole.SILENT_MEMBER); + "susy", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); ChatRoomMemberIrcImpl member2 = new ChatRoomMemberIrcImpl(provider, chatroom, - "susy", ChatRoomMemberRole.SILENT_MEMBER); + "susy", "user", "host.name", ChatRoomMemberRole.SILENT_MEMBER); Assert.assertTrue(member1.equals(member2)); } @@ -313,8 +348,30 @@ public class ChatRoomMemberIrcImplTest ProtocolProviderServiceIrcImpl provider = EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); ChatRoomMemberIrcImpl member = - new ChatRoomMemberIrcImpl(provider, chatroom, "ET", + new ChatRoomMemberIrcImpl(provider, chatroom, "ET", "user", "host.name", ChatRoomMemberRole.ADMINISTRATOR); member.hashCode(); } + + public void testGetIdent() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderServiceIrcImpl provider = + EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); + ChatRoomMemberIrcImpl member = + new ChatRoomMemberIrcImpl(provider, chatroom, "ET", "user", "host.name", + ChatRoomMemberRole.ADMINISTRATOR); + Assert.assertEquals("user", member.getIdent()); + } + + public void testGetHostname() + { + ChatRoom chatroom = EasyMock.createMock(ChatRoom.class); + ProtocolProviderServiceIrcImpl provider = + EasyMock.createMock(ProtocolProviderServiceIrcImpl.class); + ChatRoomMemberIrcImpl member = + new ChatRoomMemberIrcImpl(provider, chatroom, "ET", "user", "host.name", + ChatRoomMemberRole.ADMINISTRATOR); + Assert.assertEquals("host.name", member.getHostname()); + } } |