Browse Source

Get rid of TestInputWindow

tags/0.6.3m1rc1
Chris Smith 15 years ago
parent
commit
3855f821f4

+ 5
- 4
test/com/dmdirc/commandparser/commands/channel/BanTest.java View File

@@ -24,10 +24,11 @@ package com.dmdirc.commandparser.commands.channel;
24 24
 
25 25
 import com.dmdirc.config.IdentityManager;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27
-import com.dmdirc.harness.TestInputWindow;
27
+import com.dmdirc.ui.interfaces.InputWindow;
28
+
28 29
 import org.junit.BeforeClass;
29 30
 import org.junit.Test;
30
-import static org.junit.Assert.*;
31
+import static org.mockito.Mockito.*;
31 32
 
32 33
 public class BanTest {
33 34
 
@@ -40,9 +41,9 @@ public class BanTest {
40 41
 
41 42
     @Test
42 43
     public void testUsage() {
43
-        final TestInputWindow tiw = new TestInputWindow();
44
+        final InputWindow tiw = mock(InputWindow.class);
44 45
         command.execute(tiw, null, null, false, new CommandArguments("/ban"));
45 46
         
46
-        assertTrue(tiw.lines.containsKey("commandUsage"));
47
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
47 48
     }
48 49
 }

+ 9
- 8
test/com/dmdirc/commandparser/commands/channel/SetNickColourTest.java View File

@@ -23,10 +23,11 @@ package com.dmdirc.commandparser.commands.channel;
23 23
 
24 24
 import com.dmdirc.commandparser.CommandArguments;
25 25
 import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.harness.TestInputWindow;
26
+import com.dmdirc.ui.interfaces.InputWindow;
27
+
27 28
 import org.junit.BeforeClass;
28 29
 import org.junit.Test;
29
-import static org.junit.Assert.*;
30
+import static org.mockito.Mockito.*;
30 31
 
31 32
 public class SetNickColourTest {
32 33
 
@@ -39,26 +40,26 @@ public class SetNickColourTest {
39 40
 
40 41
     @Test
41 42
     public void testUsageNoArgs() {
42
-        final TestInputWindow tiw = new TestInputWindow();
43
+        final InputWindow tiw = mock(InputWindow.class);
43 44
         command.execute(tiw, null, null, false, new CommandArguments("/foo"));
44 45
         
45
-        assertTrue(tiw.lines.containsKey("commandUsage"));
46
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
46 47
     }
47 48
     
48 49
     @Test
49 50
     public void testUsageNicklist() {
50
-        final TestInputWindow tiw = new TestInputWindow();
51
+        final InputWindow tiw = mock(InputWindow.class);
51 52
         command.execute(tiw, null, null, false, new CommandArguments("/foo --nicklist"));
52 53
         
53
-        assertTrue(tiw.lines.containsKey("commandUsage"));
54
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
54 55
     }    
55 56
     
56 57
     @Test
57 58
     public void testUsageText() {
58
-        final TestInputWindow tiw = new TestInputWindow();
59
+        final InputWindow tiw = mock(InputWindow.class);
59 60
         command.execute(tiw, null, null, false, new CommandArguments("/foo --text"));
60 61
         
61
-        assertTrue(tiw.lines.containsKey("commandUsage"));
62
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
62 63
     }       
63 64
 
64 65
 }

+ 9
- 6
test/com/dmdirc/commandparser/commands/global/AliasCommandTest.java View File

@@ -23,10 +23,11 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.commandparser.CommandArguments;
25 25
 import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.harness.TestInputWindow;
26
+import com.dmdirc.ui.interfaces.InputWindow;
27
+
27 28
 import org.junit.BeforeClass;
28 29
 import org.junit.Test;
29
-import static org.junit.Assert.*;
30
+import static org.mockito.Mockito.*;
30 31
 
31 32
 public class AliasCommandTest {
32 33
 
@@ -39,18 +40,20 @@ public class AliasCommandTest {
39 40
 
40 41
     @Test
41 42
     public void testUsageNoArgs() {
42
-        final TestInputWindow tiw = new TestInputWindow();
43
+        final InputWindow tiw = mock(InputWindow.class);
44
+
43 45
         command.execute(tiw, false, new CommandArguments("/foo"));
44 46
         
45
-        assertTrue(tiw.lines.containsKey("commandUsage"));
47
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
46 48
     }
47 49
     
48 50
     @Test
49 51
     public void testUsageOneArg() {
50
-        final TestInputWindow tiw = new TestInputWindow();
52
+        final InputWindow tiw = mock(InputWindow.class);
53
+        
51 54
         command.execute(tiw, false, new CommandArguments("/foo --remove"));
52 55
         
53
-        assertTrue(tiw.lines.containsKey("commandUsage"));
56
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
54 57
     }    
55 58
 
56 59
 }

+ 8
- 6
test/com/dmdirc/commandparser/commands/global/DebugTest.java View File

@@ -23,10 +23,10 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.commandparser.CommandArguments;
25 25
 import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.harness.TestInputWindow;
26
+import com.dmdirc.ui.interfaces.InputWindow;
27 27
 import org.junit.BeforeClass;
28 28
 import org.junit.Test;
29
-import static org.junit.Assert.*;
29
+import static org.mockito.Mockito.*;
30 30
 
31 31
 public class DebugTest {
32 32
 
@@ -39,17 +39,19 @@ public class DebugTest {
39 39
 
40 40
     @Test
41 41
     public void testUsage() {
42
-        final TestInputWindow tiw = new TestInputWindow();
42
+        final InputWindow tiw = mock(InputWindow.class);
43
+
43 44
         command.execute(tiw, false, new CommandArguments("/foo"));
44 45
         
45
-        assertTrue(tiw.lines.containsKey("commandUsage"));
46
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
46 47
     }
47 48
     
48 49
     @Test
49 50
     public void testInvalidArg() {
50
-        final TestInputWindow tiw = new TestInputWindow();
51
+        final InputWindow tiw = mock(InputWindow.class);
52
+
51 53
         command.execute(tiw, false, new CommandArguments("/foo flubadee"));
52 54
         
53
-        assertTrue(tiw.lines.containsKey("commandError"));
55
+        verify(tiw).addLine(eq("commandError"), anyString());
54 56
     }    
55 57
 }

+ 7
- 6
test/com/dmdirc/commandparser/commands/global/IfpluginTest.java View File

@@ -23,10 +23,11 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.commandparser.CommandArguments;
25 25
 import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.harness.TestInputWindow;
26
+import com.dmdirc.ui.interfaces.InputWindow;
27
+
27 28
 import org.junit.BeforeClass;
28 29
 import org.junit.Test;
29
-import static org.junit.Assert.*;
30
+import static org.mockito.Mockito.*;
30 31
 
31 32
 public class IfpluginTest {
32 33
 
@@ -39,18 +40,18 @@ public class IfpluginTest {
39 40
 
40 41
     @Test
41 42
     public void testUsageNoArgs() {
42
-        final TestInputWindow tiw = new TestInputWindow();
43
+        final InputWindow tiw = mock(InputWindow.class);
43 44
         command.execute(tiw, false, new CommandArguments("/foo"));
44 45
         
45
-        assertTrue(tiw.lines.containsKey("commandUsage"));
46
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
46 47
     }
47 48
     
48 49
     @Test
49 50
     public void testUsageOneArg() {
50
-        final TestInputWindow tiw = new TestInputWindow();
51
+        final InputWindow tiw = mock(InputWindow.class);
51 52
         command.execute(tiw, false, new CommandArguments("/foo bar"));
52 53
         
53
-        assertTrue(tiw.lines.containsKey("commandUsage"));
54
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
54 55
     }    
55 56
 
56 57
 }

+ 11
- 10
test/com/dmdirc/commandparser/commands/global/NewServerTest.java View File

@@ -23,10 +23,11 @@ package com.dmdirc.commandparser.commands.global;
23 23
 
24 24
 import com.dmdirc.commandparser.CommandArguments;
25 25
 import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.harness.TestInputWindow;
26
+import com.dmdirc.ui.interfaces.InputWindow;
27
+
27 28
 import org.junit.BeforeClass;
28 29
 import org.junit.Test;
29
-import static org.junit.Assert.*;
30
+import static org.mockito.Mockito.*;
30 31
 
31 32
 public class NewServerTest {
32 33
 
@@ -39,34 +40,34 @@ public class NewServerTest {
39 40
 
40 41
     @Test
41 42
     public void testUsageNoArgs() {
42
-        final TestInputWindow tiw = new TestInputWindow();
43
+        final InputWindow tiw = mock(InputWindow.class);
43 44
         command.execute(tiw, false, new CommandArguments("/foo"));
44 45
         
45
-        assertTrue(tiw.lines.containsKey("commandUsage"));
46
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
46 47
     }
47 48
     
48 49
     @Test
49 50
     public void testInvalidPort() {
50
-        final TestInputWindow tiw = new TestInputWindow();
51
+        final InputWindow tiw = mock(InputWindow.class);
51 52
         command.execute(tiw, false, new CommandArguments("/foo foo:abc"));
52 53
         
53
-        assertTrue(tiw.lines.containsKey("commandError"));
54
+        verify(tiw).addLine(eq("commandError"), anyString());
54 55
     }
55 56
     
56 57
     @Test
57 58
     public void testOutOfRangePort1() {
58
-        final TestInputWindow tiw = new TestInputWindow();
59
+        final InputWindow tiw = mock(InputWindow.class);
59 60
         command.execute(tiw, false, new CommandArguments("/foo foo:0"));
60 61
         
61
-        assertTrue(tiw.lines.containsKey("commandError"));
62
+        verify(tiw).addLine(eq("commandError"), anyString());
62 63
     }
63 64
     
64 65
     @Test
65 66
     public void testOutOfRangePort2() {
66
-        final TestInputWindow tiw = new TestInputWindow();
67
+        final InputWindow tiw = mock(InputWindow.class);
67 68
         command.execute(tiw, false, new CommandArguments("/foo foo:65537"));
68 69
         
69
-        assertTrue(tiw.lines.containsKey("commandError"));
70
+        verify(tiw).addLine(eq("commandError"), anyString());
70 71
     }
71 72
 
72 73
 }

+ 11
- 10
test/com/dmdirc/commandparser/commands/server/ChangeServerTest.java View File

@@ -23,10 +23,11 @@ package com.dmdirc.commandparser.commands.server;
23 23
 
24 24
 import com.dmdirc.commandparser.CommandArguments;
25 25
 import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.harness.TestInputWindow;
26
+import com.dmdirc.ui.interfaces.InputWindow;
27
+
27 28
 import org.junit.BeforeClass;
28 29
 import org.junit.Test;
29
-import static org.junit.Assert.*;
30
+import static org.mockito.Mockito.*;
30 31
 
31 32
 public class ChangeServerTest {
32 33
 
@@ -39,34 +40,34 @@ public class ChangeServerTest {
39 40
 
40 41
     @Test
41 42
     public void testUsageNoArgs() {
42
-        final TestInputWindow tiw = new TestInputWindow();
43
+        final InputWindow tiw = mock(InputWindow.class);
43 44
         command.execute(tiw, null, false, new CommandArguments("/server"));
44 45
         
45
-        assertTrue(tiw.lines.containsKey("commandUsage"));
46
+        verify(tiw).addLine(eq("commandUsage"), anyChar(), anyString(), anyString());
46 47
     }
47 48
     
48 49
     @Test
49 50
     public void testInvalidPort() {
50
-        final TestInputWindow tiw = new TestInputWindow();
51
+        final InputWindow tiw = mock(InputWindow.class);
51 52
         command.execute(tiw, null, false, new CommandArguments("/server foo:abc"));
52 53
         
53
-        assertTrue(tiw.lines.containsKey("commandError"));
54
+        verify(tiw).addLine(eq("commandError"), anyString());
54 55
     }
55 56
     
56 57
     @Test
57 58
     public void testOutOfRangePort1() {
58
-        final TestInputWindow tiw = new TestInputWindow();
59
+        final InputWindow tiw = mock(InputWindow.class);
59 60
         command.execute(tiw, null, false, new CommandArguments("/server foo:0"));
60 61
         
61
-        assertTrue(tiw.lines.containsKey("commandError"));
62
+        verify(tiw).addLine(eq("commandError"), anyString());
62 63
     }
63 64
     
64 65
     @Test
65 66
     public void testOutOfRangePort2() {
66
-        final TestInputWindow tiw = new TestInputWindow();
67
+        final InputWindow tiw = mock(InputWindow.class);
67 68
         command.execute(tiw, null, false,new CommandArguments("/server foo:65537"));
68 69
         
69
-        assertTrue(tiw.lines.containsKey("commandError"));
70
+        verify(tiw).addLine(eq("commandError"), anyString());
70 71
     }
71 72
 
72 73
 }

+ 0
- 42
test/com/dmdirc/harness/TestInputWindow.java View File

@@ -1,42 +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;
24
-
25
-import com.dmdirc.addons.ui_dummy.DummyInputWindow;
26
-import com.dmdirc.ui.interfaces.InputWindow;
27
-import com.dmdirc.util.MapList;
28
-
29
-public class TestInputWindow extends DummyInputWindow implements InputWindow {
30
-    
31
-    public MapList<String, Object[]> lines = new MapList<String, Object[]>();
32
-
33
-    public TestInputWindow() {
34
-        super(null, null);
35
-    }
36
-
37
-    @Override
38
-    public void addLine(String messageType, Object... args) {
39
-        lines.add(messageType, args);
40
-    }
41
-
42
-}

Loading…
Cancel
Save