|
@@ -74,25 +74,25 @@ public class ConfigFileBackedConfigProviderTest {
|
74
|
74
|
}
|
75
|
75
|
|
76
|
76
|
@Test(expected = InvalidIdentityFileException.class)
|
77
|
|
- public void testNoName() throws IOException, InvalidIdentityFileException {
|
|
77
|
+ public void testNoName() throws Exception {
|
78
|
78
|
new ConfigFileBackedConfigProvider(identityManager,
|
79
|
79
|
jimFsRule.getPath("no-name"), false);
|
80
|
80
|
}
|
81
|
81
|
|
82
|
82
|
@Test(expected = InvalidIdentityFileException.class)
|
83
|
|
- public void testNoTarget() throws IOException, InvalidIdentityFileException {
|
|
83
|
+ public void testNoTarget() throws Exception {
|
84
|
84
|
new ConfigFileBackedConfigProvider(identityManager,
|
85
|
85
|
jimFsRule.getPath("no-target"), false);
|
86
|
86
|
}
|
87
|
87
|
|
88
|
88
|
@Test(expected = InvalidIdentityFileException.class)
|
89
|
|
- public void testInvalidConfigFile() throws IOException, InvalidIdentityFileException {
|
|
89
|
+ public void testInvalidConfigFile() throws Exception {
|
90
|
90
|
new ConfigFileBackedConfigProvider(identityManager,
|
91
|
91
|
jimFsRule.getPath("invalid-config-file"), false);
|
92
|
92
|
}
|
93
|
93
|
|
94
|
94
|
@Test
|
95
|
|
- public void testProfileSimple() throws IOException, InvalidIdentityFileException {
|
|
95
|
+ public void testProfileSimple() throws Exception {
|
96
|
96
|
final ConfigFileBackedConfigProvider provider = getProvider("profile-new");
|
97
|
97
|
assertTrue(provider.isProfile());
|
98
|
98
|
assertEquals("nick1\nnick2\nnick3", provider.getOption("profile", "nicknames"));
|
|
@@ -101,34 +101,33 @@ public class ConfigFileBackedConfigProviderTest {
|
101
|
101
|
}
|
102
|
102
|
|
103
|
103
|
@Test
|
104
|
|
- public void testProfileNonProfileConfig() throws IOException, InvalidIdentityFileException {
|
|
104
|
+ public void testProfileNonProfileConfig() throws Exception {
|
105
|
105
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
106
|
106
|
assertFalse(provider.isProfile());
|
107
|
107
|
}
|
108
|
108
|
|
109
|
109
|
@Test
|
110
|
|
- public void testReadsIrcdTarget() throws IOException, InvalidIdentityFileException {
|
|
110
|
+ public void testReadsIrcdTarget() throws Exception {
|
111
|
111
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
112
|
112
|
assertEquals(ConfigTarget.TYPE.IRCD, provider.getTarget().getType());
|
113
|
113
|
assertEquals("DMDircircd!", provider.getTarget().getData());
|
114
|
114
|
}
|
115
|
115
|
|
116
|
116
|
@Test
|
117
|
|
- public void testReadsServerTarget() throws IOException, InvalidIdentityFileException {
|
|
117
|
+ public void testReadsServerTarget() throws Exception {
|
118
|
118
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-server");
|
119
|
119
|
assertEquals(ConfigTarget.TYPE.SERVER, provider.getTarget().getType());
|
120
|
120
|
assertEquals("test123", provider.getTarget().getData());
|
121
|
121
|
}
|
122
|
122
|
|
123
|
123
|
@Test
|
124
|
|
- public void testSetsOrder() throws IOException, InvalidIdentityFileException {
|
|
124
|
+ public void testSetsOrder() throws Exception {
|
125
|
125
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
126
|
126
|
assertEquals(5000, provider.getTarget().getOrder());
|
127
|
127
|
}
|
128
|
128
|
|
129
|
129
|
@Test
|
130
|
|
- public void testHasOptionPermissiveValidator()
|
131
|
|
- throws IOException, InvalidIdentityFileException {
|
|
130
|
+ public void testHasOptionPermissiveValidator() throws Exception {
|
132
|
131
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
133
|
132
|
assertTrue(provider.hasOption("unit", "test", PERMISSIVE_VALIDATOR));
|
134
|
133
|
assertFalse(provider.hasOption("unit", "untest", PERMISSIVE_VALIDATOR));
|
|
@@ -136,62 +135,60 @@ public class ConfigFileBackedConfigProviderTest {
|
136
|
135
|
}
|
137
|
136
|
|
138
|
137
|
@Test
|
139
|
|
- public void testHasOptionFailingValidator() throws IOException, InvalidIdentityFileException {
|
|
138
|
+ public void testHasOptionFailingValidator() throws Exception {
|
140
|
139
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
141
|
140
|
assertFalse(provider.hasOption("unit", "test", new NumericalValidator(0, 100)));
|
142
|
141
|
}
|
143
|
142
|
|
144
|
143
|
@Test
|
145
|
|
- public void testGetOptionPermissioveValidator()
|
146
|
|
- throws IOException, InvalidIdentityFileException {
|
|
144
|
+ public void testGetOptionPermissioveValidator() throws Exception {
|
147
|
145
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
148
|
146
|
assertEquals("true", provider.getOption("unit", "test", PERMISSIVE_VALIDATOR));
|
149
|
147
|
}
|
150
|
148
|
|
151
|
149
|
@Test
|
152
|
|
- public void testGetOptionFailingValidator() throws IOException, InvalidIdentityFileException {
|
|
150
|
+ public void testGetOptionFailingValidator() throws Exception {
|
153
|
151
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
154
|
152
|
assertNull(provider.getOption("unit", "test", new NumericalValidator(0, 100)));
|
155
|
153
|
}
|
156
|
154
|
|
157
|
155
|
@Test
|
158
|
|
- public void testUnsetOption() throws IOException, InvalidIdentityFileException {
|
|
156
|
+ public void testUnsetOption() throws Exception {
|
159
|
157
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
160
|
158
|
provider.unsetOption("unit", "test");
|
161
|
159
|
assertFalse(provider.hasOption("unit", "test", PERMISSIVE_VALIDATOR));
|
162
|
160
|
}
|
163
|
161
|
|
164
|
162
|
@Test
|
165
|
|
- public void testSetOptionBoolean() throws IOException, InvalidIdentityFileException {
|
|
163
|
+ public void testSetOptionBoolean() throws Exception {
|
166
|
164
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
167
|
165
|
provider.setOption("new", "option", true);
|
168
|
166
|
assertEquals("true", provider.getOption("new", "option", PERMISSIVE_VALIDATOR));
|
169
|
167
|
}
|
170
|
168
|
|
171
|
169
|
@Test
|
172
|
|
- public void testSetOptionInt() throws IOException, InvalidIdentityFileException {
|
|
170
|
+ public void testSetOptionInt() throws Exception {
|
173
|
171
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
174
|
172
|
provider.setOption("new", "option", 1234);
|
175
|
173
|
assertEquals("1234", provider.getOption("new", "option", PERMISSIVE_VALIDATOR));
|
176
|
174
|
}
|
177
|
175
|
|
178
|
176
|
@Test
|
179
|
|
- public void testSetOptionList() throws IOException, InvalidIdentityFileException {
|
|
177
|
+ public void testSetOptionList() throws Exception {
|
180
|
178
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
181
|
179
|
provider.setOption("new", "option", Lists.newArrayList("first", "second"));
|
182
|
180
|
assertEquals("first\nsecond", provider.getOption("new", "option", PERMISSIVE_VALIDATOR));
|
183
|
181
|
}
|
184
|
182
|
|
185
|
183
|
@Test
|
186
|
|
- public void testSetOptionListWithSingleEntry()
|
187
|
|
- throws IOException, InvalidIdentityFileException {
|
|
184
|
+ public void testSetOptionListWithSingleEntry() throws Exception {
|
188
|
185
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
189
|
186
|
provider.setOption("new", "option", Lists.newArrayList("first"));
|
190
|
187
|
assertEquals("first", provider.getOption("new", "option", PERMISSIVE_VALIDATOR));
|
191
|
188
|
}
|
192
|
189
|
|
193
|
190
|
@Test
|
194
|
|
- public void testSaveSimple() throws IOException, InvalidIdentityFileException {
|
|
191
|
+ public void testSaveSimple() throws Exception {
|
195
|
192
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
196
|
193
|
provider.setOption("newdomain", "test123", 47);
|
197
|
194
|
provider.save();
|
|
@@ -207,7 +204,7 @@ public class ConfigFileBackedConfigProviderTest {
|
207
|
204
|
}
|
208
|
205
|
|
209
|
206
|
@Test
|
210
|
|
- public void testFiresSettingChanged() throws IOException, InvalidIdentityFileException {
|
|
207
|
+ public void testFiresSettingChanged() throws Exception {
|
211
|
208
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
212
|
209
|
provider.addListener(changeListener);
|
213
|
210
|
provider.setOption("new", "option", "boo");
|
|
@@ -215,8 +212,7 @@ public class ConfigFileBackedConfigProviderTest {
|
215
|
212
|
}
|
216
|
213
|
|
217
|
214
|
@Test
|
218
|
|
- public void testDoesNotFireSettingChangedIfValueIsSame()
|
219
|
|
- throws IOException, InvalidIdentityFileException {
|
|
215
|
+ public void testDoesNotFireSettingChangedIfValueIsSame() throws Exception {
|
220
|
216
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
221
|
217
|
provider.setOption("new", "option", "boo");
|
222
|
218
|
provider.addListener(changeListener);
|
|
@@ -225,8 +221,7 @@ public class ConfigFileBackedConfigProviderTest {
|
225
|
221
|
}
|
226
|
222
|
|
227
|
223
|
@Test
|
228
|
|
- public void testFiresSettingChangedWhenUnset()
|
229
|
|
- throws IOException, InvalidIdentityFileException {
|
|
224
|
+ public void testFiresSettingChangedWhenUnset() throws Exception {
|
230
|
225
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
231
|
226
|
provider.setOption("new", "option", "boo");
|
232
|
227
|
provider.addListener(changeListener);
|
|
@@ -235,8 +230,7 @@ public class ConfigFileBackedConfigProviderTest {
|
235
|
230
|
}
|
236
|
231
|
|
237
|
232
|
@Test
|
238
|
|
- public void testDoesNotFireSettingChangedIfNonExistantOptionUnset()
|
239
|
|
- throws IOException, InvalidIdentityFileException {
|
|
233
|
+ public void testDoesNotFireSettingChangedIfNonExistantOptionUnset() throws Exception {
|
240
|
234
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
241
|
235
|
provider.addListener(changeListener);
|
242
|
236
|
provider.unsetOption("new", "option");
|
|
@@ -244,8 +238,7 @@ public class ConfigFileBackedConfigProviderTest {
|
244
|
238
|
}
|
245
|
239
|
|
246
|
240
|
@Test
|
247
|
|
- public void testDoesNotFireSettingChangedIfRemoved()
|
248
|
|
- throws IOException, InvalidIdentityFileException {
|
|
241
|
+ public void testDoesNotFireSettingChangedIfRemoved() throws Exception {
|
249
|
242
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
250
|
243
|
provider.addListener(changeListener);
|
251
|
244
|
provider.removeListener(changeListener);
|
|
@@ -254,8 +247,7 @@ public class ConfigFileBackedConfigProviderTest {
|
254
|
247
|
}
|
255
|
248
|
|
256
|
249
|
@Test
|
257
|
|
- public void testReloadLoadsExtraSettings()
|
258
|
|
- throws IOException, InvalidConfigFileException, InvalidIdentityFileException {
|
|
250
|
+ public void testReloadLoadsExtraSettings() throws Exception {
|
259
|
251
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
260
|
252
|
copyFileAndReload(provider);
|
261
|
253
|
assertTrue(provider.hasOption("more", "settings", PERMISSIVE_VALIDATOR));
|
|
@@ -263,16 +255,14 @@ public class ConfigFileBackedConfigProviderTest {
|
263
|
255
|
}
|
264
|
256
|
|
265
|
257
|
@Test
|
266
|
|
- public void testReloadUnsetsMissingSettings()
|
267
|
|
- throws IOException, InvalidConfigFileException, InvalidIdentityFileException {
|
|
258
|
+ public void testReloadUnsetsMissingSettings() throws Exception {
|
268
|
259
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
269
|
260
|
copyFileAndReload(provider);
|
270
|
261
|
assertFalse(provider.hasOption("unit", "test", PERMISSIVE_VALIDATOR));
|
271
|
262
|
}
|
272
|
263
|
|
273
|
264
|
@Test
|
274
|
|
- public void testReloadFiresSettingChangedForChangedOptions()
|
275
|
|
- throws IOException, InvalidConfigFileException, InvalidIdentityFileException {
|
|
265
|
+ public void testReloadFiresSettingChangedForChangedOptions() throws Exception {
|
276
|
266
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
277
|
267
|
provider.addListener(changeListener);
|
278
|
268
|
copyFileAndReload(provider);
|
|
@@ -280,8 +270,7 @@ public class ConfigFileBackedConfigProviderTest {
|
280
|
270
|
}
|
281
|
271
|
|
282
|
272
|
@Test
|
283
|
|
- public void testReloadFiresSettingChangedForNewOptions()
|
284
|
|
- throws IOException, InvalidConfigFileException, InvalidIdentityFileException {
|
|
273
|
+ public void testReloadFiresSettingChangedForNewOptions() throws Exception {
|
285
|
274
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
286
|
275
|
provider.addListener(changeListener);
|
287
|
276
|
copyFileAndReload(provider);
|
|
@@ -292,8 +281,7 @@ public class ConfigFileBackedConfigProviderTest {
|
292
|
281
|
}
|
293
|
282
|
|
294
|
283
|
@Test
|
295
|
|
- public void testReloadFiresSettingChangedForRemovedOptions()
|
296
|
|
- throws IOException, InvalidConfigFileException, InvalidIdentityFileException {
|
|
284
|
+ public void testReloadFiresSettingChangedForRemovedOptions() throws Exception {
|
297
|
285
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
298
|
286
|
provider.addListener(changeListener);
|
299
|
287
|
copyFileAndReload(provider);
|
|
@@ -301,8 +289,7 @@ public class ConfigFileBackedConfigProviderTest {
|
301
|
289
|
}
|
302
|
290
|
|
303
|
291
|
@Test
|
304
|
|
- public void testReloadDoesNotFireSettingChangedForUnchangedOptions()
|
305
|
|
- throws IOException, InvalidConfigFileException, InvalidIdentityFileException {
|
|
292
|
+ public void testReloadDoesNotFireSettingChangedForUnchangedOptions() throws Exception {
|
306
|
293
|
final ConfigFileBackedConfigProvider provider = getProvider("simple-ircd");
|
307
|
294
|
provider.addListener(changeListener);
|
308
|
295
|
copyFileAndReload(provider);
|