OshiPlatformCache { public void refresh() { wLock.lock(); try { sysInfo = new SystemInfo(); sysInfoCache.clear(); } finally { wLock.unlock(); } } OshiPlatformCache(String feedId, String machineId, String containerId); void refresh(); OperatingSystem getOperatingSystem(); @SuppressWarnings("unchecked") Map<String, OSFileStore> getFileStores(); GlobalMemory getMemory(); CentralProcessor getProcessor(); @SuppressWarnings("unchecked") Map<String, PowerSource> getPowerSources(); Double getPowerSourceMetric(String powerSourceName, ID metricToCollect); Double getProcessorMetric(String processorNumber, ID metricToCollect); Double getFileStoreMetric(String fileStoreNameName, ID metricToCollect); Double getMemoryMetric(ID metricToCollect); Double getOperatingSystemMetric(ID metricId); Double getMetric(PlatformResourceType type, String name, ID metricToCollect); String getMachineId(); String getContainerId();  }
@Test public void testRefresh() { OshiPlatformCache oshi = newOshiPlatformCache(); Object os1 = oshi.getOperatingSystem(); Object mem1 = oshi.getMemory(); Object fs1 = oshi.getFileStores(); Object proc1 = oshi.getProcessor(); Object ps1 = oshi.getPowerSources(); Object os2 = oshi.getOperatingSystem(); Object mem2 = oshi.getMemory(); Object fs2 = oshi.getFileStores(); Object proc2 = oshi.getProcessor(); Object ps2 = oshi.getPowerSources(); Assert.assertSame(os1, os2); Assert.assertSame(mem1, mem2); Assert.assertSame(fs1, fs2); Assert.assertSame(proc1, proc2); Assert.assertSame(ps1, ps2); oshi.refresh(); os2 = oshi.getOperatingSystem(); mem2 = oshi.getMemory(); fs2 = oshi.getFileStores(); proc2 = oshi.getProcessor(); ps2 = oshi.getPowerSources(); Assert.assertNotSame(os1, os2); Assert.assertNotSame(mem1, mem2); Assert.assertNotSame(fs1, fs2); Assert.assertNotSame(proc1, proc2); Assert.assertNotSame(ps1, ps2); }