1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.util;
21
22 import org.apache.hadoop.hbase.MediumTests;
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 import static junit.framework.Assert.assertTrue;
27 import static junit.framework.Assert.fail;
28
29
30
31
32
33 @Category(MediumTests.class)
34 public class TestDefaultEnvironmentEdge {
35
36 @Test
37 public void testGetCurrentTimeUsesSystemClock() {
38 DefaultEnvironmentEdge edge = new DefaultEnvironmentEdge();
39 long systemTime = System.currentTimeMillis();
40 long edgeTime = edge.currentTimeMillis();
41 assertTrue("System time must be either the same or less than the edge time",
42 systemTime < edgeTime || systemTime == edgeTime);
43 try {
44 Thread.sleep(1);
45 } catch (InterruptedException e) {
46 fail(e.getMessage());
47 }
48 long secondEdgeTime = edge.currentTimeMillis();
49 assertTrue("Second time must be greater than the first",
50 secondEdgeTime > edgeTime);
51 }
52
53
54 @org.junit.Rule
55 public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
56 new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();
57 }
58