Переглянути джерело

Merge pull request #50 from csmith/master

Add Process464 test.
pull/52/head
Greg Holmes 9 роки тому
джерело
коміт
4bc39d2b2b

+ 64
- 0
irc/test/com/dmdirc/parser/irc/processors/Process464Test.java Переглянути файл

@@ -0,0 +1,64 @@
1
+/*
2
+ * Copyright (c) 2006-2014 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.parser.common.CallbackManager;
26
+import com.dmdirc.parser.interfaces.callbacks.PasswordRequiredListener;
27
+import com.dmdirc.parser.irc.IRCParser;
28
+import com.dmdirc.parser.irc.ProcessingManager;
29
+
30
+import org.junit.Before;
31
+import org.junit.Test;
32
+import org.junit.runner.RunWith;
33
+import org.mockito.Mock;
34
+import org.mockito.runners.MockitoJUnitRunner;
35
+
36
+import static org.mockito.Matchers.anyObject;
37
+import static org.mockito.Matchers.same;
38
+import static org.mockito.Mockito.verify;
39
+import static org.mockito.Mockito.when;
40
+
41
+@RunWith(MockitoJUnitRunner.class)
42
+public class Process464Test {
43
+
44
+    @Mock private IRCParser parser;
45
+    @Mock private ProcessingManager processingManager;
46
+    @Mock private CallbackManager callbackManager;
47
+    @Mock private PasswordRequiredListener listener;
48
+    private Process464 processor;
49
+
50
+    @Before
51
+    public void setup() {
52
+        when(parser.getCallbackManager()).thenReturn(callbackManager);
53
+        when(callbackManager.getCallback(PasswordRequiredListener.class))
54
+                .thenReturn(listener);
55
+        processor = new Process464(parser, processingManager);
56
+    }
57
+
58
+    @Test
59
+    public void testFiresPasswordListenerOn464() {
60
+        processor.process("464", ":server.com", "464", ":Bad password!");
61
+        verify(listener).onPasswordRequired(same(parser), anyObject());
62
+    }
63
+
64
+}

Завантаження…
Відмінити
Зберегти