aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/test/java/com/yahoo/jdisc/core/SystemTimerTestCase.java
blob: 9d6353560bb31b5709f944586546cbad6fed9d4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.core;

import com.google.inject.Guice;
import com.yahoo.jdisc.Timer;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;


/**
 * @author Simon Thoresen Hult
 */
public class SystemTimerTestCase {

    @Test
    void requireThatClassIsInjectedByDefault() {
        Timer timer = Guice.createInjector().getInstance(Timer.class);
        assertTrue(timer instanceof SystemTimer);
    }

    @Test
    void requireThatSystemTimerIsSane() {
        long before = System.currentTimeMillis();
        long millis = new SystemTimer().currentTimeMillis();
        long after = System.currentTimeMillis();

        assertTrue(before <= millis);
        assertTrue(after >= millis);
    }
}