summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
blob: 35a2210611a9dface8a4ec734bbdef2bb8b9bc6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */
package org.apache.qpid.server.configuration;

import java.util.List;
import java.util.Locale;

import org.apache.commons.configuration.XMLConfiguration;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.util.TestApplicationRegistry;
import org.apache.qpid.test.utils.QpidTestCase;

public class ServerConfigurationTest extends QpidTestCase
{
    private XMLConfiguration _xml = new XMLConfiguration();
    private ServerConfiguration _config ;
    
    public void setUp() throws Exception
    {
        _config = new ServerConfiguration(_xml);
        TestApplicationRegistry instance = new TestApplicationRegistry(_config);
        ApplicationRegistry.initialise(instance);
        _config.initialise();
    }
    
    public void testGetJMXManagementPort() throws Exception
    {
        _config.setJMXManagementPort(23);
        assertEquals(23, _config.getJMXManagementPort());
    }

    public void testSetJMXManagementPort() throws Exception
    {
        _xml.setProperty("management.jmxport", 42);
        _config.initialise();
        assertEquals(42, _config.getJMXManagementPort());
    }

    public void testGetPlatformMbeanserver() throws Exception
    {
        assertTrue(_config.getPlatformMbeanserver());
    }

    public void testSetPlatformMbeanserver() throws Exception
    {
        _xml.setProperty("management.platform-mbeanserver", false);
        _config.initialise();
        assertFalse(_config.getPlatformMbeanserver());
    }

    public void testGetPluginDirectory() throws Exception
    {
        assertNull(_config.getPluginDirectory());
    }

    public void testSetPluginDirectory() throws Exception
    {
        _xml.setProperty("plugin-directory", "/path/to/plugins");
        _config.initialise();
        assertEquals("/path/to/plugins", _config.getPluginDirectory());
    }

    public void testGetCacheDirectory() throws Exception
    {
        assertNull(_config.getCacheDirectory());
    }

    public void testSetCacheDirectory() throws Exception
    {
        _xml.setProperty("cache-directory", "/path/to/cache");
        _config.initialise();
        assertEquals("/path/to/cache", _config.getCacheDirectory());
    }

    public void testGetPrincipalDatabaseNames() throws Exception
    {
        assertEquals(0, _config.getPrincipalDatabaseNames().size());
    }

    public void testSetPrincipalDatabaseNames() throws Exception
    {
        _xml.setProperty("security.principal-databases.principal-database(0).name", "a");
        _xml.setProperty("security.principal-databases.principal-database(1).name", "b");
        _config.initialise();
        List<String> dbs = _config.getPrincipalDatabaseNames();
        assertEquals(2, dbs.size());
        assertEquals("a", dbs.get(0));
        assertEquals("b", dbs.get(1));
    }

    public void testGetPrincipalDatabaseClass() throws Exception
    {
        assertEquals(0, _config.getPrincipalDatabaseClass().size());
    }

    public void testSetPrincipalDatabaseClass() throws Exception
    {
        _xml.setProperty("security.principal-databases.principal-database(0).class", "a");
        _xml.setProperty("security.principal-databases.principal-database(1).class", "b");
        _config.initialise();
        List<String> dbs = _config.getPrincipalDatabaseClass();
        assertEquals(2, dbs.size());
        assertEquals("a", dbs.get(0));
        assertEquals("b", dbs.get(1));
    }

    public void testGetPrincipalDatabaseAttributeNames() throws Exception
    {
        assertEquals(0, _config.getPrincipalDatabaseAttributeNames(1).size());
    }

    public void testSetPrincipalDatabaseAttributeNames() throws Exception
    {
        _xml.setProperty("security.principal-databases.principal-database(0).attributes(0).attribute.name", "a");
        _xml.setProperty("security.principal-databases.principal-database(0).attributes(1).attribute.name", "b");
        _config.initialise();
        List<String> dbs = _config.getPrincipalDatabaseAttributeNames(0);
        assertEquals(2, dbs.size());
        assertEquals("a", dbs.get(0));
        assertEquals("b", dbs.get(1));
    }

    public void testGetPrincipalDatabaseAttributeValues() throws Exception
    {
        assertEquals(0, _config.getPrincipalDatabaseAttributeValues(1).size());
    }

    public void testSetPrincipalDatabaseAttributeValues() throws Exception
    {
        _xml.setProperty("security.principal-databases.principal-database(0).attributes(0).attribute.value", "a");
        _xml.setProperty("security.principal-databases.principal-database(0).attributes(1).attribute.value", "b");
        _config.initialise();
        List<String> dbs = _config.getPrincipalDatabaseAttributeValues(0);
        assertEquals(2, dbs.size());
        assertEquals("a", dbs.get(0));
        assertEquals("b", dbs.get(1));
    }

    public void testGetManagementAccessList() throws Exception
    {
        assertEquals(0, _config.getManagementAccessList().size());
    }

    public void testSetManagementAccessList() throws Exception
    {
        _xml.setProperty("security.jmx.access(0)", "a");
        _xml.setProperty("security.jmx.access(1)", "b");
        _config.initialise();
        List<String> dbs = _config.getManagementAccessList();
        assertEquals(2, dbs.size());
        assertEquals("a", dbs.get(0));
        assertEquals("b", dbs.get(1));
    }

    public void testGetFrameSize() throws Exception
    {
        assertEquals(65536, _config.getFrameSize());
    }

    public void testSetFrameSize() throws Exception
    {
        _xml.setProperty("advanced.framesize", "23");
        _config.initialise();
        assertEquals(23, _config.getFrameSize());
    }

    public void testGetProtectIOEnabled() throws Exception
    {
        assertFalse(_config.getProtectIOEnabled());
    }

    public void testSetProtectIOEnabled() throws Exception
    {
        _xml.setProperty(ServerConfiguration.CONNECTOR_PROTECTIO_ENABLED, true);
        _config.initialise();
        assertTrue(_config.getProtectIOEnabled());
    }

    public void testGetBufferReadLimit() throws Exception
    {
        assertEquals(262144, _config.getBufferReadLimit());
    }

    public void testSetBufferReadLimit() throws Exception
    {
        _xml.setProperty(ServerConfiguration.CONNECTOR_PROTECTIO_READ_BUFFER_LIMIT_SIZE, 23);
        _config.initialise();
        assertEquals(23, _config.getBufferReadLimit());
    }

    public void testGetBufferWriteLimit() throws Exception
    {
        assertEquals(262144, _config.getBufferWriteLimit());
    }

    public void testSetBufferWriteLimit() throws Exception
    {
        _xml.setProperty(ServerConfiguration.CONNECTOR_PROTECTIO_WRITE_BUFFER_LIMIT_SIZE, 23);
        _config.initialise();
        assertEquals(23, _config.getBufferWriteLimit());
    }

    public void testGetStatusEnabled() throws Exception
    {
        assertEquals(ServerConfiguration.DEFAULT_STATUS_UPDATES.equalsIgnoreCase("on"),
                     _config.getStatusUpdatesEnabled());
    }

    public void testSetStatusEnabled() throws Exception
    {
        _xml.setProperty(ServerConfiguration.STATUS_UPDATES, "off");
        _config.initialise();
        assertFalse(_config.getStatusUpdatesEnabled());
    }

    public void testSetStatusEnabledError() throws Exception
    {
        _xml.setProperty(ServerConfiguration.STATUS_UPDATES, "Yes Please");
        _config.initialise();
        assertFalse(_config.getStatusUpdatesEnabled());
    }

    public void testGetSynchedClocks() throws Exception
    {
        assertFalse(_config.getSynchedClocks());
    }

    public void testSetSynchedClocks() throws Exception
    {
        _xml.setProperty("advanced.synced-clocks", true);
        _config.initialise();
        assertTrue(_config.getSynchedClocks());
    }

    public void testGetLocale() throws Exception
    {
        // The Default is what ever the VMs default is
        Locale defaultLocale = Locale.getDefault();

        assertEquals(defaultLocale, _config.getLocale());
    }

    public void testSetLocaleOne() throws Exception
    {
        Locale update = new Locale("es");
        _xml.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es");
        _config.initialise();
        assertEquals(update, _config.getLocale());
    }

    public void testSetLocaleTwo() throws Exception
    {
        Locale update = new Locale("es","ES");
        _xml.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es_ES");
        _config.initialise();
        assertEquals(update, _config.getLocale());
    }

    public void testSetLocaleThree() throws Exception
    {
        Locale update = new Locale("es","ES", "Traditional_WIN");
        _xml.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es_ES_Traditional_WIN");
        _config.initialise();
        assertEquals(update, _config.getLocale());
    }

    public void testGetMsgAuth() throws Exception
    {
        assertFalse(_config.getMsgAuth());
    }

    public void testSetMsgAuth() throws Exception
    {
        _xml.setProperty("security.msg-auth", true);
        _config.initialise();
        assertTrue(_config.getMsgAuth());
    }

    public void testGetJMXPrincipalDatabase() throws Exception
    {
        assertNull(_config.getJMXPrincipalDatabase());
    }

    public void testSetJMXPrincipalDatabase() throws Exception
    {
        _xml.setProperty("security.jmx.principal-database", "a");
        _config.initialise();
        assertEquals("a", _config.getJMXPrincipalDatabase());
    }

    public void testGetManagementKeyStorePath() throws Exception
    {
        assertNull(_config.getManagementKeyStorePath());
    }

    public void testSetManagementKeyStorePath() throws Exception
    {
        _xml.setProperty("management.ssl.keyStorePath", "a");
        _config.initialise();
        assertEquals("a", _config.getManagementKeyStorePath());
    }

    public void testGetManagementSSLEnabled() throws Exception
    {
        assertTrue(_config.getManagementSSLEnabled());
    }

    public void testSetManagementSSLEnabled() throws Exception
    {
        _xml.setProperty("management.ssl.enabled", false);
        _config.initialise();
        assertFalse(_config.getManagementSSLEnabled());
    }

    public void testGetManagementKeyStorePassword() throws Exception
    {
        assertNull(_config.getManagementKeyStorePassword());
    }

    public void testSetManagementKeyStorePassword() throws Exception
    {
        _xml.setProperty("management.ssl.keyStorePassword", "a");
        _config.initialise();
        assertEquals("a", _config.getManagementKeyStorePassword());
    }

    public void testGetQueueAutoRegister() throws Exception
    {
        assertTrue(_config.getQueueAutoRegister());
    }

    public void testSetQueueAutoRegister() throws Exception
    {
        _xml.setProperty("queue.auto_register", false);
        _config.initialise();
        assertFalse(_config.getQueueAutoRegister());
    }

    public void testGetManagementEnabled() throws Exception
    {
        _config.setManagementEnabled(false);
        _config.initialise();
        assertFalse(_config.getManagementEnabled());
    }

    public void testSetManagementEnabled() throws Exception
    {
        _xml.setProperty("management.enabled", false);
        _config.initialise();
        assertFalse(_config.getManagementEnabled());
    }

    public void testGetHeartBeatDelay() throws Exception
    {
        assertEquals(5, _config.getHeartBeatDelay());
    }

    public void testSetHeartBeatDelay() throws Exception
    {
        _xml.setProperty("heartbeat.delay", 23);
        _config.initialise();
        assertEquals(23, _config.getHeartBeatDelay());
    }

    public void testGetHeartBeatTimeout() throws Exception
    {
        assertEquals(2.0, _config.getHeartBeatTimeout());
    }

    public void testSetHeartBeatTimeout() throws Exception
    {
        _xml.setProperty("heartbeat.timeoutFactor", 2.3);
        _config.initialise();
        assertEquals(2.3, _config.getHeartBeatTimeout());
    }

    public void testGetMaximumMessageAge() throws Exception
    {
        assertEquals(0, _config.getMaximumMessageAge());
    }

    public void testSetMaximumMessageAge() throws Exception
    {
        _xml.setProperty("maximumMessageAge", 10L);
        _config.initialise();
        assertEquals(10, _config.getMaximumMessageAge());
    }

    public void testGetMaximumMessageCount() throws Exception
    {
        assertEquals(0, _config.getMaximumMessageCount());
    }

    public void testSetMaximumMessageCount() throws Exception
    {
        _xml.setProperty("maximumMessageCount", 10L);
        _config.initialise();
        assertEquals(10, _config.getMaximumMessageCount());
    }

    public void testGetMaximumQueueDepth() throws Exception
    {
        assertEquals(0, _config.getMaximumQueueDepth());
    }

    public void testSetMaximumQueueDepth() throws Exception
    {
        _xml.setProperty("maximumQueueDepth", 10L);
        _config.initialise();
        assertEquals(10, _config.getMaximumQueueDepth());
    }

    public void testGetMaximumMessageSize() throws Exception
    {
        assertEquals(0, _config.getMaximumMessageSize());
    }

    public void testSetMaximumMessageSize() throws Exception
    {
        _xml.setProperty("maximumMessageSize", 10L);
        _config.initialise();
        assertEquals(10, _config.getMaximumMessageSize());
    }

    public void testGetMinimumAlertRepeatGap() throws Exception
    {
        assertEquals(0, _config.getMinimumAlertRepeatGap());
    }

    public void testSetMinimumAlertRepeatGap() throws Exception
    {
        _xml.setProperty("minimumAlertRepeatGap", 10L);
        _config.initialise();
        assertEquals(10, _config.getMinimumAlertRepeatGap());
    }

    public void testGetProcessors() throws Exception
    {
        assertEquals(4, _config.getProcessors());
    }

    public void testSetProcessors() throws Exception
    {
        _xml.setProperty("connector.processors", 10);
        _config.initialise();
        assertEquals(10, _config.getProcessors());
    }

    public void testGetPort() throws Exception
    {
        assertNotNull(_config.getPorts());
        assertEquals(1, _config.getPorts().size());
        assertEquals("5672", _config.getPorts().get(0));
    }

    public void testSetPort() throws Exception
    {
        _xml.setProperty("connector.port", "10");
        _config.initialise();
        assertNotNull(_config.getPorts());
        assertEquals(1, _config.getPorts().size());
        assertEquals("10", _config.getPorts().get(0));
    }

    public void testGetBind() throws Exception
    {
        assertEquals("*", _config.getBind());
    }

    public void testSetBind() throws Exception
    {
        _xml.setProperty("connector.bind", "a");
        _config.initialise();
        assertEquals("a", _config.getBind());
    }

    public void testGetReceiveBufferSize() throws Exception
    {
        assertEquals(32767, _config.getReceiveBufferSize());
    }

    public void testSetReceiveBufferSize() throws Exception
    {
        _xml.setProperty("connector.socketReceiveBuffer", "23");
        _config.initialise();
        assertEquals(23, _config.getReceiveBufferSize());
    }

    public void testGetWriteBufferSize() throws Exception
    {
        _config.initialise();
        assertEquals(32767, _config.getWriteBufferSize());
    }

    public void testSetWriteBufferSize() throws Exception
    {
        _xml.setProperty("connector.socketWriteBuffer", "23");
        _config.initialise();
        assertEquals(23, _config.getWriteBufferSize());
    }

    public void testGetTcpNoDelay() throws Exception
    {
        assertTrue(_config.getTcpNoDelay());
    }

    public void testSetTcpNoDelay() throws Exception
    {
        _xml.setProperty("connector.tcpNoDelay", false);
        _config.initialise();
        assertFalse(_config.getTcpNoDelay());
    }

    public void testGetEnableExecutorPool() throws Exception
    {
        assertFalse(_config.getEnableExecutorPool());
    }

    public void testSetEnableExecutorPool() throws Exception
    {
        _xml.setProperty("advanced.filterchain[@enableExecutorPool]", true);
        _config.initialise();
        assertTrue(_config.getEnableExecutorPool());
    }

    public void testGetEnablePooledAllocator() throws Exception
    {
        assertFalse(_config.getEnablePooledAllocator());
    }

    public void testSetEnablePooledAllocator() throws Exception
    {
        _xml.setProperty("advanced.enablePooledAllocator", true);
        _config.initialise();
        assertTrue(_config.getEnablePooledAllocator());
    }

    public void testGetEnableDirectBuffers() throws Exception
    {
        assertFalse(_config.getEnableDirectBuffers());
    }

    public void testSetEnableDirectBuffers() throws Exception
    {
        _xml.setProperty("advanced.enableDirectBuffers", true);
        _config.initialise();
        assertTrue(_config.getEnableDirectBuffers());
    }

    public void testGetEnableSSL() throws Exception
    {
        assertFalse(_config.getEnableSSL());
    }

    public void testSetEnableSSL() throws Exception
    {
        _xml.setProperty("connector.ssl.enabled", true);
        _config.initialise();
        assertTrue(_config.getEnableSSL());
    }

    public void testGetSSLOnly() throws Exception
    {
        assertFalse(_config.getSSLOnly());
    }

    public void testSetSSLOnly() throws Exception
    {
        _xml.setProperty("connector.ssl.sslOnly", true);
        _config.initialise();
        assertTrue(_config.getSSLOnly());
    }

    public void testGetSSLPort() throws Exception
    {
        assertEquals(8672, _config.getSSLPort());
    }

    public void testSetSSLPort() throws Exception
    {
        _xml.setProperty("connector.ssl.port", 23);
        _config.initialise();
        assertEquals(23, _config.getSSLPort());
    }

    public void testGetKeystorePath() throws Exception
    {
        assertEquals("none", _config.getKeystorePath());
    }

    public void testSetKeystorePath() throws Exception
    {
        _xml.setProperty("connector.ssl.keystorePath", "a");
        _config.initialise();
        assertEquals("a", _config.getKeystorePath());
    }

    public void testGetKeystorePassword() throws Exception
    {
        assertEquals("none", _config.getKeystorePassword());
    }

    public void testSetKeystorePassword() throws Exception
    {
        _xml.setProperty("connector.ssl.keystorePassword", "a");
        _config.initialise();
        assertEquals("a", _config.getKeystorePassword());
    }

    public void testGetCertType() throws Exception
    {
        assertEquals("SunX509", _config.getCertType());
    }

    public void testSetCertType() throws Exception
    {
        _xml.setProperty("connector.ssl.certType", "a");
        _config.initialise();
        assertEquals("a", _config.getCertType());
    }

    public void testGetQpidNIO() throws Exception
    {
        assertFalse(_config.getQpidNIO());
    }

    public void testSetQpidNIO() throws Exception
    {
        _xml.setProperty("connector.qpidnio", true);
        _config.initialise();
        assertTrue(_config.getQpidNIO());
    }

    public void testGetUseBiasedWrites() throws Exception
    {
        assertFalse(_config.getUseBiasedWrites());
    }

    public void testSetUseBiasedWrites() throws Exception
    {
        _xml.setProperty("advanced.useWriteBiasedPool", true);
        _config.initialise();
        assertTrue(_config.getUseBiasedWrites());
    }

    public void testGetHousekeepingExpiredMessageCheckPeriod() throws Exception
    {
        assertEquals(30000, _config.getHousekeepingCheckPeriod());
    }

    public void testSetHousekeepingExpiredMessageCheckPeriod() throws Exception
    {
        _xml.setProperty("housekeeping.expiredMessageCheckPeriod", 23L);
        _config.initialise();
        assertEquals(23, _config.getHousekeepingCheckPeriod());
        _config.setHousekeepingExpiredMessageCheckPeriod(42L);
        assertEquals(42, _config.getHousekeepingCheckPeriod());
    }
}