Kaynağa Gözat

Merge pull request #79 from csmith/master

Add defensive checks to all events.
pull/80/head
Greg Holmes 9 yıl önce
ebeveyn
işleme
3c48d6558b
67 değiştirilmiş dosya ile 286 ekleme ve 1078 silme
  1. 0
    13
      common/src/com/dmdirc/parser/common/CallbackManager.java
  2. 3
    1
      common/src/com/dmdirc/parser/events/AuthNoticeEvent.java
  3. 8
    3
      common/src/com/dmdirc/parser/events/AwayStateEvent.java
  4. 6
    4
      common/src/com/dmdirc/parser/events/ChannelActionEvent.java
  5. 7
    5
      common/src/com/dmdirc/parser/events/ChannelCTCPEvent.java
  6. 7
    5
      common/src/com/dmdirc/parser/events/ChannelCTCPReplyEvent.java
  7. 4
    2
      common/src/com/dmdirc/parser/events/ChannelJoinEvent.java
  8. 12
    10
      common/src/com/dmdirc/parser/events/ChannelKickEvent.java
  9. 3
    1
      common/src/com/dmdirc/parser/events/ChannelListModeEvent.java
  10. 6
    4
      common/src/com/dmdirc/parser/events/ChannelMessageEvent.java
  11. 6
    4
      common/src/com/dmdirc/parser/events/ChannelModeChangeEvent.java
  12. 7
    5
      common/src/com/dmdirc/parser/events/ChannelModeMessageEvent.java
  13. 7
    5
      common/src/com/dmdirc/parser/events/ChannelModeNoticeEvent.java
  14. 3
    1
      common/src/com/dmdirc/parser/events/ChannelNamesEvent.java
  15. 5
    3
      common/src/com/dmdirc/parser/events/ChannelNickChangeEvent.java
  16. 6
    4
      common/src/com/dmdirc/parser/events/ChannelNonUserModeChangeEvent.java
  17. 6
    4
      common/src/com/dmdirc/parser/events/ChannelNoticeEvent.java
  18. 6
    4
      common/src/com/dmdirc/parser/events/ChannelOtherAwayStateEvent.java
  19. 5
    3
      common/src/com/dmdirc/parser/events/ChannelPartEvent.java
  20. 5
    3
      common/src/com/dmdirc/parser/events/ChannelQuitEvent.java
  21. 3
    1
      common/src/com/dmdirc/parser/events/ChannelSelfJoinEvent.java
  22. 6
    4
      common/src/com/dmdirc/parser/events/ChannelSingleModeChangeEvent.java
  23. 3
    1
      common/src/com/dmdirc/parser/events/ChannelTopicEvent.java
  24. 7
    5
      common/src/com/dmdirc/parser/events/ChannelUserModeChangeEvent.java
  25. 4
    2
      common/src/com/dmdirc/parser/events/CompositionStateChangeEvent.java
  26. 3
    1
      common/src/com/dmdirc/parser/events/ConnectErrorEvent.java
  27. 3
    1
      common/src/com/dmdirc/parser/events/DataInEvent.java
  28. 3
    1
      common/src/com/dmdirc/parser/events/DataOutEvent.java
  29. 3
    1
      common/src/com/dmdirc/parser/events/DebugInfoEvent.java
  30. 3
    1
      common/src/com/dmdirc/parser/events/ErrorInfoEvent.java
  31. 5
    3
      common/src/com/dmdirc/parser/events/GroupListEntryEvent.java
  32. 4
    2
      common/src/com/dmdirc/parser/events/InviteEvent.java
  33. 3
    1
      common/src/com/dmdirc/parser/events/MOTDEndEvent.java
  34. 3
    1
      common/src/com/dmdirc/parser/events/MOTDLineEvent.java
  35. 3
    1
      common/src/com/dmdirc/parser/events/MOTDStartEvent.java
  36. 5
    3
      common/src/com/dmdirc/parser/events/NetworkDetectedEvent.java
  37. 4
    2
      common/src/com/dmdirc/parser/events/NickChangeEvent.java
  38. 3
    1
      common/src/com/dmdirc/parser/events/NickInUseEvent.java
  39. 4
    2
      common/src/com/dmdirc/parser/events/NumericEvent.java
  40. 5
    3
      common/src/com/dmdirc/parser/events/OtherAwayStateEvent.java
  41. 3
    1
      common/src/com/dmdirc/parser/events/ParserErrorEvent.java
  42. 8
    15
      common/src/com/dmdirc/parser/events/ParserEvent.java
  43. 4
    2
      common/src/com/dmdirc/parser/events/PrivateActionEvent.java
  44. 5
    3
      common/src/com/dmdirc/parser/events/PrivateCTCPEvent.java
  45. 5
    3
      common/src/com/dmdirc/parser/events/PrivateCTCPReplyEvent.java
  46. 4
    2
      common/src/com/dmdirc/parser/events/PrivateMessageEvent.java
  47. 4
    2
      common/src/com/dmdirc/parser/events/PrivateNoticeEvent.java
  48. 4
    2
      common/src/com/dmdirc/parser/events/QuitEvent.java
  49. 3
    1
      common/src/com/dmdirc/parser/events/ServerErrorEvent.java
  50. 4
    2
      common/src/com/dmdirc/parser/events/ServerNoticeEvent.java
  51. 5
    3
      common/src/com/dmdirc/parser/events/UnknownActionEvent.java
  52. 6
    4
      common/src/com/dmdirc/parser/events/UnknownCTCPEvent.java
  53. 6
    4
      common/src/com/dmdirc/parser/events/UnknownCTCPReplyEvent.java
  54. 5
    3
      common/src/com/dmdirc/parser/events/UnknownMessageEvent.java
  55. 5
    3
      common/src/com/dmdirc/parser/events/UnknownNoticeEvent.java
  56. 5
    3
      common/src/com/dmdirc/parser/events/UnknownServerNoticeEvent.java
  57. 5
    3
      common/src/com/dmdirc/parser/events/UserModeChangeEvent.java
  58. 4
    2
      common/src/com/dmdirc/parser/events/UserModeDiscoveryEvent.java
  59. 4
    2
      common/src/com/dmdirc/parser/events/WallDesyncEvent.java
  60. 4
    2
      common/src/com/dmdirc/parser/events/WallopEvent.java
  61. 4
    2
      common/src/com/dmdirc/parser/events/WalluserEvent.java
  62. 0
    127
      irc/test/com/dmdirc/harness/parser/TestParser.java
  63. 0
    105
      irc/test/com/dmdirc/parser/irc/ChannelClientInfoTest.java
  64. 0
    347
      irc/test/com/dmdirc/parser/irc/ChannelInfoTest.java
  65. 0
    76
      irc/test/com/dmdirc/parser/irc/IRCParserIrcdTest.java
  66. 0
    93
      irc/test/com/dmdirc/parser/irc/processors/ProcessListModeTest.java
  67. 0
    145
      irc/test/com/dmdirc/parser/irc/processors/ProcessModeTest.java

+ 0
- 13
common/src/com/dmdirc/parser/common/CallbackManager.java Dosyayı Görüntüle

@@ -57,19 +57,6 @@ public class CallbackManager extends MBassador<ParserEvent> {
57 57
         this.parser = parser;
58 58
     }
59 59
 
60
-    @Override
61
-    public void publish(final ParserEvent message) {
62
-        // TODO: HACKY REMOVE
63
-        if (message.getParser() == null) {
64
-            message.setParser(parser);
65
-        }
66
-        if (message.getDate() == null) {
67
-            message.setDate(new Date());
68
-        }
69
-        // TODO: HACKY REMOVE
70
-        super.publish(message);
71
-    }
72
-
73 60
     @SuppressWarnings({
74 61
             "ThrowableResultOfMethodCallIgnored",
75 62
             "CallToPrintStackTrace",

+ 3
- 1
common/src/com/dmdirc/parser/events/AuthNoticeEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Used on every incomming line before 001.
31 33
  */
@@ -35,7 +37,7 @@ public class AuthNoticeEvent extends ParserEvent {
35 37
 
36 38
     public AuthNoticeEvent(final Parser parser, final Date date, final String message) {
37 39
         super(parser, date);
38
-        this.message = message;
40
+        this.message = checkNotNull(message);
39 41
     }
40 42
 
41 43
     public String getMessage() {

+ 8
- 3
common/src/com/dmdirc/parser/events/AwayStateEvent.java Dosyayı Görüntüle

@@ -27,6 +27,10 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import javax.annotation.Nullable;
31
+
32
+import static com.google.common.base.Preconditions.checkNotNull;
33
+
30 34
 /**
31 35
  * Called when we go away, or come back.
32 36
  */
@@ -37,10 +41,10 @@ public class AwayStateEvent extends ParserEvent {
37 41
     private final String reason;
38 42
 
39 43
     public AwayStateEvent(final Parser parser, final Date date, final AwayState oldState,
40
-            final AwayState newState, final String reason) {
44
+            final AwayState newState, @Nullable final String reason) {
41 45
         super(parser, date);
42
-        this.oldState = oldState;
43
-        this.newState = newState;
46
+        this.oldState = checkNotNull(oldState);
47
+        this.newState = checkNotNull(newState);
44 48
         this.reason = reason;
45 49
     }
46 50
 
@@ -52,6 +56,7 @@ public class AwayStateEvent extends ParserEvent {
52 56
         return newState;
53 57
     }
54 58
 
59
+    @Nullable
55 60
     public String getReason() {
56 61
         return reason;
57 62
     }

+ 6
- 4
common/src/com/dmdirc/parser/events/ChannelActionEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person does an action in a channel.
33 35
  */
@@ -41,10 +43,10 @@ public class ChannelActionEvent extends ParserEvent {
41 43
     public ChannelActionEvent(final Parser parser, final Date date, final ChannelInfo channel,
42 44
             final ChannelClientInfo client, final String message, final String host) {
43 45
         super(parser, date);
44
-        this.channel = channel;
45
-        this.client = client;
46
-        this.message = message;
47
-        this.host = host;
46
+        this.channel = checkNotNull(channel);
47
+        this.client = checkNotNull(client);
48
+        this.message = checkNotNull(message);
49
+        this.host = checkNotNull(host);
48 50
     }
49 51
 
50 52
     public ChannelInfo getChannel() {

+ 7
- 5
common/src/com/dmdirc/parser/events/ChannelCTCPEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person sends a CTCP to a channel.
33 35
  */
@@ -43,11 +45,11 @@ public class ChannelCTCPEvent extends ParserEvent {
43 45
             final ChannelClientInfo client, final String type, final String message,
44 46
             final String host) {
45 47
         super(parser, date);
46
-        this.channel = channel;
47
-        this.client = client;
48
-        this.type = type;
49
-        this.message = message;
50
-        this.host = host;
48
+        this.channel = checkNotNull(channel);
49
+        this.client = checkNotNull(client);
50
+        this.type = checkNotNull(type);
51
+        this.message = checkNotNull(message);
52
+        this.host = checkNotNull(host);
51 53
     }
52 54
 
53 55
     public ChannelInfo getChannel() {

+ 7
- 5
common/src/com/dmdirc/parser/events/ChannelCTCPReplyEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person sends a CTCPRReply to a channel.
33 35
  */
@@ -43,11 +45,11 @@ public class ChannelCTCPReplyEvent extends ParserEvent {
43 45
             final ChannelClientInfo client, final String type, final String message,
44 46
             final String host) {
45 47
         super(parser, date);
46
-        this.channel = channel;
47
-        this.client = client;
48
-        this.type = type;
49
-        this.message = message;
50
-        this.host = host;
48
+        this.channel = checkNotNull(channel);
49
+        this.client = checkNotNull(client);
50
+        this.type = checkNotNull(type);
51
+        this.message = checkNotNull(message);
52
+        this.host = checkNotNull(host);
51 53
     }
52 54
 
53 55
     public ChannelInfo getChannel() {

+ 4
- 2
common/src/com/dmdirc/parser/events/ChannelJoinEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called When we, or another client joins a channel.
33 35
  */
@@ -39,8 +41,8 @@ public class ChannelJoinEvent extends ParserEvent {
39 41
     public ChannelJoinEvent(final Parser parser, final Date date, final ChannelInfo channel,
40 42
             final ChannelClientInfo client) {
41 43
         super(parser, date);
42
-        this.channel = channel;
43
-        this.client = client;
44
+        this.channel = checkNotNull(channel);
45
+        this.client = checkNotNull(client);
44 46
     }
45 47
 
46 48
     public ChannelInfo getChannel() {

+ 12
- 10
common/src/com/dmdirc/parser/events/ChannelKickEvent.java Dosyayı Görüntüle

@@ -28,26 +28,28 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person is kicked.
33 35
  */
34 36
 public class ChannelKickEvent extends ParserEvent {
35 37
 
36
-    final ChannelInfo channel;
37
-    final ChannelClientInfo kickedClient;
38
-    final ChannelClientInfo client;
39
-    final String reason;
40
-    final String host;
38
+    private final ChannelInfo channel;
39
+    private final ChannelClientInfo kickedClient;
40
+    private final ChannelClientInfo client;
41
+    private final String reason;
42
+    private final String host;
41 43
 
42 44
     public ChannelKickEvent(final Parser parser, final Date date, final ChannelInfo channel,
43 45
             final ChannelClientInfo kickedClient, final ChannelClientInfo client,
44 46
             final String reason, final String host) {
45 47
         super(parser, date);
46
-        this.channel = channel;
47
-        this.kickedClient = kickedClient;
48
-        this.client = client;
49
-        this.reason = reason;
50
-        this.host = host;
48
+        this.channel = checkNotNull(channel);
49
+        this.kickedClient = checkNotNull(kickedClient);
50
+        this.client = checkNotNull(client);
51
+        this.reason = checkNotNull(reason);
52
+        this.host = checkNotNull(host);
51 53
     }
52 54
 
53 55
     public ChannelInfo getChannel() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ChannelListModeEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when all requested ListModes have been sent.
32 34
  */
@@ -38,7 +40,7 @@ public class ChannelListModeEvent extends ParserEvent {
38 40
     public ChannelListModeEvent(final Parser parser, final Date date, final ChannelInfo channel,
39 41
             final char mode) {
40 42
         super(parser, date);
41
-        this.channel = channel;
43
+        this.channel = checkNotNull(channel);
42 44
         this.mode = mode;
43 45
     }
44 46
 

+ 6
- 4
common/src/com/dmdirc/parser/events/ChannelMessageEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person sends a message to a channel.
33 35
  */
@@ -41,10 +43,10 @@ public class ChannelMessageEvent extends ParserEvent {
41 43
     public ChannelMessageEvent(final Parser parser, final Date date, final ChannelInfo channel,
42 44
             final ChannelClientInfo client, final String message, final String host) {
43 45
         super(parser, date);
44
-        this.channel = channel;
45
-        this.client = client;
46
-        this.message = message;
47
-        this.host = host;
46
+        this.channel = checkNotNull(channel);
47
+        this.client = checkNotNull(client);
48
+        this.message = checkNotNull(message);
49
+        this.host = checkNotNull(host);
48 50
     }
49 51
 
50 52
     public ChannelInfo getChannel() {

+ 6
- 4
common/src/com/dmdirc/parser/events/ChannelModeChangeEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when the channel modes are changed or discovered.
33 35
  */
@@ -41,10 +43,10 @@ public class ChannelModeChangeEvent extends ParserEvent {
41 43
     public ChannelModeChangeEvent(final Parser parser, final Date date, final ChannelInfo channel,
42 44
             final ChannelClientInfo client, final String host, final String modes) {
43 45
         super(parser, date);
44
-        this.channel = channel;
45
-        this.client = client;
46
-        this.host = host;
47
-        this.modes = modes;
46
+        this.channel = checkNotNull(channel);
47
+        this.client = checkNotNull(client);
48
+        this.host = checkNotNull(host);
49
+        this.modes = checkNotNull(modes);
48 50
     }
49 51
 
50 52
     public ChannelInfo getChannel() {

+ 7
- 5
common/src/com/dmdirc/parser/events/ChannelModeMessageEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person sends a Message to a channel with a mode prefix.
33 35
  */
@@ -43,11 +45,11 @@ public class ChannelModeMessageEvent extends ParserEvent {
43 45
             final char prefix, final ChannelClientInfo client, final String message,
44 46
             final String host) {
45 47
         super(parser, date);
46
-        this.channel = channel;
47
-        this.prefix = prefix;
48
-        this.client = client;
49
-        this.message = message;
50
-        this.host = host;
48
+        this.channel = checkNotNull(channel);
49
+        this.prefix = checkNotNull(prefix);
50
+        this.client = checkNotNull(client);
51
+        this.message = checkNotNull(message);
52
+        this.host = checkNotNull(host);
51 53
     }
52 54
 
53 55
     public ChannelInfo getChannel() {

+ 7
- 5
common/src/com/dmdirc/parser/events/ChannelModeNoticeEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person sends a notice to a channel with a mode prefix.
33 35
  */
@@ -43,11 +45,11 @@ public class ChannelModeNoticeEvent extends ParserEvent {
43 45
             final char prefix, final ChannelClientInfo client, final String message,
44 46
             final String host) {
45 47
         super(parser, date);
46
-        this.channel = channel;
47
-        this.prefix = prefix;
48
-        this.client = client;
49
-        this.message = message;
50
-        this.host = host;
48
+        this.channel = checkNotNull(channel);
49
+        this.prefix = checkNotNull(prefix);
50
+        this.client = checkNotNull(client);
51
+        this.message = checkNotNull(message);
52
+        this.host = checkNotNull(host);
51 53
     }
52 54
 
53 55
     public ChannelInfo getChannel() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ChannelNamesEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when a names reply is parsed.
32 34
  */
@@ -36,7 +38,7 @@ public class ChannelNamesEvent extends ParserEvent {
36 38
 
37 39
     public ChannelNamesEvent(final Parser parser, final Date date, final ChannelInfo channel) {
38 40
         super(parser, date);
39
-        this.channel = channel;
41
+        this.channel = checkNotNull(channel);
40 42
     }
41 43
 
42 44
     public ChannelInfo getChannel() {

+ 5
- 3
common/src/com/dmdirc/parser/events/ChannelNickChangeEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when we or another user change nickname (Called once per channel the user is on).
33 35
  */
@@ -40,9 +42,9 @@ public class ChannelNickChangeEvent extends ParserEvent {
40 42
     public ChannelNickChangeEvent(final Parser parser, final Date date, final ChannelInfo channel,
41 43
             final ChannelClientInfo client, final String oldNick) {
42 44
         super(parser, date);
43
-        this.channel = channel;
44
-        this.client = client;
45
-        this.oldNick = oldNick;
45
+        this.channel = checkNotNull(channel);
46
+        this.client = checkNotNull(client);
47
+        this.oldNick = checkNotNull(oldNick);
46 48
     }
47 49
 
48 50
     public ChannelInfo getChannel() {

+ 6
- 4
common/src/com/dmdirc/parser/events/ChannelNonUserModeChangeEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when the channel modes are changed or discovered.
33 35
  */
@@ -42,10 +44,10 @@ public class ChannelNonUserModeChangeEvent extends ParserEvent {
42 44
             final ChannelInfo channel, final ChannelClientInfo client, final String host,
43 45
             final String modes) {
44 46
         super(parser, date);
45
-        this.channel = channel;
46
-        this.client = client;
47
-        this.host = host;
48
-        this.modes = modes;
47
+        this.channel = checkNotNull(channel);
48
+        this.client = checkNotNull(client);
49
+        this.host = checkNotNull(host);
50
+        this.modes = checkNotNull(modes);
49 51
     }
50 52
 
51 53
     public ChannelInfo getChannel() {

+ 6
- 4
common/src/com/dmdirc/parser/events/ChannelNoticeEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when a person sends a notice to a channel.
33 35
  */
@@ -41,10 +43,10 @@ public class ChannelNoticeEvent extends ParserEvent {
41 43
     public ChannelNoticeEvent(final Parser parser, final Date date, final ChannelInfo channel,
42 44
             final ChannelClientInfo client, final String message, final String host) {
43 45
         super(parser, date);
44
-        this.channel = channel;
45
-        this.client = client;
46
-        this.message = message;
47
-        this.host = host;
46
+        this.channel = checkNotNull(channel);
47
+        this.client = checkNotNull(client);
48
+        this.message = checkNotNull(message);
49
+        this.host = checkNotNull(host);
48 50
     }
49 51
 
50 52
     public ChannelInfo getChannel() {

+ 6
- 4
common/src/com/dmdirc/parser/events/ChannelOtherAwayStateEvent.java Dosyayı Görüntüle

@@ -29,6 +29,8 @@ import com.dmdirc.parser.interfaces.Parser;
29 29
 
30 30
 import java.util.Date;
31 31
 
32
+import static com.google.common.base.Preconditions.checkNotNull;
33
+
32 34
 /**
33 35
  * Called when we go away, or come back.
34 36
  */
@@ -43,10 +45,10 @@ public class ChannelOtherAwayStateEvent extends ParserEvent {
43 45
             final ChannelInfo channel, final ChannelClientInfo client, final AwayState oldState,
44 46
             final AwayState newState) {
45 47
         super(parser, date);
46
-        this.channel = channel;
47
-        this.client = client;
48
-        this.oldState = oldState;
49
-        this.newState = newState;
48
+        this.channel = checkNotNull(channel);
49
+        this.client = checkNotNull(client);
50
+        this.oldState = checkNotNull(oldState);
51
+        this.newState = checkNotNull(newState);
50 52
     }
51 53
 
52 54
     public ChannelInfo getChannel() {

+ 5
- 3
common/src/com/dmdirc/parser/events/ChannelPartEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called When we, or another client parts a channel.
33 35
  */
@@ -40,9 +42,9 @@ public class ChannelPartEvent extends ParserEvent {
40 42
     public ChannelPartEvent(final Parser parser, final Date date, final ChannelInfo channel,
41 43
             final ChannelClientInfo client, final String reason) {
42 44
         super(parser, date);
43
-        this.channel = channel;
44
-        this.client = client;
45
-        this.reason = reason;
45
+        this.channel = checkNotNull(channel);
46
+        this.client = checkNotNull(client);
47
+        this.reason = checkNotNull(reason);
46 48
     }
47 49
 
48 50
     public ChannelInfo getChannel() {

+ 5
- 3
common/src/com/dmdirc/parser/events/ChannelQuitEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called When we, or another client quits IRC (Called once per channel the user was on).
33 35
  */
@@ -40,9 +42,9 @@ public class ChannelQuitEvent extends ParserEvent {
40 42
     public ChannelQuitEvent(final Parser parser, final Date date, final ChannelInfo channel,
41 43
             final ChannelClientInfo client, final String reason) {
42 44
         super(parser, date);
43
-        this.channel = channel;
44
-        this.client = client;
45
-        this.reason = reason;
45
+        this.channel = checkNotNull(channel);
46
+        this.client = checkNotNull(client);
47
+        this.reason = checkNotNull(reason);
46 48
     }
47 49
 
48 50
     public ChannelInfo getChannel() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ChannelSelfJoinEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when we join a channel.
32 34
  */
@@ -36,7 +38,7 @@ public class ChannelSelfJoinEvent extends ParserEvent {
36 38
 
37 39
     public ChannelSelfJoinEvent(final Parser parser, final Date date, final ChannelInfo channel) {
38 40
         super(parser, date);
39
-        this.channel = channel;
41
+        this.channel = checkNotNull(channel);
40 42
     }
41 43
 
42 44
     public ChannelInfo getChannel() {

+ 6
- 4
common/src/com/dmdirc/parser/events/ChannelSingleModeChangeEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when the channel modes are changed or discovered.
33 35
  */
@@ -42,10 +44,10 @@ public class ChannelSingleModeChangeEvent extends ParserEvent {
42 44
             final ChannelInfo channel, final ChannelClientInfo client, final String host,
43 45
             final String modes) {
44 46
         super(parser, date);
45
-        this.channel = channel;
46
-        this.client = client;
47
-        this.host = host;
48
-        this.modes = modes;
47
+        this.channel = checkNotNull(channel);
48
+        this.client = checkNotNull(client);
49
+        this.host = checkNotNull(host);
50
+        this.modes = checkNotNull(modes);
49 51
     }
50 52
 
51 53
     public ChannelInfo getChannel() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ChannelTopicEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when the topic is changed or discovered for the first time.
32 34
  */
@@ -38,7 +40,7 @@ public class ChannelTopicEvent extends ParserEvent {
38 40
     public ChannelTopicEvent(final Parser parser, final Date date, final ChannelInfo channel,
39 41
             final boolean isJoinTopic) {
40 42
         super(parser, date);
41
-        this.channel = channel;
43
+        this.channel = checkNotNull(channel);
42 44
         this.isJoinTopic = isJoinTopic;
43 45
     }
44 46
 

+ 7
- 5
common/src/com/dmdirc/parser/events/ChannelUserModeChangeEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  *  Called when a users channel mode is changed.
33 35
  */
@@ -43,11 +45,11 @@ public class ChannelUserModeChangeEvent extends ParserEvent {
43 45
             final ChannelInfo channel, final ChannelClientInfo targetClient,
44 46
             final ChannelClientInfo client, final String host, final String mode) {
45 47
         super(parser, date);
46
-        this.channel = channel;
47
-        this.targetClient = targetClient;
48
-        this.client = client;
49
-        this.host = host;
50
-        this.mode = mode;
48
+        this.channel = checkNotNull(channel);
49
+        this.targetClient = checkNotNull(targetClient);
50
+        this.client = checkNotNull(client);
51
+        this.host = checkNotNull(host);
52
+        this.mode = checkNotNull(mode);
51 53
     }
52 54
 
53 55
     public ChannelInfo getChannel() {

+ 4
- 2
common/src/com/dmdirc/parser/events/CompositionStateChangeEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when a person's composition state changes.
32 34
  */
@@ -38,8 +40,8 @@ public class CompositionStateChangeEvent extends ParserEvent {
38 40
     public CompositionStateChangeEvent(final Parser parser, final Date date,
39 41
             final CompositionState state, final String host) {
40 42
         super(parser, date);
41
-        this.state = state;
42
-        this.host = host;
43
+        this.state = checkNotNull(state);
44
+        this.host = checkNotNull(host);
43 45
     }
44 46
 
45 47
     public CompositionState getState() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ConnectErrorEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called to give Error Information related to a connection attempt.
32 34
  */
@@ -36,7 +38,7 @@ public class ConnectErrorEvent extends ParserEvent {
36 38
 
37 39
     public ConnectErrorEvent(final Parser parser, final Date date, final ParserError errorInfo) {
38 40
         super(parser, date);
39
-        this.errorInfo = errorInfo;
41
+        this.errorInfo = checkNotNull(errorInfo);
40 42
     }
41 43
 
42 44
     public ParserError getErrorInfo() {

+ 3
- 1
common/src/com/dmdirc/parser/events/DataInEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Interface Used on every incoming line BEFORE parsing.
31 33
  */
@@ -35,7 +37,7 @@ public class DataInEvent extends ParserEvent {
35 37
 
36 38
     public DataInEvent(final Parser parser, final Date date, final String data) {
37 39
         super(parser, date);
38
-        this.data = data;
40
+        this.data = checkNotNull(data);
39 41
     }
40 42
 
41 43
     public String getData() {

+ 3
- 1
common/src/com/dmdirc/parser/events/DataOutEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called on every incoming line BEFORE being sent.
31 33
  */
@@ -35,7 +37,7 @@ public class DataOutEvent extends ParserEvent {
35 37
 
36 38
     public DataOutEvent(final Parser parser, final Date date, final String data) {
37 39
         super(parser, date);
38
-        this.data = data;
40
+        this.data = checkNotNull(data);
39 41
     }
40 42
 
41 43
     public String getData() {

+ 3
- 1
common/src/com/dmdirc/parser/events/DebugInfoEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Interface Used to give Debug Information.
31 33
  */
@@ -38,7 +40,7 @@ public class DebugInfoEvent extends ParserEvent {
38 40
             final String data) {
39 41
         super(parser, date);
40 42
         this.level = level;
41
-        this.data = data;
43
+        this.data = checkNotNull(data);
42 44
     }
43 45
 
44 46
     public int getLevel() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ErrorInfoEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called to give Error Information.
32 34
  */
@@ -36,7 +38,7 @@ public class ErrorInfoEvent extends ParserEvent {
36 38
 
37 39
     public ErrorInfoEvent(final Parser parser, final Date date, final ParserError errorInfo) {
38 40
         super(parser, date);
39
-        this.errorInfo = errorInfo;
41
+        this.errorInfo = checkNotNull(errorInfo);
40 42
     }
41 43
 
42 44
     public ParserError getErrorInfo() {

+ 5
- 3
common/src/com/dmdirc/parser/events/GroupListEntryEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Callback interface for when the parser receives an entry during a group list response.
31 33
  */
@@ -38,9 +40,9 @@ public class GroupListEntryEvent extends ParserEvent {
38 40
     public GroupListEntryEvent(final Parser parser, final Date date, final String name,
39 41
             final int users, final String topic) {
40 42
         super(parser, date);
41
-        this.name = name;
42
-        this.users = users;
43
-        this.topic = topic;
43
+        this.name = checkNotNull(name);
44
+        this.users = checkNotNull(users);
45
+        this.topic = checkNotNull(topic);
44 46
     }
45 47
 
46 48
     public String getName() {

+ 4
- 2
common/src/com/dmdirc/parser/events/InviteEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when we are invited to a channel.
31 33
  */
@@ -37,8 +39,8 @@ public class InviteEvent extends ParserEvent {
37 39
     public InviteEvent(final Parser parser, final Date date, final String userHost,
38 40
             final String channel) {
39 41
         super(parser, date);
40
-        this.userHost = userHost;
41
-        this.channel = channel;
42
+        this.userHost = checkNotNull(userHost);
43
+        this.channel = checkNotNull(channel);
42 44
     }
43 45
 
44 46
     public String getUserHost() {

+ 3
- 1
common/src/com/dmdirc/parser/events/MOTDEndEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when "End of MOTD" or "No MOTD" is received.
31 33
  */
@@ -38,7 +40,7 @@ public class MOTDEndEvent extends ParserEvent {
38 40
             final String data) {
39 41
         super(parser, date);
40 42
         this.noMOTD = noMOTD;
41
-        this.data = data;
43
+        this.data = checkNotNull(data);
42 44
     }
43 45
 
44 46
     public boolean isNoMOTD() {

+ 3
- 1
common/src/com/dmdirc/parser/events/MOTDLineEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Interface Used to give MOTD Information.
31 33
  */
@@ -35,7 +37,7 @@ public class MOTDLineEvent extends ParserEvent {
35 37
 
36 38
     public MOTDLineEvent(final Parser parser, final Date date, final String data) {
37 39
         super(parser, date);
38
-        this.data = data;
40
+        this.data = checkNotNull(data);
39 41
     }
40 42
 
41 43
     public String getData() {

+ 3
- 1
common/src/com/dmdirc/parser/events/MOTDStartEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Interface Used when the MOTD Starts.
31 33
  */
@@ -35,7 +37,7 @@ public class MOTDStartEvent extends ParserEvent {
35 37
 
36 38
     public MOTDStartEvent(final Parser parser, final Date date, final String data) {
37 39
         super(parser, date);
38
-        this.data = data;
40
+        this.data = checkNotNull(data);
39 41
     }
40 42
 
41 43
     public String getData() {

+ 5
- 3
common/src/com/dmdirc/parser/events/NetworkDetectedEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Interface Used when the Network=blah 005 token is recieved.
31 33
  */
@@ -38,9 +40,9 @@ public class NetworkDetectedEvent extends ParserEvent {
38 40
     public NetworkDetectedEvent(final Parser parser, final Date date, final String networkName,
39 41
             final String ircdVersion, final String ircdType) {
40 42
         super(parser, date);
41
-        this.networkName = networkName;
42
-        this.ircdVersion = ircdVersion;
43
-        this.ircdType = ircdType;
43
+        this.networkName = checkNotNull(networkName);
44
+        this.ircdVersion = checkNotNull(ircdVersion);
45
+        this.ircdType = checkNotNull(ircdType);
44 46
     }
45 47
 
46 48
     public String getNetworkName() {

+ 4
- 2
common/src/com/dmdirc/parser/events/NickChangeEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when we or another user change nickname.
32 34
  */
@@ -38,8 +40,8 @@ public class NickChangeEvent extends ParserEvent {
38 40
     public NickChangeEvent(final Parser parser, final Date date, final ClientInfo client,
39 41
             final String oldNick) {
40 42
         super(parser, date);
41
-        this.client = client;
42
-        this.oldNick = oldNick;
43
+        this.client = checkNotNull(client);
44
+        this.oldNick = checkNotNull(oldNick);
43 45
     }
44 46
 
45 47
     public ClientInfo getClient() {

+ 3
- 1
common/src/com/dmdirc/parser/events/NickInUseEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when requested nickname is in use.
31 33
  */
@@ -35,7 +37,7 @@ public class NickInUseEvent extends ParserEvent {
35 37
 
36 38
     public NickInUseEvent(final Parser parser, final Date date, final String nickname) {
37 39
         super(parser, date);
38
-        this.nickname = nickname;
40
+        this.nickname = checkNotNull(nickname);
39 41
     }
40 42
 
41 43
     public String getNickname() {

+ 4
- 2
common/src/com/dmdirc/parser/events/NumericEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Interface Used to give numeric Information.
31 33
  */
@@ -37,8 +39,8 @@ public class NumericEvent extends ParserEvent {
37 39
     public NumericEvent(final Parser parser, final Date date, final int numeric,
38 40
             final String[] token) {
39 41
         super(parser, date);
40
-        this.numeric = numeric;
41
-        this.token = token;
42
+        this.numeric = checkNotNull(numeric);
43
+        this.token = checkNotNull(token);
42 44
     }
43 45
 
44 46
     public int getNumeric() {

+ 5
- 3
common/src/com/dmdirc/parser/events/OtherAwayStateEvent.java Dosyayı Görüntüle

@@ -28,6 +28,8 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 import java.util.Date;
30 30
 
31
+import static com.google.common.base.Preconditions.checkNotNull;
32
+
31 33
 /**
32 34
  * Called when we go away, or come back.
33 35
  */
@@ -40,9 +42,9 @@ public class OtherAwayStateEvent extends ParserEvent {
40 42
     public OtherAwayStateEvent(final Parser parser, final Date date, final ClientInfo client,
41 43
             final AwayState oldState, final AwayState newState) {
42 44
         super(parser, date);
43
-        this.client = client;
44
-        this.oldState = oldState;
45
-        this.newState = newState;
45
+        this.client = checkNotNull(client);
46
+        this.oldState = checkNotNull(oldState);
47
+        this.newState = checkNotNull(newState);
46 48
     }
47 49
 
48 50
     public ClientInfo getClient() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ParserErrorEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Parser error event.
31 33
  */
@@ -35,7 +37,7 @@ public class ParserErrorEvent extends ParserEvent {
35 37
 
36 38
     public ParserErrorEvent(final Parser parser, final Date date, final Throwable throwable) {
37 39
         super(parser, date);
38
-        this.throwable = throwable;
40
+        this.throwable = checkNotNull(throwable);
39 41
     }
40 42
 
41 43
     public Throwable getThrowable() {

+ 8
- 15
common/src/com/dmdirc/parser/events/ParserEvent.java Dosyayı Görüntüle

@@ -26,17 +26,19 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30
- *
32
+ * Base class for events emitted by a {@link Parser}.
31 33
  */
32
-public class ParserEvent {
34
+public abstract class ParserEvent {
33 35
 
34
-    private Parser parser;
35
-    private Date date;
36
+    private final Parser parser;
37
+    private final Date date;
36 38
 
37 39
     public ParserEvent(final Parser parser, final Date date) {
38
-        this.parser = parser;
39
-        this.date = date;
40
+        this.parser = checkNotNull(parser);
41
+        this.date = checkNotNull(date);
40 42
     }
41 43
 
42 44
     public Parser getParser() {
@@ -47,13 +49,4 @@ public class ParserEvent {
47 49
         return date;
48 50
     }
49 51
 
50
-    // TODO: HACKY REMOVE
51
-    public void setParser(final Parser parser) {
52
-        this.parser = parser;
53
-    }
54
-
55
-    // TODO: HACKY REMOVE
56
-    public void setDate(final Date date) {
57
-        this.date = date;
58
-    }
59 52
 }

+ 4
- 2
common/src/com/dmdirc/parser/events/PrivateActionEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person does an action to you (PM).
31 33
  */
@@ -37,8 +39,8 @@ public class PrivateActionEvent extends ParserEvent {
37 39
     public PrivateActionEvent(final Parser parser, final Date date, final String message,
38 40
             final String host) {
39 41
         super(parser, date);
40
-        this.message = message;
41
-        this.host = host;
42
+        this.message = checkNotNull(message);
43
+        this.host = checkNotNull(host);
42 44
     }
43 45
 
44 46
     public String getMessage() {

+ 5
- 3
common/src/com/dmdirc/parser/events/PrivateCTCPEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a CTCP to you directly.
31 33
  */
@@ -38,9 +40,9 @@ public class PrivateCTCPEvent extends ParserEvent {
38 40
     public PrivateCTCPEvent(final Parser parser, final Date date, final String type,
39 41
             final String message, final String host) {
40 42
         super(parser, date);
41
-        this.type = type;
42
-        this.message = message;
43
-        this.host = host;
43
+        this.type = checkNotNull(type);
44
+        this.message = checkNotNull(message);
45
+        this.host = checkNotNull(host);
44 46
     }
45 47
 
46 48
     public String getType() {

+ 5
- 3
common/src/com/dmdirc/parser/events/PrivateCTCPReplyEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a CTCPRReply to you directly.
31 33
  */
@@ -38,9 +40,9 @@ public class PrivateCTCPReplyEvent extends ParserEvent {
38 40
     public PrivateCTCPReplyEvent(final Parser parser, final Date date, final String type,
39 41
             final String message, final String host) {
40 42
         super(parser, date);
41
-        this.type = type;
42
-        this.message = message;
43
-        this.host = host;
43
+        this.type = checkNotNull(type);
44
+        this.message = checkNotNull(message);
45
+        this.host = checkNotNull(host);
44 46
     }
45 47
 
46 48
     public String getType() {

+ 4
- 2
common/src/com/dmdirc/parser/events/PrivateMessageEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a message to you directly (PM).
31 33
  */
@@ -37,8 +39,8 @@ public class PrivateMessageEvent extends ParserEvent {
37 39
     public PrivateMessageEvent(final Parser parser, final Date date, final String message,
38 40
             final String host) {
39 41
         super(parser, date);
40
-        this.message = message;
41
-        this.host = host;
42
+        this.message = checkNotNull(message);
43
+        this.host = checkNotNull(host);
42 44
     }
43 45
 
44 46
     public String getMessage() {

+ 4
- 2
common/src/com/dmdirc/parser/events/PrivateNoticeEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a notice to you.
31 33
  */
@@ -37,8 +39,8 @@ public class PrivateNoticeEvent extends ParserEvent {
37 39
     public PrivateNoticeEvent(final Parser parser, final Date date, final String message,
38 40
             final String host) {
39 41
         super(parser, date);
40
-        this.message = message;
41
-        this.host = host;
42
+        this.message = checkNotNull(message);
43
+        this.host = checkNotNull(host);
42 44
     }
43 45
 
44 46
     public String getMessage() {

+ 4
- 2
common/src/com/dmdirc/parser/events/QuitEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called When we, or another client quits IRC (Called once in total).
32 34
  */
@@ -38,8 +40,8 @@ public class QuitEvent extends ParserEvent {
38 40
     public QuitEvent(final Parser parser, final Date date, final ClientInfo client,
39 41
             final String reason) {
40 42
         super(parser, date);
41
-        this.client = client;
42
-        this.reason = reason;
43
+        this.client = checkNotNull(client);
44
+        this.reason = checkNotNull(reason);
43 45
     }
44 46
 
45 47
     public ClientInfo getClient() {

+ 3
- 1
common/src/com/dmdirc/parser/events/ServerErrorEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Interface Used to give ServerError.
31 33
  */
@@ -35,7 +37,7 @@ public class ServerErrorEvent extends ParserEvent {
35 37
 
36 38
     public ServerErrorEvent(final Parser parser, final Date date, final String message) {
37 39
         super(parser, date);
38
-        this.message = message;
40
+        this.message = checkNotNull(message);
39 41
     }
40 42
 
41 43
     public String getMessage() {

+ 4
- 2
common/src/com/dmdirc/parser/events/ServerNoticeEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a server sends a notice to you.
31 33
  */
@@ -37,8 +39,8 @@ public class ServerNoticeEvent extends ParserEvent {
37 39
     public ServerNoticeEvent(final Parser parser, final Date date, final String message,
38 40
             final String host) {
39 41
         super(parser, date);
40
-        this.message = message;
41
-        this.host = host;
42
+        this.message = checkNotNull(message);
43
+        this.host = checkNotNull(host);
42 44
     }
43 45
 
44 46
     public String getMessage() {

+ 5
- 3
common/src/com/dmdirc/parser/events/UnknownActionEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends an action not aimed specifically at you or a channel (ie $*).
31 33
  */
@@ -38,9 +40,9 @@ public class UnknownActionEvent extends ParserEvent {
38 40
     public UnknownActionEvent(final Parser parser, final Date date, final String message,
39 41
             final String target, final String host) {
40 42
         super(parser, date);
41
-        this.message = message;
42
-        this.target = target;
43
-        this.host = host;
43
+        this.message = checkNotNull(message);
44
+        this.target = checkNotNull(target);
45
+        this.host = checkNotNull(host);
44 46
     }
45 47
 
46 48
     public String getMessage() {

+ 6
- 4
common/src/com/dmdirc/parser/events/UnknownCTCPEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a CTCP not aimed at you or a channel (ie $*).
31 33
  */
@@ -39,10 +41,10 @@ public class UnknownCTCPEvent extends ParserEvent {
39 41
     public UnknownCTCPEvent(final Parser parser, final Date date, final String type,
40 42
             final String message, final String target, final String host) {
41 43
         super(parser, date);
42
-        this.type = type;
43
-        this.message = message;
44
-        this.target = target;
45
-        this.host = host;
44
+        this.type = checkNotNull(type);
45
+        this.message = checkNotNull(message);
46
+        this.target = checkNotNull(target);
47
+        this.host = checkNotNull(host);
46 48
     }
47 49
 
48 50
     public String getType() {

+ 6
- 4
common/src/com/dmdirc/parser/events/UnknownCTCPReplyEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a CTCP not aimed at you or a channel (ie $*).
31 33
  */
@@ -39,10 +41,10 @@ public class UnknownCTCPReplyEvent extends ParserEvent {
39 41
     public UnknownCTCPReplyEvent(final Parser parser, final Date date, final String type,
40 42
             final String message, final String target, final String host) {
41 43
         super(parser, date);
42
-        this.type = type;
43
-        this.message = message;
44
-        this.target = target;
45
-        this.host = host;
44
+        this.type = checkNotNull(type);
45
+        this.message = checkNotNull(message);
46
+        this.target = checkNotNull(target);
47
+        this.host = checkNotNull(host);
46 48
     }
47 49
 
48 50
     public String getType() {

+ 5
- 3
common/src/com/dmdirc/parser/events/UnknownMessageEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a message not aimed specifically at you or a channel (ie $*).
31 33
  */
@@ -38,9 +40,9 @@ public class UnknownMessageEvent extends ParserEvent {
38 40
     public UnknownMessageEvent(final Parser parser, final Date date,
39 41
             final String message, final String target, final String host) {
40 42
         super(parser, date);
41
-        this.message = message;
42
-        this.target = target;
43
-        this.host = host;
43
+        this.message = checkNotNull(message);
44
+        this.target = checkNotNull(target);
45
+        this.host = checkNotNull(host);
44 46
     }
45 47
 
46 48
     public String getMessage() {

+ 5
- 3
common/src/com/dmdirc/parser/events/UnknownNoticeEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a person sends a notice not aimed specifically at you or a channel (ie $*).
31 33
  */
@@ -38,9 +40,9 @@ public class UnknownNoticeEvent extends ParserEvent {
38 40
     public UnknownNoticeEvent(final Parser parser, final Date date,
39 41
             final String message, final String target, final String host) {
40 42
         super(parser, date);
41
-        this.message = message;
42
-        this.target = target;
43
-        this.host = host;
43
+        this.message = checkNotNull(message);
44
+        this.target = checkNotNull(target);
45
+        this.host = checkNotNull(host);
44 46
     }
45 47
 
46 48
     public String getMessage() {

+ 5
- 3
common/src/com/dmdirc/parser/events/UnknownServerNoticeEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a server sends a notice not aimed specifically at you or a channel (ie $*).
31 33
  */
@@ -38,9 +40,9 @@ public class UnknownServerNoticeEvent extends ParserEvent {
38 40
     public UnknownServerNoticeEvent(final Parser parser, final Date date, final String message,
39 41
             final String target, final String host) {
40 42
         super(parser, date);
41
-        this.message = message;
42
-        this.target = target;
43
-        this.host = host;
43
+        this.message = checkNotNull(message);
44
+        this.target = checkNotNull(target);
45
+        this.host = checkNotNull(host);
44 46
     }
45 47
 
46 48
     public String getMessage() {

+ 5
- 3
common/src/com/dmdirc/parser/events/UserModeChangeEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when user modes are changed.
32 34
  */
@@ -39,9 +41,9 @@ public class UserModeChangeEvent extends ParserEvent {
39 41
     public UserModeChangeEvent(final Parser parser, final Date date, final ClientInfo client,
40 42
             final String host, final String modes) {
41 43
         super(parser, date);
42
-        this.client = client;
43
-        this.host = host;
44
-        this.modes = modes;
44
+        this.client = checkNotNull(client);
45
+        this.host = checkNotNull(host);
46
+        this.modes = checkNotNull(modes);
45 47
     }
46 48
 
47 49
     public ClientInfo getClient() {

+ 4
- 2
common/src/com/dmdirc/parser/events/UserModeDiscoveryEvent.java Dosyayı Görüntüle

@@ -27,6 +27,8 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
+import static com.google.common.base.Preconditions.checkNotNull;
31
+
30 32
 /**
31 33
  * Called when user modes are Discovered.
32 34
  */
@@ -38,8 +40,8 @@ public class UserModeDiscoveryEvent extends ParserEvent {
38 40
     public UserModeDiscoveryEvent(final Parser parser, final Date date, final ClientInfo client,
39 41
             final String modes) {
40 42
         super(parser, date);
41
-        this.client = client;
42
-        this.modes = modes;
43
+        this.client = checkNotNull(client);
44
+        this.modes = checkNotNull(modes);
43 45
     }
44 46
 
45 47
     public ClientInfo getClient() {

+ 4
- 2
common/src/com/dmdirc/parser/events/WallDesyncEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when a Desync message is recieved over wallops.
31 33
  */
@@ -37,8 +39,8 @@ public class WallDesyncEvent extends ParserEvent {
37 39
     public WallDesyncEvent(final Parser parser, final Date date, final String message,
38 40
             final String host) {
39 41
         super(parser, date);
40
-        this.message = message;
41
-        this.host = host;
42
+        this.message = checkNotNull(message);
43
+        this.host = checkNotNull(host);
42 44
     }
43 45
 
44 46
     public String getMessage() {

+ 4
- 2
common/src/com/dmdirc/parser/events/WallopEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when an oper-only message is recieved over wallops.
31 33
  */
@@ -37,8 +39,8 @@ public class WallopEvent extends ParserEvent {
37 39
     public WallopEvent(final Parser parser, final Date date, final String message,
38 40
             final String host) {
39 41
         super(parser, date);
40
-        this.message = message;
41
-        this.host = host;
42
+        this.message = checkNotNull(message);
43
+        this.host = checkNotNull(host);
42 44
     }
43 45
 
44 46
     public String getMessage() {

+ 4
- 2
common/src/com/dmdirc/parser/events/WalluserEvent.java Dosyayı Görüntüle

@@ -26,6 +26,8 @@ import com.dmdirc.parser.interfaces.Parser;
26 26
 
27 27
 import java.util.Date;
28 28
 
29
+import static com.google.common.base.Preconditions.checkNotNull;
30
+
29 31
 /**
30 32
  * Called when an all-users message is recieved over wallops.
31 33
  */
@@ -37,8 +39,8 @@ public class WalluserEvent extends ParserEvent {
37 39
     public WalluserEvent(final Parser parser, final Date date, final String message,
38 40
             final String host) {
39 41
         super(parser, date);
40
-        this.message = message;
41
-        this.host = host;
42
+        this.message = checkNotNull(message);
43
+        this.host = checkNotNull(host);
42 44
     }
43 45
 
44 46
     public String getMessage() {

+ 0
- 127
irc/test/com/dmdirc/harness/parser/TestParser.java Dosyayı Görüntüle

@@ -1,127 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.harness.parser;
24
-
25
-import com.dmdirc.parser.common.ChildImplementations;
26
-import com.dmdirc.parser.common.MyInfo;
27
-import com.dmdirc.parser.common.QueuePriority;
28
-import com.dmdirc.parser.irc.IRCChannelClientInfo;
29
-import com.dmdirc.parser.irc.IRCChannelInfo;
30
-import com.dmdirc.parser.irc.IRCClientInfo;
31
-import com.dmdirc.parser.irc.IRCParser;
32
-import com.dmdirc.parser.irc.IRCReader;
33
-import com.dmdirc.parser.irc.SocketState;
34
-
35
-import java.net.URI;
36
-import java.net.URISyntaxException;
37
-import java.util.ArrayList;
38
-import java.util.List;
39
-import java.util.Timer;
40
-
41
-@ChildImplementations({
42
-    IRCChannelClientInfo.class,
43
-    IRCChannelInfo.class,
44
-    IRCClientInfo.class
45
-})
46
-public class TestParser extends IRCParser {
47
-
48
-    public final List<String> sentLines = new ArrayList<>();
49
-
50
-    public String nick = "nick";
51
-
52
-    public String network = null;
53
-
54
-    public TestParser() {
55
-        super(buildURI());
56
-        currentSocketState = SocketState.OPEN;
57
-        setPingTimerFraction(10);
58
-        setPingTimerInterval(60000);
59
-    }
60
-
61
-    public TestParser(final MyInfo myDetails, final URI address) {
62
-        super(myDetails, address);
63
-        currentSocketState = SocketState.OPEN;
64
-        setPingTimerFraction(10);
65
-        setPingTimerInterval(60000);
66
-    }
67
-
68
-    private static URI buildURI() {
69
-        try {
70
-            return new URI("irc://host:1234/");
71
-        } catch (URISyntaxException ex) {
72
-            return null;
73
-        }
74
-    }
75
-
76
-    @Override
77
-    protected boolean doSendString(final String line, final QueuePriority priority, final boolean fromParser) {
78
-        sentLines.add(line);
79
-        return true;
80
-    }
81
-
82
-    public String[] getLine(final int index) {
83
-        return tokeniseLine(sentLines.get(index));
84
-    }
85
-
86
-    public void injectLine(final String line) {
87
-        processLine(new IRCReader.ReadLine(line, IRCParser.tokeniseLine(line)));
88
-    }
89
-
90
-    public void injectConnectionStrings() {
91
-        final String[] lines = {
92
-            "NOTICE AUTH :Blah, blah",
93
-            ":server 001 " + nick + " :Welcome to the Testing IRC Network, " + nick,
94
-            ":server 002 " + nick + " :Your host is server.net, running version foo",
95
-            ":server 003 " + nick + " :This server was created Sun Jan 6 2008 at 17:34:54 CET",
96
-            ":server 004 " + nick + " server.net foo dioswkgxRXInP bRIeiklmnopstvrDcCNuMT bklov",
97
-            ":server 005 " + nick + " WHOX WALLCHOPS WALLVOICES USERIP PREFIX=(ov)@+ " +
98
-                    (network == null ? "" : "NETWORK=" + network + ' ') +
99
-                    ":are supported by this server",
100
-            ":server 005 " + nick + " MAXNICKLEN=15 TOPICLEN=250 AWAYLEN=160 MODES=6 " +
101
-                    "CHANMODES=bIeR,k,l,imnpstrDducCNMT :are supported by this server",
102
-        };
103
-
104
-        sendConnectionStrings();
105
-
106
-        for (String line : lines) {
107
-            injectLine(line);
108
-        }
109
-
110
-        sentLines.clear();
111
-    }
112
-
113
-    @Override
114
-    protected void pingTimerTask(final Timer timer) {
115
-        // Do nothing
116
-    }
117
-
118
-    @Override
119
-    public void run() {
120
-        injectConnectionStrings();
121
-    }
122
-
123
-    public void runSuper() {
124
-        super.run();
125
-    }
126
-
127
-}

+ 0
- 105
irc/test/com/dmdirc/parser/irc/ChannelClientInfoTest.java Dosyayı Görüntüle

@@ -1,105 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.irc;
24
-
25
-import com.dmdirc.harness.parser.TestParser;
26
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
27
-
28
-import java.util.HashMap;
29
-import java.util.Map;
30
-
31
-import org.junit.Test;
32
-
33
-import static org.junit.Assert.assertEquals;
34
-import static org.junit.Assert.assertSame;
35
-
36
-public class ChannelClientInfoTest {
37
-        
38
-    @Test
39
-    public void testImportantMode() {
40
-        final TestParser parser = new TestParser();
41
-
42
-        parser.injectConnectionStrings();
43
-        parser.injectLine(":nick JOIN #DMDirc_testing");
44
-        parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
45
-        parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
46
-
47
-        final IRCChannelClientInfo cci = (IRCChannelClientInfo) parser.getClient("luser")
48
-                .getChannelClients().get(0);
49
-
50
-        assertEquals("v", cci.getImportantMode());
51
-        assertEquals("+", cci.getImportantModePrefix());
52
-        assertEquals("+luser", cci.toString());
53
-        assertEquals("+luser", cci.toFullString());
54
-
55
-        parser.injectLine(":server MODE #DMDirc_testing +o luser");
56
-        assertEquals("o", cci.getImportantMode());
57
-        assertEquals("@", cci.getImportantModePrefix());
58
-        assertEquals("@luser", cci.toString());
59
-        assertEquals("@+luser", cci.toFullString());
60
-
61
-        parser.injectLine(":server MODE #DMDirc_testing -ov luser luser");
62
-        assertEquals("", cci.getImportantMode());
63
-        assertEquals("", cci.getImportantModePrefix());
64
-        assertEquals("luser", cci.toString());
65
-        assertEquals("luser", cci.toFullString());
66
-    }
67
-    
68
-    @Test
69
-    public void testMap() {
70
-        final TestParser parser = new TestParser();
71
-
72
-        parser.injectConnectionStrings();
73
-        parser.injectLine(":nick JOIN #DMDirc_testing");
74
-        final Map<Object, Object> map1 = new HashMap<>();
75
-        final Map<Object, Object> map2 = new HashMap<>();
76
-        
77
-        final IRCChannelClientInfo cci = (IRCChannelClientInfo) parser.getClient("nick")
78
-                .getChannelClients().get(0);
79
-        
80
-        cci.setMap(map1);
81
-        assertSame(map1, cci.getMap());
82
-        
83
-        cci.setMap(map2);
84
-        assertSame(map2, cci.getMap());
85
-    }
86
-    
87
-    @Test
88
-    public void testKick() {
89
-        final TestParser parser = new TestParser();
90
-
91
-        parser.injectConnectionStrings();
92
-        parser.injectLine(":nick JOIN #DMDirc_testing");
93
-        parser.sentLines.clear();
94
-        
95
-        parser.getClient("nick").getChannelClients().get(0).kick("");
96
-        assertEquals(1, parser.sentLines.size());
97
-        assertEquals("KICK #DMDirc_testing nick", parser.sentLines.get(0));
98
-        parser.sentLines.clear();
99
-        
100
-        parser.getClient("nick").getChannelClients().get(0).kick("booya");
101
-        assertEquals(1, parser.sentLines.size());
102
-        assertEquals("KICK #DMDirc_testing nick :booya", parser.sentLines.get(0));
103
-    }
104
-
105
-}

+ 0
- 347
irc/test/com/dmdirc/parser/irc/ChannelInfoTest.java Dosyayı Görüntüle

@@ -1,347 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-package com.dmdirc.parser.irc;
23
-
24
-import com.dmdirc.harness.parser.TestParser;
25
-
26
-import com.dmdirc.parser.interfaces.ChannelInfo;
27
-
28
-import org.junit.Ignore;
29
-import org.junit.Test;
30
-import static org.junit.Assert.*;
31
-
32
-public class ChannelInfoTest {
33
-
34
-    final IRCChannelInfo ci = new IRCChannelInfo(null, null, null, null, "name");
35
-
36
-    @Test
37
-    public void testGetName() {
38
-        assertEquals("name", ci.getName());
39
-    }
40
-
41
-    @Test
42
-    public void testAddingNames() {
43
-        assertTrue(ci.isAddingNames());
44
-
45
-        ci.setAddingNames(false);
46
-
47
-        assertFalse(ci.isAddingNames());
48
-    }
49
-
50
-    @Test
51
-    public void testCreateTime() {
52
-        ci.setCreateTime(12345L);
53
-
54
-        assertEquals(12345L, ci.getCreateTime());
55
-    }
56
-
57
-    @Test
58
-    public void testTopicTime() {
59
-        ci.setTopicTime(12345L);
60
-
61
-        assertEquals(12345L, ci.getTopicTime());
62
-    }
63
-
64
-    @Test
65
-    public void testTopic() {
66
-        ci.setInternalTopic("abcdef");
67
-
68
-        assertEquals("abcdef", ci.getTopic());
69
-    }
70
-
71
-    @Test
72
-    public void testSendMessage() {
73
-        final TestParser parser = new TestParser();
74
-        getChannel(parser).sendMessage("hello");
75
-
76
-        assertEquals("PRIVMSG #DMDirc_testing :hello", parser.sentLines.get(0));
77
-    }
78
-
79
-    @Test
80
-    public void testSendNotice() {
81
-        final TestParser parser = new TestParser();
82
-        getChannel(parser).sendNotice("hello");
83
-
84
-        assertEquals("NOTICE #DMDirc_testing :hello", parser.sentLines.get(0));
85
-    }
86
-
87
-    @Test
88
-    public void testSendCTCP() {
89
-        final TestParser parser = new TestParser();
90
-        getChannel(parser).sendCTCP("type", "hello");
91
-
92
-        assertEquals("PRIVMSG #DMDirc_testing :" + ((char) 1) + "TYPE hello" + ((char) 1),
93
-                parser.sentLines.get(0));
94
-    }
95
-
96
-    @Test
97
-    public void testSendCTCPEmpty() {
98
-        final TestParser parser = new TestParser();
99
-        getChannel(parser).sendCTCP("type", "");
100
-
101
-        assertEquals("PRIVMSG #DMDirc_testing :" + ((char) 1) + "TYPE" + ((char) 1),
102
-                parser.sentLines.get(0));
103
-    }
104
-
105
-    @Test
106
-    public void testSendAction() {
107
-        final TestParser parser = new TestParser();
108
-        getChannel(parser).sendAction("moo");
109
-
110
-        assertEquals("PRIVMSG #DMDirc_testing :" + ((char) 1) + "ACTION moo" + ((char) 1),
111
-                parser.sentLines.get(0));
112
-    }
113
-
114
-    @Test
115
-    public void testSendCTCPReply() {
116
-        final TestParser parser = new TestParser();
117
-        getChannel(parser).sendCTCPReply("type", "moo");
118
-
119
-        assertEquals("NOTICE #DMDirc_testing :" + ((char) 1) + "TYPE moo" + ((char) 1),
120
-                parser.sentLines.get(0));
121
-    }
122
-
123
-    @Test
124
-    public void testSendCTCPReplyEmpty() {
125
-        final TestParser parser = new TestParser();
126
-        getChannel(parser).sendCTCPReply("type", "");
127
-
128
-        assertEquals("NOTICE #DMDirc_testing :" + ((char) 1) + "TYPE" + ((char) 1),
129
-                parser.sentLines.get(0));
130
-    }
131
-
132
-    @Test
133
-    public void testSendEmptyMessages() {
134
-        final TestParser parser = new TestParser();
135
-        final IRCChannelInfo info = getChannel(parser);
136
-
137
-        info.sendAction("");
138
-        info.sendCTCP("", "");
139
-        info.sendCTCPReply("", "");
140
-        info.sendMessage("");
141
-        info.sendNotice("");
142
-
143
-        assertEquals(0, parser.sentLines.size());
144
-    }
145
-
146
-    @Test
147
-    public void testGetSetParamMode() {
148
-        final TestParser parser = new TestParser();
149
-        final ChannelInfo info = getChannel(parser);
150
-        parser.injectLine(":server 324 nick #DMDirc_testing +k lalala");
151
-        parser.sentLines.clear();
152
-
153
-        assertEquals("lalala", info.getMode('k'));
154
-        assertEquals("", info.getMode('z'));
155
-
156
-        parser.injectLine(":server MODE #DMDirc_testing -k *");
157
-
158
-        assertEquals("", info.getMode('k'));
159
-    }
160
-
161
-    @Test
162
-    public void testModeSendFull() {
163
-        final TestParser parser = new TestParser();
164
-        final ChannelInfo info = getChannel(parser);
165
-
166
-        parser.sentLines.clear();
167
-        info.alterMode(true, 'i', null);
168
-        info.alterMode(true, 'm', null);
169
-        info.alterMode(true, 'n', null);
170
-        info.alterMode(true, 'p', null);
171
-        info.alterMode(true, 't', null);
172
-        info.alterMode(true, 'r', null);
173
-
174
-        assertEquals("Parser must send modes as soon as the max number is reached",
175
-                1, parser.sentLines.size());
176
-        final String modes = getModes(parser.sentLines.get(0));
177
-
178
-        assertTrue(modes.indexOf('i') > -1);
179
-        assertTrue(modes.indexOf('m') > -1);
180
-        assertTrue(modes.indexOf('n') > -1);
181
-        assertTrue(modes.indexOf('p') > -1);
182
-        assertTrue(modes.indexOf('t') > -1);
183
-        assertTrue(modes.indexOf('r') > -1);
184
-    }
185
-
186
-    @Test
187
-    public void testModeSendExtra() {
188
-        final TestParser parser = new TestParser();
189
-        final ChannelInfo info = getChannel(parser);
190
-
191
-        parser.sentLines.clear();
192
-        info.alterMode(true, 'i', null);
193
-        info.alterMode(true, 'm', null);
194
-        info.alterMode(true, 'n', null);
195
-        info.alterMode(true, 'p', null);
196
-        info.alterMode(true, 't', null);
197
-        info.alterMode(true, 'r', null);
198
-        info.alterMode(true, 'N', null);
199
-        info.flushModes();
200
-
201
-        assertEquals("sendModes must send modes",
202
-                2, parser.sentLines.size());
203
-
204
-        final String modes = getModes(parser.sentLines.get(0))
205
-                + getModes(parser.sentLines.get(1));
206
-
207
-        assertTrue(modes.indexOf('i') > -1);
208
-        assertTrue(modes.indexOf('m') > -1);
209
-        assertTrue(modes.indexOf('n') > -1);
210
-        assertTrue(modes.indexOf('p') > -1);
211
-        assertTrue(modes.indexOf('t') > -1);
212
-        assertTrue(modes.indexOf('r') > -1);
213
-        assertTrue(modes.indexOf('N') > -1);
214
-    }
215
-
216
-    @Test
217
-    public void testModeSendOptimisation1() {
218
-        final TestParser parser = new TestParser();
219
-        final ChannelInfo info = getChannel(parser);
220
-
221
-        parser.sentLines.clear();
222
-        info.alterMode(true, 'i', null);
223
-        info.alterMode(true, 'm', null);
224
-        info.alterMode(true, 'n', null);
225
-        info.alterMode(true, 'n', null);
226
-        info.alterMode(false, 'i', null);
227
-        info.flushModes();
228
-
229
-        assertEquals("sendModes must send modes in one go",
230
-                1, parser.sentLines.size());
231
-
232
-        final String modes = getModes(parser.sentLines.get(0));
233
-
234
-        assertEquals("Setting a negative mode should cancel a positive one",
235
-                -1, modes.indexOf('i'));
236
-
237
-        assertTrue(modes.indexOf('m') > -1);
238
-    }
239
-
240
-    @Test
241
-    public void testModeSendOptimisation2() {
242
-        final TestParser parser = new TestParser();
243
-        final ChannelInfo info = getChannel(parser);
244
-
245
-        parser.sentLines.clear();
246
-        info.alterMode(true, 'm', null);
247
-        info.alterMode(true, 'n', null);
248
-        info.alterMode(true, 'n', null);
249
-        info.flushModes();
250
-
251
-        assertEquals("sendModes must send modes in one go",
252
-                1, parser.sentLines.size());
253
-
254
-        final String modes = getModes(parser.sentLines.get(0));
255
-
256
-        assertEquals("Setting a mode twice should have no effect",
257
-                modes.indexOf('n'), modes.lastIndexOf('n'));
258
-
259
-        assertTrue(modes.indexOf('m') > -1);
260
-    }
261
-
262
-    @Test
263
-    public void testModeUnsetKey() {
264
-        final TestParser parser = new TestParser();
265
-        final ChannelInfo info = getChannel(parser);
266
-        parser.injectLine(":server 324 nick #DMDirc_testing +k lalala");
267
-        parser.sentLines.clear();
268
-
269
-        info.alterMode(true, 'k', "foobar");
270
-        info.flushModes();
271
-
272
-        assertEquals("sendModes must send modes in one go",
273
-                1, parser.sentLines.size());
274
-        assertEquals("Setting +k must set -k first",
275
-                "-k+k lalala foobar", getModes(parser.sentLines.get(0)));
276
-    }
277
-
278
-    @Test
279
-    public void testIssue1410() {
280
-        final TestParser parser = new TestParser();
281
-
282
-        parser.injectConnectionStrings();
283
-        parser.injectLine(":nick JOIN #DMDirc_testing");
284
-        parser.injectLine(":foo!bar@baz JOIN #DMDirc_testing");
285
-        parser.injectLine(":flub!floo@fleeee JOIN #DMDirc_testing");
286
-
287
-        assertNotSame(parser.getChannel("#DMDirc_testing").getChannelClients(),
288
-                parser.getChannel("#DMDirc_testing").getChannelClients());
289
-        assertEquals(parser.getChannel("#DMDirc_testing").getChannelClients(),
290
-                parser.getChannel("#DMDirc_testing").getChannelClients());
291
-    }
292
-
293
-    @Test @Ignore
294
-    public void testModeUnsetKeyMultiple() {
295
-        final TestParser parser = new TestParser();
296
-        final ChannelInfo info = getChannel(parser);
297
-        parser.injectLine(":server 324 nick #DMDirc_testing +k lalala");
298
-        parser.sentLines.clear();
299
-
300
-        info.alterMode(true, 'k', "foobar");
301
-        info.alterMode(true, 'k', "blahblah");
302
-        info.alterMode(true, 'k', "unittest");
303
-        info.flushModes();
304
-
305
-        assertEquals("sendModes must send modes in one go",
306
-                1, parser.sentLines.size());
307
-        assertEquals("Setting a mode multiple times should have no effect",
308
-                "-k+k lalala unittest", getModes(parser.sentLines.get(0)));
309
-    }
310
-
311
-    @Test @Ignore
312
-    public void testModeUnsetLimitMultiple() {
313
-        final TestParser parser = new TestParser();
314
-        final ChannelInfo info = getChannel(parser);
315
-        parser.injectLine(":server 324 nick #DMDirc_testing +l 73");
316
-        parser.sentLines.clear();
317
-
318
-        info.alterMode(true, 'l', "74");
319
-        info.alterMode(true, 'l', "75");
320
-        info.alterMode(true, 'l', "76");
321
-        info.flushModes();
322
-
323
-        assertEquals("sendModes must send modes in one go",
324
-                1, parser.sentLines.size());
325
-        assertEquals("Setting a mode multiple times should have no effect",
326
-                "+l 76", getModes(parser.sentLines.get(0)));
327
-    }
328
-
329
-    private String getModes(final String line) {
330
-        final String res = line.substring("MODE #DMDirc_testing ".length());
331
-
332
-        if (res.charAt(0) == '+') {
333
-            return res.substring(1);
334
-        }
335
-
336
-        return res;
337
-    }
338
-
339
-    private IRCChannelInfo getChannel(final TestParser parser) {
340
-        parser.injectConnectionStrings();
341
-        parser.injectLine(":nick JOIN #DMDirc_testing");
342
-
343
-        parser.sentLines.clear();
344
-        return parser.getChannels().iterator().next();
345
-    }
346
-
347
-}

+ 0
- 76
irc/test/com/dmdirc/parser/irc/IRCParserIrcdTest.java Dosyayı Görüntüle

@@ -1,76 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.irc;
24
-
25
-import com.dmdirc.harness.parser.TestParser;
26
-import java.util.Arrays;
27
-import java.util.List;
28
-import org.junit.Test;
29
-import org.junit.runner.RunWith;
30
-import org.junit.runners.Parameterized;
31
-import static org.junit.Assert.*;
32
-
33
-@RunWith(Parameterized.class)
34
-public class IRCParserIrcdTest {
35
-
36
-    private final String ircd, expected;
37
-
38
-    public IRCParserIrcdTest(final String ircd, final String expected) {
39
-        this.ircd = ircd;
40
-        this.expected = expected;
41
-    }
42
-
43
-    @Test
44
-    public void testIrcdDetection() {
45
-        final TestParser parser = new TestParser();
46
-
47
-        String[] strings = {
48
-            ":server 001 nick :Welcome to the Testing IRC Network, nick",
49
-            ":server 002 nick :Your host is server.net, running version %s",
50
-            ":server 003 nick :This server was created Sun Jan 6 2008 at 17:34:54 CET",
51
-            ":server 004 nick server.net %s dioswkgxRXInP biklmnopstvrDcCNuMT bklov"
52
-        };
53
-
54
-        for (String line : strings) {
55
-            parser.injectLine(String.format(line, ircd));
56
-        }
57
-
58
-        assertEquals(ircd, parser.getServerSoftware());
59
-        assertEquals(expected.toLowerCase(), parser.getServerSoftwareType().toLowerCase());
60
-    }
61
-
62
-    @Parameterized.Parameters
63
-    public static List<String[]> data() {
64
-        final String[][] tests = {
65
-            {"u2.10.12.10+snircd(1.3.4)", "snircd"},
66
-            {"u2.10.12.12", "ircu"},
67
-            {"hyperion-1.0.2b", "hyperion"},
68
-            {"hybrid-7.2.3", "hybrid"},
69
-            {"Unreal3.2.6", "unreal"},
70
-            {"bahamut-1.8(04)", "bahamut"},
71
-        };
72
-
73
-        return Arrays.asList(tests);
74
-    }
75
-
76
-}

+ 0
- 93
irc/test/com/dmdirc/parser/irc/processors/ProcessListModeTest.java Dosyayı Görüntüle

@@ -1,93 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.irc.processors;
24
-
25
-import com.dmdirc.harness.parser.TestParser;
26
-import com.dmdirc.parser.common.ChannelListModeItem;
27
-import java.util.Collection;
28
-import org.junit.Test;
29
-import static org.junit.Assert.*;
30
-
31
-public class ProcessListModeTest {
32
-
33
-    private void testListModes(final String numeric1, final String numeric2, final char mode) {
34
-        final TestParser parser = new TestParser();
35
-        parser.injectConnectionStrings();
36
-
37
-        parser.injectLine(":nick JOIN #D");
38
-        parser.injectLine(":server " + numeric1 + " nick #D ban1!ident@.host bansetter1 1001");
39
-        parser.injectLine(":server " + numeric1 + " nick #D ban2!*@.host bansetter2 1002");
40
-        parser.injectLine(":server " + numeric1 + " nick #D ban3!ident@* bansetter3 1003");
41
-        parser.injectLine(":server " + numeric2 + " nick #D :End of Channel Something List");
42
-
43
-        final Collection<ChannelListModeItem> items
44
-                = parser.getChannel("#D").getListMode(mode);
45
-
46
-        assertEquals(3, items.size());
47
-        boolean gotOne = false, gotTwo = false, gotThree = false;
48
-
49
-        for (ChannelListModeItem item : items) {
50
-            if (item.getItem().equals("ban1!ident@.host")) {
51
-                assertEquals("bansetter1", item.getOwner());
52
-                assertEquals(1001L, item.getTime());
53
-                assertFalse(gotOne);
54
-                gotOne = true;
55
-            } else if (item.getItem().equals("ban2!*@.host")) {
56
-                assertEquals("bansetter2", item.getOwner());
57
-                assertEquals(1002L, item.getTime());
58
-                assertFalse(gotTwo);
59
-                gotTwo = true;
60
-            } else if (item.toString().equals("ban3!ident@*")) {
61
-                assertEquals("bansetter3", item.getOwner());
62
-                assertEquals(1003L, item.getTime());
63
-                assertFalse(gotThree);
64
-                gotThree = true;
65
-            }
66
-        }
67
-
68
-        assertTrue(gotOne);
69
-        assertTrue(gotTwo);
70
-        assertTrue(gotThree);
71
-    }
72
-
73
-    @Test
74
-    public void testNormalBans() {
75
-        testListModes("367", "368", 'b');
76
-    }
77
-
78
-    @Test
79
-    public void testInvexList() {
80
-        testListModes("346", "347", 'I');
81
-    }
82
-
83
-    @Test
84
-    public void testExemptList() {
85
-        testListModes("348", "349", 'e');
86
-    }
87
-
88
-    @Test
89
-    public void testReopList() {
90
-        testListModes("344", "345", 'R');
91
-    }
92
-
93
-}

+ 0
- 145
irc/test/com/dmdirc/parser/irc/processors/ProcessModeTest.java Dosyayı Görüntüle

@@ -1,145 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.parser.irc.processors;
24
-
25
-import com.dmdirc.harness.parser.TestParser;
26
-import com.dmdirc.parser.common.CallbackNotFoundException;
27
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
28
-
29
-import org.junit.Ignore;
30
-import org.junit.Test;
31
-
32
-import static org.junit.Assert.assertEquals;
33
-import static org.junit.Assert.assertNotNull;
34
-import static org.junit.Assert.assertTrue;
35
-
36
-@Ignore
37
-public class ProcessModeTest {
38
-    
39
-    @Test
40
-    public void testBasicUmodes() throws CallbackNotFoundException {
41
-        final TestParser parser = new TestParser();
42
-
43
-        parser.injectConnectionStrings();
44
-
45
-        parser.injectLine(":server 221 nick iw");
46
-
47
-        assertTrue(parser.getLocalClient().getModes().indexOf('i') > -1);
48
-        assertTrue(parser.getLocalClient().getModes().indexOf('w') > -1);
49
-    }
50
-    
51
-    @Test
52
-    public void testAlteringUmodes() throws CallbackNotFoundException {
53
-        final TestParser parser = new TestParser();
54
-
55
-        parser.injectConnectionStrings();
56
-
57
-        parser.injectLine(":server 221 nick iw");
58
-        parser.injectLine(":server MODE nick :-iw+ox");
59
-
60
-        assertTrue(parser.getLocalClient().getModes().indexOf('o') > -1);
61
-        assertTrue(parser.getLocalClient().getModes().indexOf('x') > -1);
62
-        assertEquals(-1, parser.getLocalClient().getModes().indexOf('i'));
63
-        assertEquals(-1, parser.getLocalClient().getModes().indexOf('w'));
64
-    }
65
-    
66
-    @Test
67
-    public void testChannelUmodes() {
68
-        final TestParser parser = new TestParser();
69
-
70
-        parser.injectConnectionStrings();
71
-        parser.injectLine(":nick JOIN #DMDirc_testing");
72
-        parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
73
-        parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
74
-
75
-        final ChannelClientInfo cci = parser.getClient("luser").getChannelClients().get(0);
76
-
77
-        parser.injectLine(":server MODE #DMDirc_testing +v luser");
78
-        assertEquals("v", cci.getAllModes());
79
-        assertEquals("+", cci.getAllModesPrefix());
80
-
81
-        parser.injectLine(":server MODE #DMDirc_testing +o luser");
82
-        assertEquals("ov", cci.getAllModes());
83
-        assertEquals("@+", cci.getAllModesPrefix());
84
-
85
-        parser.injectLine(":server MODE #DMDirc_testing +bov moo luser luser");
86
-        assertEquals("ov", cci.getAllModes());
87
-
88
-        parser.injectLine(":server MODE #DMDirc_testing -bov moo luser luser");
89
-        assertEquals("", cci.getAllModes());
90
-        assertEquals("", cci.getAllModesPrefix());
91
-    }
92
-    
93
-    @Test
94
-    public void testUnknownUser1() {
95
-        final TestParser parser = new TestParser();
96
-
97
-        parser.injectConnectionStrings();
98
-        parser.injectLine(":nick JOIN #DMDirc_testing");
99
-        parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
100
-        parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
101
-
102
-        parser.injectLine(":luser!me@my MODE #DMDirc_testing +v :moo");
103
-        
104
-        assertNotNull(parser.getClient("moo"));
105
-        assertEquals(0, parser.getClient("moo").getChannelCount());
106
-        
107
-        assertEquals("Parser should update ident when it sees a MODE line",
108
-                "me", parser.getClient("luser").getUsername());
109
-        assertEquals("Parser should update host when it sees a MODE line",
110
-                "my", parser.getClient("luser").getHostname());
111
-    }
112
-    
113
-    @Test
114
-    public void testChannelModes() {
115
-        final TestParser parser = new TestParser();
116
-
117
-        parser.injectConnectionStrings();
118
-        parser.injectLine(":nick JOIN #DMDirc_testing");
119
-        parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
120
-        parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
121
-        parser.injectLine(":server 324 nick #DMDirc_testing +Zstnl 1234");
122
-
123
-        assertEquals("1234", parser.getChannel("#DMDirc_testing").getMode('l'));
124
-        
125
-        String modes = parser.getChannel("#DMDirc_testing").getModes().split(" ")[0];
126
-        assertEquals(6, modes.length());
127
-        assertEquals('+', modes.charAt(0));
128
-        assertTrue(modes.indexOf('Z') > -1);
129
-        assertTrue(modes.indexOf('s') > -1);
130
-        assertTrue(modes.indexOf('t') > -1);
131
-        assertTrue(modes.indexOf('n') > -1);
132
-        assertTrue(modes.indexOf('l') > -1);
133
-        
134
-        parser.injectLine(":server MODE #DMDirc_testing :-Z");
135
-        
136
-        modes = parser.getChannel("#DMDirc_testing").getModes().split(" ")[0];
137
-        assertEquals(5, modes.length());
138
-        assertEquals('+', modes.charAt(0));
139
-        assertTrue(modes.indexOf('s') > -1);
140
-        assertTrue(modes.indexOf('t') > -1);
141
-        assertTrue(modes.indexOf('n') > -1);
142
-        assertTrue(modes.indexOf('l') > -1);        
143
-    }
144
-
145
-}

Loading…
İptal
Kaydet