1
2
3
4
5 package oshi.driver.windows.perfmon;
6
7 import static org.hamcrest.MatcherAssert.assertThat;
8 import static org.hamcrest.Matchers.greaterThan;
9 import static org.hamcrest.Matchers.lessThan;
10
11 import org.junit.jupiter.api.Test;
12 import org.junit.jupiter.api.condition.EnabledOnOs;
13 import org.junit.jupiter.api.condition.OS;
14
15 import oshi.util.Util;
16
17 @EnabledOnOs(OS.WINDOWS)
18 class LoadAverageTest {
19
20 @Test
21 void testQueryLoadAverage() {
22 double[] loadAverage = LoadAverage.queryLoadAverage(3);
23 assertThat("1m load average should be negative", loadAverage[0], lessThan(0d));
24 assertThat("5m load average should be negative", loadAverage[1], lessThan(0d));
25 assertThat("15m load average should be negative", loadAverage[2], lessThan(0d));
26 LoadAverage.startDaemon();
27 Util.sleep(11000L);
28 loadAverage = LoadAverage.queryLoadAverage(3);
29 assertThat("1m load average should be positive", loadAverage[0], greaterThan(0d));
30 assertThat("5m load average should be positive", loadAverage[1], greaterThan(0d));
31 assertThat("15m load average should be positive", loadAverage[2], greaterThan(0d));
32 LoadAverage.stopDaemon();
33 }
34 }