Browse Source

Start getting rid of stub parser classes

tags/0.6.3m1rc1
Chris Smith 15 years ago
parent
commit
9bcfb0302e

+ 0
- 41
test/com/dmdirc/harness/parser/TestIAwayState.java View File

@@ -1,41 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2009 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.harness.parser;
24
-
25
-import com.dmdirc.parser.irc.IRCParser;
26
-import com.dmdirc.parser.irc.callbacks.interfaces.IAwayState;
27
-
28
-public class TestIAwayState implements IAwayState {
29
-
30
-    public boolean called = false;
31
-    public boolean state = false;
32
-    public String reason = null;
33
-
34
-    public void onAwayState(IRCParser tParser, boolean currentState,
35
-            String reason) {
36
-        this.state = currentState;
37
-        this.reason = reason;
38
-        this.called = true;
39
-    }
40
-
41
-}

+ 0
- 39
test/com/dmdirc/harness/parser/TestIChannelJoin.java View File

@@ -1,39 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2009 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.harness.parser;
24
-
25
-import com.dmdirc.parser.irc.*;
26
-import com.dmdirc.parser.irc.callbacks.interfaces.IChannelJoin;
27
-
28
-public class TestIChannelJoin implements IChannelJoin {
29
-
30
-    public ChannelInfo channel = null;
31
-    
32
-    public ChannelClientInfo client = null;
33
-
34
-    public void onChannelJoin(IRCParser tParser, ChannelInfo cChannel,
35
-            ChannelClientInfo cChannelClient) {
36
-        channel = cChannel;
37
-        client = cChannelClient;
38
-    }
39
-}

+ 0
- 41
test/com/dmdirc/harness/parser/TestIChannelKick.java View File

@@ -1,41 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2009 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.harness.parser;
24
-
25
-import com.dmdirc.parser.irc.*;
26
-import com.dmdirc.parser.irc.callbacks.interfaces.IChannelKick;
27
-
28
-public class TestIChannelKick implements IChannelKick {
29
-
30
-    public ChannelClientInfo cKickedClient = null;
31
-
32
-    public boolean called = false;
33
-
34
-    public void onChannelKick(IRCParser tParser, ChannelInfo cChannel,
35
-                              ChannelClientInfo cKickedClient,
36
-                              ChannelClientInfo cKickedByClient, String sReason,
37
-                              String sKickedByHost) {
38
-        this.cKickedClient = cKickedClient;
39
-        called = true;
40
-    }
41
-}

+ 8
- 6
test/com/dmdirc/parser/irc/IRCParserTest.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.harness.parser.TestIPrivateCTCP;
26 26
 import com.dmdirc.harness.parser.TestParser;
27
-import com.dmdirc.harness.parser.TestIChannelKick;
28 27
 import com.dmdirc.harness.parser.TestIConnectError;
29 28
 import com.dmdirc.harness.parser.TestINoticeAuth;
30 29
 import com.dmdirc.harness.parser.TestINumeric;
@@ -34,14 +33,16 @@ import com.dmdirc.harness.parser.TestIPrivateMessage;
34 33
 import com.dmdirc.harness.parser.TestIPrivateAction;
35 34
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
36 35
 import com.dmdirc.parser.irc.callbacks.interfaces.IAwayState;
36
+import com.dmdirc.parser.irc.callbacks.interfaces.IChannelKick;
37 37
 
38 38
 import java.util.Arrays;
39
-
40 39
 import java.util.List;
40
+
41 41
 import javax.net.ssl.TrustManager;
42 42
 
43 43
 import org.junit.Test;
44 44
 import static org.junit.Assert.*;
45
+import static org.mockito.Mockito.*;
45 46
 
46 47
 public class IRCParserTest {
47 48
 
@@ -430,15 +431,16 @@ public class IRCParserTest {
430 431
     @Test
431 432
     public void testKick() throws CallbackNotFoundException {
432 433
         final TestParser parser = new TestParser();
433
-        final TestIChannelKick ick = new TestIChannelKick();
434
+        final IChannelKick ick = mock(IChannelKick.class);
434 435
         parser.injectConnectionStrings();
435 436
 
436 437
         parser.injectLine(":nick JOIN #D");
437 438
         parser.getCallbackManager().addCallback("onChannelKick", ick, "#D");
438 439
         parser.injectLine(":bar!me@moo KICK #D nick :Bye!");
439
-     
440
-        assertTrue("onChannelKick must be called", ick.called);
441
-        assertNotNull("cKickedClient must not be null", ick.cKickedClient);
440
+
441
+        verify(ick).onChannelKick(same(parser), (ChannelInfo) anyObject(),
442
+                (ChannelClientInfo) anyObject(), (ChannelClientInfo) anyObject(),
443
+                anyString(), anyString());
442 444
     }
443 445
 
444 446
     @Test

+ 5
- 9
test/com/dmdirc/parser/irc/ProcessJoinTest.java View File

@@ -22,13 +22,14 @@
22 22
 
23 23
 package com.dmdirc.parser.irc;
24 24
 
25
-import com.dmdirc.harness.parser.TestIChannelJoin;
26 25
 import com.dmdirc.harness.parser.TestIChannelSelfJoin;
27 26
 import com.dmdirc.harness.parser.TestParser;
28 27
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
28
+import com.dmdirc.parser.irc.callbacks.interfaces.IChannelJoin;
29 29
 
30 30
 import org.junit.Test;
31 31
 import static org.junit.Assert.*;
32
+import static org.mockito.Mockito.*;
32 33
 
33 34
 public class ProcessJoinTest {
34 35
     
@@ -53,7 +54,7 @@ public class ProcessJoinTest {
53 54
     @Test
54 55
     public void testOtherJoinChannel() throws CallbackNotFoundException {
55 56
         final TestParser parser = new TestParser();
56
-        final TestIChannelJoin test = new TestIChannelJoin();
57
+        final IChannelJoin test = mock(IChannelJoin.class);
57 58
 
58 59
         parser.injectConnectionStrings();
59 60
         parser.getCallbackManager().addCallback("onChannelJoin", test);
@@ -61,13 +62,8 @@ public class ProcessJoinTest {
61 62
         parser.injectLine(":nick JOIN #DMDirc_testing");
62 63
         parser.injectLine(":foo!bar@baz JOIN #DMDirc_testing");
63 64
 
64
-        assertNotNull(test.channel);
65
-        assertEquals("#DMDirc_testing", test.channel.getName());
66
-        assertEquals("#DMDirc_testing", test.channel.toString());
67
-        assertSame(parser, test.channel.getParser());
68
-        assertNotNull(parser.getClientInfo("foo"));
69
-        assertSame(test.client.getClient(), parser.getClientInfo("foo"));
70
-        assertTrue(parser.getClientInfo("foo").getChannelClients().contains(test.client));
65
+        verify(test).onChannelJoin(parser, parser.getChannelInfo("#DMDirc_testing"),
66
+                parser.getClientInfo("foo!bar@baz").getChannelClients().get(0));
71 67
     }    
72 68
 
73 69
 }

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

@@ -22,18 +22,18 @@
22 22
 
23 23
 package com.dmdirc.parser.irc;
24 24
 
25
-import com.dmdirc.harness.parser.TestIAwayState;
26 25
 import com.dmdirc.harness.parser.TestParser;
27 26
 import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
27
+import com.dmdirc.parser.irc.callbacks.interfaces.IAwayState;
28 28
 import org.junit.Test;
29
-import static org.junit.Assert.*;
29
+import static org.mockito.Mockito.*;
30 30
 
31 31
 public class ProcessWhoTest {
32 32
 
33 33
     @Test
34 34
     public void testSelfAway() throws CallbackNotFoundException {
35 35
         final TestParser parser = new TestParser();
36
-        final TestIAwayState test = new TestIAwayState();
36
+        final IAwayState test = mock(IAwayState.class);
37 37
         parser.injectConnectionStrings();
38 38
         parser.getCallbackManager().addCallback("OnAwayState", test);
39 39
 
@@ -41,12 +41,11 @@ public class ProcessWhoTest {
41 41
 
42 42
         parser.injectLine(":server 352 nick #DMDirc_testing nick2 host2 server nick2 G@ :0 rn");
43 43
 
44
-        assertFalse(test.called);
44
+        verify(test, never()).onAwayState((IRCParser) anyObject(),anyBoolean(), anyString());
45 45
 
46 46
         parser.injectLine(":server 352 nick #DMDirc_testing nick host server nick G@ :0 rn");
47 47
 
48
-        assertTrue(test.called);
49
-        assertTrue(test.state);
48
+        verify(test).onAwayState(parser, true, "");
50 49
     }
51 50
 
52 51
 }

Loading…
Cancel
Save