瀏覽代碼

Unit test fiddling

Remove unreachable/unused test code

Change-Id: I2bfd2d7d3f37065f218afa09a67c38e4e91e7a10
Reviewed-on: http://gerrit.dmdirc.com/468
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Tested-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3b1
Chris Smith 14 年之前
父節點
當前提交
b3009f3843
共有 2 個文件被更改,包括 10 次插入131 次删除
  1. 6
    122
      test/com/dmdirc/commandparser/CommandTypeTest.java
  2. 4
    9
      test/com/dmdirc/ui/messages/FormatterTest.java

+ 6
- 122
test/com/dmdirc/commandparser/CommandTypeTest.java 查看文件

@@ -21,161 +21,45 @@
21 21
  */
22 22
 package com.dmdirc.commandparser;
23 23
 
24
-import com.dmdirc.Channel;
25
-import com.dmdirc.MessageTarget;
26
-import com.dmdirc.Query;
27
-import com.dmdirc.Server;
28 24
 import com.dmdirc.commandparser.commands.ChannelCommand;
29 25
 import com.dmdirc.commandparser.commands.ChatCommand;
30 26
 import com.dmdirc.commandparser.commands.Command;
31 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
32 28
 import com.dmdirc.commandparser.commands.QueryCommand;
33 29
 import com.dmdirc.commandparser.commands.ServerCommand;
34
-import com.dmdirc.ui.interfaces.InputWindow;
35 30
 import org.junit.Test;
36 31
 import static org.junit.Assert.*;
32
+import static org.mockito.Mockito.*;
37 33
 
38 34
 public class CommandTypeTest {
39 35
 
40 36
     @Test
41 37
     public void testGlobal() {
42
-        final Command command = new GlobalCommand() {
43
-
44
-            @Override
45
-            public void execute(InputWindow origin, boolean isSilent, CommandArguments args) {
46
-                throw new UnsupportedOperationException("Not supported yet.");
47
-            }
48
-
49
-            @Override
50
-            public String getName() {
51
-                throw new UnsupportedOperationException("Not supported yet.");
52
-            }
53
-
54
-            @Override
55
-            public boolean showInHelp() {
56
-                throw new UnsupportedOperationException("Not supported yet.");
57
-            }
58
-
59
-            @Override
60
-            public String getHelp() {
61
-                throw new UnsupportedOperationException("Not supported yet.");
62
-            }
63
-        };
64
-        
38
+        final Command command = mock(GlobalCommand.class);
65 39
         assertEquals(CommandType.TYPE_GLOBAL, CommandType.fromCommand(command));
66 40
     }
67 41
     
68 42
     @Test
69 43
     public void testServer() {
70
-        final Command command = new ServerCommand() {
71
-
72
-            @Override
73
-            public void execute(InputWindow origin, Server server, boolean isSilent, CommandArguments args) {
74
-                throw new UnsupportedOperationException("Not supported yet.");
75
-            }
76
-
77
-            @Override
78
-            public String getName() {
79
-                throw new UnsupportedOperationException("Not supported yet.");
80
-            }
81
-
82
-            @Override
83
-            public boolean showInHelp() {
84
-                throw new UnsupportedOperationException("Not supported yet.");
85
-            }
86
-
87
-            @Override
88
-            public String getHelp() {
89
-                throw new UnsupportedOperationException("Not supported yet.");
90
-            }
91
-        };
92
-        
44
+        final Command command = mock(ServerCommand.class);
93 45
         assertEquals(CommandType.TYPE_SERVER, CommandType.fromCommand(command));
94 46
     }
95 47
     
96 48
     @Test
97 49
     public void testChat() {
98
-        final Command command = new ChatCommand() {
99
-
100
-            @Override
101
-            public String getName() {
102
-                throw new UnsupportedOperationException("Not supported yet.");
103
-            }
104
-
105
-            @Override
106
-            public boolean showInHelp() {
107
-                throw new UnsupportedOperationException("Not supported yet.");
108
-            }
109
-
110
-            @Override
111
-            public String getHelp() {
112
-                throw new UnsupportedOperationException("Not supported yet.");
113
-            }
114
-
115
-            @Override
116
-            public void execute(InputWindow origin, Server server,
117
-                    MessageTarget target, boolean isSilent, CommandArguments args) {
118
-                throw new UnsupportedOperationException("Not supported yet.");
119
-            }
120
-        };
121
-        
50
+        final Command command = mock(ChatCommand.class);
122 51
         assertEquals(CommandType.TYPE_CHAT, CommandType.fromCommand(command));
123 52
     }    
124 53
     
125 54
     @Test
126 55
     public void testChannel() {
127
-        final Command command = new ChannelCommand() {
128
-            @Override
129
-            public String getName() {
130
-                throw new UnsupportedOperationException("Not supported yet.");
131
-            }
132
-
133
-            @Override
134
-            public boolean showInHelp() {
135
-                throw new UnsupportedOperationException("Not supported yet.");
136
-            }
137
-
138
-            @Override
139
-            public String getHelp() {
140
-                throw new UnsupportedOperationException("Not supported yet.");
141
-            }
142
-
143
-            @Override
144
-            public void execute(InputWindow origin, Server server,
145
-                    Channel channel, boolean isSilent, CommandArguments args) {
146
-                throw new UnsupportedOperationException("Not supported yet.");
147
-            }
148
-        };
149
-        
56
+        final Command command = mock(ChannelCommand.class);
150 57
         assertEquals(CommandType.TYPE_CHANNEL, CommandType.fromCommand(command));
151 58
     }
152 59
     
153 60
     @Test
154 61
     public void testQuery() {
155
-        final Command command = new QueryCommand() {
156
-
157
-            @Override
158
-            public String getName() {
159
-                throw new UnsupportedOperationException("Not supported yet.");
160
-            }
161
-
162
-            @Override
163
-            public boolean showInHelp() {
164
-                throw new UnsupportedOperationException("Not supported yet.");
165
-            }
166
-
167
-            @Override
168
-            public String getHelp() {
169
-                throw new UnsupportedOperationException("Not supported yet.");
170
-            }
171
-
172
-            @Override
173
-            public void execute(InputWindow origin, Server server, Query query,
174
-                    boolean isSilent, CommandArguments args) {
175
-                throw new UnsupportedOperationException("Not supported yet.");
176
-            }
177
-        };
178
-        
62
+        final Command command = mock(QueryCommand.class);
179 63
         assertEquals(CommandType.TYPE_QUERY, CommandType.fromCommand(command));
180 64
     }
181 65
     

+ 4
- 9
test/com/dmdirc/ui/messages/FormatterTest.java 查看文件

@@ -51,15 +51,10 @@ public class FormatterTest {
51 51
     
52 52
     @Test
53 53
     public void testCaching() {
54
-        try {
55
-            assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!"));
56
-            assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!", 123, null));
57
-            assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!", 123, null));
58
-            assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!"));
59
-        } catch (Exception ex) {
60
-            ex.printStackTrace();
61
-            assertTrue(false);
62
-        }
54
+        assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!"));
55
+        assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!", 123, null));
56
+        assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!", 123, null));
57
+        assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!"));
63 58
     }
64 59
     
65 60
     @Test

Loading…
取消
儲存