2 * Copyright (c) 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.openflowplugin.impl.statistics;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Test for {@link TimeCounter}.
20 public class TimeCounterTest {
22 private static final Logger LOG = LoggerFactory.getLogger(TimeCounterTest.class);
23 private TimeCounter timeCounter;
26 public void setUp() throws Exception {
27 timeCounter = new TimeCounter();
31 public void testGetAverageTimeBetweenMarks() throws Exception {
32 Assert.assertEquals(0, timeCounter.getAverageTimeBetweenMarks());
33 timeCounter.markStart();
34 Assert.assertEquals(0, timeCounter.getAverageTimeBetweenMarks());
37 timeCounter.addTimeMark();
38 Assert.assertEquals(2, timeCounter.getAverageTimeBetweenMarks());
41 timeCounter.addTimeMark();
42 Assert.assertEquals(2, timeCounter.getAverageTimeBetweenMarks());
45 timeCounter.addTimeMark();
46 Assert.assertEquals(3, timeCounter.getAverageTimeBetweenMarks());
49 private void zzz(long length) {
52 } catch (InterruptedException e) {
53 LOG.error("processing sleep interrupted", e);