瀏覽代碼

Unit test issue 1734

git-svn-id: http://svn.dmdirc.com/trunk@4737 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6.3m1rc1
Chris Smith 16 年之前
父節點
當前提交
0382f0423e
共有 2 個文件被更改,包括 57 次插入2 次删除
  1. 28
    2
      test/com/dmdirc/actions/ActionTest.java
  2. 29
    0
      test/com/dmdirc/actions/action_multisettings

+ 28
- 2
test/com/dmdirc/actions/ActionTest.java 查看文件

23
 
23
 
24
 import com.dmdirc.actions.interfaces.ActionType;
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
 import com.dmdirc.util.ConfigFile;
29
 import com.dmdirc.util.ConfigFile;
27
 import com.dmdirc.util.InvalidConfigFileException;
30
 import com.dmdirc.util.InvalidConfigFileException;
28
 
31
 
31
 import java.util.ArrayList;
34
 import java.util.ArrayList;
32
 import java.util.Arrays;
35
 import java.util.Arrays;
33
 
36
 
37
+import org.junit.Before;
34
 import org.junit.Test;
38
 import org.junit.Test;
35
 import static org.junit.Assert.*;
39
 import static org.junit.Assert.*;
36
 
40
 
37
 public class ActionTest extends junit.framework.TestCase {
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
     private static Action action;
49
     private static Action action;
40
 
50
 
41
     @Test
51
     @Test
82
 
92
 
83
     @Test
93
     @Test
84
     public void testRead() throws IOException, InvalidConfigFileException {
94
     public void testRead() throws IOException, InvalidConfigFileException {
85
-        ActionManager.init();
86
-
87
         final Action action = new Action("unit-test", "doesn't_exist");
95
         final Action action = new Action("unit-test", "doesn't_exist");
88
         action.config = new ConfigFile(getClass().getResourceAsStream("action1"));
96
         action.config = new ConfigFile(getClass().getResourceAsStream("action1"));
89
         action.config.read();
97
         action.config.read();
99
                 "bar"), action.getConditions().get(1));
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
 }

+ 29
- 0
test/com/dmdirc/actions/action_multisettings 查看文件

1
+# This is a DMDirc configuration file.
2
+# Written on: Mon Jan 14 06:19:51 GMT 2008
3
+
4
+# This section indicates which sections below take key/value
5
+# pairs, rather than a simple list. It should be placed above
6
+# any sections that take key/values.
7
+keysections:
8
+  setting 0
9
+  setting 1
10
+
11
+triggers:
12
+  SERVER_AWAY
13
+
14
+response:
15
+  /away
16
+
17
+setting 0:
18
+  type=TEXT
19
+  setting=highlightregex
20
+  title=Highlight Regex
21
+  tooltip=Regex to use to detect a highlight
22
+  default=(?i).*(shane|dataforce|Q${SERVER_MYNICKNAME}E|(?<![#A-Z])DF).*
23
+
24
+setting 1:
25
+  type=TEXT
26
+  setting=highlightregex
27
+  title=Highlight Regex
28
+  tooltip=Regex to use to detect a highlight
29
+  default=(?i).*(shane|dataforce|Q${SERVER_MYNICKNAME}E|(?<![#A-Z])DF).*

Loading…
取消
儲存