ソースを参照

Remove all stupid TestParser-based tests.

These need to be rewritten as proper unit tests.
pull/79/head
Chris Smith 9年前
コミット
bde70f142c

+ 0
- 127
irc/test/com/dmdirc/harness/parser/TestParser.java ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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
-}

読み込み中…
キャンセル
保存