2 * Copyright (c) 2013 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
8 package org.opendaylight.bgpcep.programming;
10 import static org.junit.Assert.assertTrue;
12 import java.math.BigInteger;
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.Nanotime;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public class NanotimeUtilTest {
19 private static final Logger LOG = LoggerFactory.getLogger(NanotimeUtilTest.class);
22 public void testCurrentTime() {
23 assertTrue(NanotimeUtil.currentTime().getValue().toJava().divide(BigInteger.valueOf(1000000)).subtract(
24 BigInteger.valueOf(System.currentTimeMillis())).shortValue() <= 0);
28 public void testNanoTime() throws InterruptedException {
29 final Nanotime nt1 = NanotimeUtil.currentNanoTime();
31 final Nanotime nt2 = NanotimeUtil.currentNanoTime();
33 LOG.debug("Times: {} {}", nt1, nt2);
34 assertTrue(nt1.getValue().compareTo(nt2.getValue()) < 0);