Hardware { public static long getSizeOfPhysicalMemory() { switch (OperatingSystem.getCurrentOperatingSystem()) { case LINUX: return getSizeOfPhysicalMemoryForLinux(); case WINDOWS: return getSizeOfPhysicalMemoryForWindows(); case MAC_OS: return getSizeOfPhysicalMemoryForMac(); case FREE_BSD: return getSizeOfPhysicalMemoryForFreeBSD(); case UNKNOWN: LOG.error("Cannot determine size of physical memory for unknown operating system"); return -1; default: LOG.error("Unrecognized OS: " + OperatingSystem.getCurrentOperatingSystem()); return -1; } } private  Hardware(); static int getNumberCPUCores(); static long getSizeOfPhysicalMemory();  }
@Test public void testPhysicalMemory() { try { long physMem = Hardware.getSizeOfPhysicalMemory(); assertTrue(physMem >= -1); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }