VMStatsMonitor extends MBeanStatsMonitor { public float getCpuUsage() { return cpuUsage; } VMStatsMonitor(String name, boolean processCPUTimeAvailable);  VMStatsMonitor(String name); float getCpuUsage(); @Override void handleNotification(StatisticsNotification notification);  }
@Test public void statisticInitialValueShouldBeZeroWhenTheProcessCpuTimeJmxAttributeIsAvailable() { vmStatsMonitor = new VMStatsMonitor(testName.getMethodName(), true); assertThat(vmStatsMonitor).isNotNull(); assertThat(vmStatsMonitor.getCpuUsage()).isEqualTo(0); }
@Test public void statisticInitialValueShouldBeUndefinedWhenTheProcessCpuTimeJmxAttributeIsNotAvailable() { vmStatsMonitor = new VMStatsMonitor(testName.getMethodName(), false); assertThat(vmStatsMonitor).isNotNull(); assertThat(vmStatsMonitor.getCpuUsage()).isEqualTo(VMStatsMonitor.VALUE_NOT_AVAILABLE); }