Przeglądaj źródła

Fix the URL Catcher plugin tests.

Change-Id: I1c7a931e6db3dceedf21ffb0b681046655765585
Reviewed-on: http://gerrit.dmdirc.com/2684
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Chris Smith 10 lat temu
rodzic
commit
b3bc4cf09b

+ 13
- 17
test/com/dmdirc/addons/urlcatcher/UrlCatcherPluginTest.java Wyświetl plik

@@ -22,40 +22,38 @@
22 22
 
23 23
 package com.dmdirc.addons.urlcatcher;
24 24
 
25
-import com.dmdirc.TestMain;
26 25
 import com.dmdirc.FrameContainer;
27 26
 import com.dmdirc.actions.CoreActionType;
28 27
 import com.dmdirc.config.ConfigManager;
29 28
 import com.dmdirc.config.InvalidIdentityFileException;
30 29
 import com.dmdirc.interfaces.CommandController;
31 30
 import com.dmdirc.ui.messages.Styliser;
32
-import org.junit.BeforeClass;
31
+
32
+import org.junit.Before;
33 33
 import org.junit.Test;
34
+import org.junit.runner.RunWith;
35
+import org.mockito.Mock;
36
+import org.mockito.runners.MockitoJUnitRunner;
34 37
 import static org.junit.Assert.*;
35 38
 import static org.mockito.Mockito.*;
36 39
 
40
+@RunWith(MockitoJUnitRunner.class)
37 41
 public class UrlCatcherPluginTest {
38 42
 
39
-    private static FrameContainer container;
40
-
41
-    @BeforeClass
42
-    public static void setupClass() {
43
-        container = mock(FrameContainer.class);
44
-
45
-        final ConfigManager manager = mock(ConfigManager.class);
43
+    @Mock private FrameContainer container;
44
+    @Mock private ConfigManager manager;
45
+    @Mock private CommandController controller;
46 46
 
47
+    @Before
48
+    public void setupClass() {
47 49
         when(container.getConfigManager()).thenReturn(manager);
48
-
49 50
         final Styliser styliser = new Styliser(container);
50
-
51 51
         when(container.getStyliser()).thenReturn(styliser);
52 52
     }
53 53
 
54 54
     @Test
55 55
     public void testURLCounting() throws InvalidIdentityFileException {
56
-        TestMain.getTestMain();
57
-
58
-        final UrlCatcherPlugin plugin = new UrlCatcherPlugin(mock(CommandController.class));
56
+        final UrlCatcherPlugin plugin = new UrlCatcherPlugin(controller);
59 57
 
60 58
         plugin.processEvent(CoreActionType.CHANNEL_MESSAGE, null,
61 59
                 container, "This is a message - http://www.google.com/ foo");
@@ -70,9 +68,7 @@ public class UrlCatcherPluginTest {
70 68
 
71 69
     @Test
72 70
     public void testURLCatching() throws InvalidIdentityFileException {
73
-        TestMain.getTestMain();
74
-
75
-        final UrlCatcherPlugin plugin = new UrlCatcherPlugin(mock(CommandController.class));
71
+        final UrlCatcherPlugin plugin = new UrlCatcherPlugin(controller);
76 72
 
77 73
         plugin.processEvent(CoreActionType.CHANNEL_MESSAGE, null,
78 74
                 container, "http://www.google.com/ www.example.com foo://bar.baz");

Ładowanie…
Anuluj
Zapisz