2 * Copyright (c) 2014 Brocade Communications 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.md.sal.dom.broker.impl.jmx;
11 import static org.junit.Assert.assertEquals;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.util.DurationStatsTracker;
17 * Unit tests for CommitStatsMXBeanImpl.
19 * @author Thomas Pantelis
21 public class CommitStatsMXBeanImplTest {
26 DurationStatsTracker commitStatsTracker = new DurationStatsTracker();
27 CommitStatsMXBeanImpl bean =
28 new CommitStatsMXBeanImpl(commitStatsTracker, "Test");
30 commitStatsTracker.addDuration(100);
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));