Browse Source

Added processNickTest. Uncomment failing ChannelInfo tests and @Ignore them instead

git-svn-id: http://svn.dmdirc.com/trunk@3918 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 years ago
parent
commit
fd4d184068

+ 6
- 5
test/com/dmdirc/parser/ChannelInfoTest.java View File

@@ -24,10 +24,11 @@ package com.dmdirc.parser;
24 24
 import com.dmdirc.harness.parser.TestParser;
25 25
 import java.util.HashMap;
26 26
 import java.util.Map;
27
+import org.junit.Ignore;
27 28
 import org.junit.Test;
28 29
 import static org.junit.Assert.*;
29 30
 
30
-public class ChannelInfoTest extends junit.framework.TestCase {
31
+public class ChannelInfoTest {
31 32
 
32 33
     final ChannelInfo ci = new ChannelInfo(null, "name");
33 34
 
@@ -205,7 +206,7 @@ public class ChannelInfoTest extends junit.framework.TestCase {
205 206
         assertTrue(modes.indexOf('N') > -1);
206 207
     }
207 208
     
208
-    /*@Test
209
+    @Test @Ignore
209 210
     public void testModeSendOptimisation1() {
210 211
         final TestParser parser = new TestParser();
211 212
         final ChannelInfo info = getChannelInfo(parser);
@@ -227,9 +228,9 @@ public class ChannelInfoTest extends junit.framework.TestCase {
227 228
                 -1, modes.indexOf('i'));
228 229
         
229 230
         assertTrue(modes.indexOf('m') > -1);
230
-    }*/
231
+    }
231 232
     
232
-    /*@Test
233
+    @Test @Ignore
233 234
     public void testModeSendOptimisation2() {
234 235
         final TestParser parser = new TestParser();
235 236
         final ChannelInfo info = getChannelInfo(parser);
@@ -249,7 +250,7 @@ public class ChannelInfoTest extends junit.framework.TestCase {
249 250
                 modes.indexOf('n'), modes.lastIndexOf('n'));
250 251
         
251 252
         assertTrue(modes.indexOf('m') > -1);
252
-    }*/
253
+    }
253 254
     
254 255
     private String getModes(final String line) {
255 256
         final String res = line.substring("MODE #DMDirc_testing ".length());

+ 91
- 0
test/com/dmdirc/parser/ProcessNickTest.java View File

@@ -0,0 +1,91 @@
1
+/*
2
+ * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
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;
24
+
25
+import com.dmdirc.harness.parser.TestParser;
26
+import com.dmdirc.harness.parser.TestIErrorInfo;
27
+import com.dmdirc.parser.callbacks.CallbackNotFoundException;
28
+import org.junit.Ignore;
29
+import org.junit.Test;
30
+import static org.junit.Assert.*;
31
+
32
+public class ProcessNickTest {
33
+    
34
+    @Test
35
+    public void testNickSameName() {
36
+        final TestParser parser = new TestParser();
37
+
38
+        parser.injectConnectionStrings();
39
+        parser.injectLine(":nick JOIN #DMDirc_testing");
40
+        parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser @+nick2 nick3");
41
+        parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
42
+        parser.injectLine(":luser!lu@ser.com NICK LUSER");
43
+
44
+        assertNotNull(parser.getClientInfo("LUSER"));
45
+        assertEquals(1, parser.getClientInfo("LUSER").getChannelClients().size());
46
+
47
+        ChannelClientInfo cci = parser.getClientInfo("LUSER").getChannelClients().get(0);
48
+        assertEquals(parser.getChannelInfo("#DMDirc_testing"), cci.getChannel());
49
+        assertEquals("+", cci.getChanModeStr(true));
50
+    }
51
+    
52
+    @Test
53
+    public void testNickDifferent() {
54
+        final TestParser parser = new TestParser();
55
+
56
+        parser.injectConnectionStrings();
57
+        parser.injectLine(":nick JOIN #DMDirc_testing");
58
+        parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser @+nick2 nick3");
59
+        parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
60
+        parser.injectLine(":luser!lu@ser.com NICK foobar");
61
+
62
+        assertNotNull(parser.getClientInfo("foobar"));
63
+        assertNull(parser.getClientInfo("luser"));
64
+        assertEquals(1, parser.getClientInfo("foobar").getChannelClients().size());
65
+
66
+        ChannelClientInfo cci = parser.getClientInfo("foobar").getChannelClients().get(0);
67
+        assertEquals(parser.getChannelInfo("#DMDirc_testing"), cci.getChannel());
68
+        assertEquals("+", cci.getChanModeStr(true));
69
+    }    
70
+    
71
+    @Test @Ignore
72
+    public void testOverrideNick() throws CallbackNotFoundException {
73
+        final TestParser parser = new TestParser();
74
+        final TestIErrorInfo info = new TestIErrorInfo();
75
+        
76
+        parser.getCallbackManager().addCallback("OnErrorInfo", info);
77
+        parser.injectConnectionStrings();
78
+        parser.injectLine(":nick JOIN #DMDirc_testing");
79
+        parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser @+nick2 nick3");
80
+        parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
81
+        parser.injectLine(":luser!lu@ser.com NICK nick3");
82
+
83
+        assertTrue("Parser should raise an error if a nick change overrides an "
84
+                + "existing client", info.error);
85
+    }    
86
+    
87
+    public static junit.framework.Test suite() {
88
+        return new junit.framework.JUnit4TestAdapter(ProcessNickTest.class);
89
+    }
90
+
91
+}

Loading…
Cancel
Save