|
@@ -23,6 +23,9 @@ package com.dmdirc.actions;
|
23
|
23
|
|
24
|
24
|
import com.dmdirc.actions.interfaces.ActionType;
|
25
|
25
|
|
|
26
|
+import com.dmdirc.config.IdentityManager;
|
|
27
|
+import com.dmdirc.config.prefs.PreferencesSetting;
|
|
28
|
+import com.dmdirc.config.prefs.PreferencesType;
|
26
|
29
|
import com.dmdirc.util.ConfigFile;
|
27
|
30
|
import com.dmdirc.util.InvalidConfigFileException;
|
28
|
31
|
|
|
@@ -31,11 +34,18 @@ import java.io.IOException;
|
31
|
34
|
import java.util.ArrayList;
|
32
|
35
|
import java.util.Arrays;
|
33
|
36
|
|
|
37
|
+import org.junit.Before;
|
34
|
38
|
import org.junit.Test;
|
35
|
39
|
import static org.junit.Assert.*;
|
36
|
40
|
|
37
|
41
|
public class ActionTest extends junit.framework.TestCase {
|
38
|
42
|
|
|
43
|
+ @Before
|
|
44
|
+ public void setUp() throws Exception {
|
|
45
|
+ IdentityManager.load();
|
|
46
|
+ ActionManager.init();
|
|
47
|
+ }
|
|
48
|
+
|
39
|
49
|
private static Action action;
|
40
|
50
|
|
41
|
51
|
@Test
|
|
@@ -82,8 +92,6 @@ public class ActionTest extends junit.framework.TestCase {
|
82
|
92
|
|
83
|
93
|
@Test
|
84
|
94
|
public void testRead() throws IOException, InvalidConfigFileException {
|
85
|
|
- ActionManager.init();
|
86
|
|
-
|
87
|
95
|
final Action action = new Action("unit-test", "doesn't_exist");
|
88
|
96
|
action.config = new ConfigFile(getClass().getResourceAsStream("action1"));
|
89
|
97
|
action.config.read();
|
|
@@ -99,4 +107,22 @@ public class ActionTest extends junit.framework.TestCase {
|
99
|
107
|
"bar"), action.getConditions().get(1));
|
100
|
108
|
}
|
101
|
109
|
|
|
110
|
+ @Test
|
|
111
|
+ public void testMultipleGroups() throws IOException, InvalidConfigFileException {
|
|
112
|
+ final Action action = new Action("unit-test", "doesn't_exist");
|
|
113
|
+ action.config = new ConfigFile(getClass().getResourceAsStream("action_multisettings"));
|
|
114
|
+ action.config.read();
|
|
115
|
+ action.loadActionFromConfig();
|
|
116
|
+
|
|
117
|
+ assertEquals(1, ActionManager.getGroup("unit-test").getSettings().size());
|
|
118
|
+
|
|
119
|
+ final PreferencesSetting setting = ActionManager.getGroup("unit-test")
|
|
120
|
+ .getSettings().values().iterator().next();
|
|
121
|
+ assertEquals(PreferencesType.TEXT, setting.getType());
|
|
122
|
+ assertEquals("Highlight Regex", setting.getTitle());
|
|
123
|
+ assertEquals("Regex to use to detect a highlight", setting.getHelptext());
|
|
124
|
+ assertEquals("(?i).*(shane|dataforce|Q${SERVER_MYNICKNAME}E|(?<![#A-Z])DF).*",
|
|
125
|
+ setting.getValue());
|
|
126
|
+ }
|
|
127
|
+
|
102
|
128
|
}
|