2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.common.actor;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
15 import java.util.concurrent.TimeUnit;
16 import org.junit.Test;
17 import scala.concurrent.duration.FiniteDuration;
19 public class CommonConfigTest {
22 public void testCommonConfigDefaults() {
23 CommonConfig config = new CommonConfig.Builder<>("testsystem").build();
25 assertNotNull(config.getActorSystemName());
26 assertNotNull(config.getMailBoxCapacity());
27 assertNotNull(config.getMailBoxName());
28 assertNotNull(config.getMailBoxPushTimeout());
29 assertNotNull(config.isMetricCaptureEnabled());
33 public void testCommonConfigOverride() {
35 int expectedCapacity = 123;
36 String timeoutValue = "1000ms";
37 CommonConfig config = new CommonConfig.Builder<>("testsystem")
38 .mailboxCapacity(expectedCapacity)
39 .mailboxPushTimeout(timeoutValue)
40 .metricCaptureEnabled(true)
43 assertEquals(expectedCapacity, config.getMailBoxCapacity().intValue());
45 FiniteDuration expectedTimeout = FiniteDuration.create(1000, TimeUnit.MILLISECONDS);
46 assertEquals(expectedTimeout.toMillis(), config.getMailBoxPushTimeout().toMillis());
48 assertTrue(config.isMetricCaptureEnabled());