Parcourir la source

Unit test issue 1734

git-svn-id: http://svn.dmdirc.com/trunk@4737 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6.3m1rc1
Chris Smith il y a 16 ans
Parent
révision
0382f0423e

+ 28
- 2
test/com/dmdirc/actions/ActionTest.java Voir le fichier

@@ -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
 }

+ 29
- 0
test/com/dmdirc/actions/action_multisettings Voir le fichier

@@ -0,0 +1,29 @@
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).*

Chargement…
Annuler
Enregistrer