1
2
3
4
5 package oshi.driver.unix.aix;
6
7 import static org.hamcrest.MatcherAssert.assertThat;
8 import static org.hamcrest.Matchers.greaterThan;
9 import static org.hamcrest.Matchers.greaterThanOrEqualTo;
10 import static org.hamcrest.Matchers.lessThan;
11 import static org.hamcrest.Matchers.lessThanOrEqualTo;
12
13 import org.junit.jupiter.api.Test;
14 import org.junit.jupiter.api.condition.EnabledOnOs;
15 import org.junit.jupiter.api.condition.OS;
16
17 @EnabledOnOs(OS.AIX)
18 class UptimeAndBootTimeTest {
19 @Test
20 void testQueryBootTime() {
21 long msSinceEpoch = Who.queryBootTime();
22
23 assertThat("Boot time should be after the epoch", msSinceEpoch, greaterThanOrEqualTo(0L));
24 assertThat("Boot time should be before now", msSinceEpoch, lessThan(System.currentTimeMillis()));
25
26 long msSinceBoot = Uptime.queryUpTime();
27 assertThat("Up time should be positive", msSinceBoot, greaterThan(0L));
28 assertThat("Boot time plus uptime should be just before now", msSinceBoot + msSinceEpoch,
29 lessThanOrEqualTo(System.currentTimeMillis()));
30 }
31 }