Merge "Bug 1666: Fixing the clustering config file issue"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / test / java / org / opendaylight / controller / md / sal / dom / broker / impl / jmx / CommitStatsMXBeanImplTest.java
1 /*
2  * Copyright (c) 2014 Brocade Communications 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.md.sal.dom.broker.impl.jmx;
10
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.util.DurationStatsTracker;
15
16 /**
17  * Unit tests for CommitStatsMXBeanImpl.
18  *
19  * @author Thomas Pantelis
20  */
21 public class CommitStatsMXBeanImplTest {
22
23     @Test
24     public void test() {
25
26         DurationStatsTracker commitStatsTracker = new DurationStatsTracker();
27         CommitStatsMXBeanImpl bean =
28                 new CommitStatsMXBeanImpl(commitStatsTracker, "Test");
29
30         commitStatsTracker.addDuration(100);
31
32         String prefix = "100.0 ns";
33         assertEquals("getTotalCommits", 1L, bean.getTotalCommits());
34         assertEquals("getLongestCommitTime starts with \"" + prefix + "\"", true,
35                      bean.getLongestCommitTime().startsWith("100.0 ns"));
36         assertEquals("getShortestCommitTime starts with \"" + prefix + "\"", true,
37                      bean.getShortestCommitTime().startsWith(prefix));
38         assertEquals("getAverageCommitTime starts with \"" + prefix + "\"", true,
39                      bean.getAverageCommitTime().startsWith(prefix));
40     }
41 }