Fixup checkstyle
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / common / actor / CommonConfigTest.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.common.actor;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14
15 import java.util.concurrent.TimeUnit;
16 import org.junit.Test;
17 import scala.concurrent.duration.FiniteDuration;
18
19 public class CommonConfigTest {
20
21     @Test
22     public void testCommonConfigDefaults() {
23         CommonConfig config = new CommonConfig.Builder<>("testsystem").build();
24
25         assertNotNull(config.getActorSystemName());
26         assertNotNull(config.getMailBoxCapacity());
27         assertNotNull(config.getMailBoxName());
28         assertNotNull(config.getMailBoxPushTimeout());
29         assertNotNull(config.isMetricCaptureEnabled());
30     }
31
32     @Test
33     public void testCommonConfigOverride() {
34
35         int expectedCapacity = 123;
36         String timeoutValue = "1000ms";
37         CommonConfig config = new CommonConfig.Builder<>("testsystem")
38                 .mailboxCapacity(expectedCapacity)
39                 .mailboxPushTimeout(timeoutValue)
40                 .metricCaptureEnabled(true)
41                 .build();
42
43         assertEquals(expectedCapacity, config.getMailBoxCapacity().intValue());
44
45         FiniteDuration expectedTimeout = FiniteDuration.create(1000, TimeUnit.MILLISECONDS);
46         assertEquals(expectedTimeout.toMillis(), config.getMailBoxPushTimeout().toMillis());
47
48         assertTrue(config.isMetricCaptureEnabled());
49     }
50 }