### Question:
OSUtils { public static Boolean checkResource(double systemCpuLoad, double systemReservedMemory) { double loadAverage = OSUtils.loadAverage(); double availablePhysicalMemorySize = OSUtils.availablePhysicalMemorySize(); if (loadAverage > systemCpuLoad || availablePhysicalMemorySize < systemReservedMemory) { logger.warn("load is too high or availablePhysicalMemorySize(G) is too low, it's availablePhysicalMemorySize(G):{},loadAvg:{}", availablePhysicalMemorySize, loadAverage); return false; } else { return true; } } private  OSUtils(); static double memoryUsage(); static double availablePhysicalMemorySize(); static double totalMemorySize(); static double loadAverage(); static double cpuUsage(); static List<String> getUserList(); static boolean createUser(String userName); static String getGroup(); static String exeCmd(String command); static String exeShell(String[] command); static int getProcessID(); static boolean isMacOS(); static boolean isWindows(); static String getOSName(); static Boolean checkResource(double systemCpuLoad, double systemReservedMemory); static Boolean checkResource(Configuration conf, Boolean isMaster); static final ThreadLocal<Logger> taskLoggerThreadLocal; static final String TWO_DECIMAL; static final double NEGATIVE_ONE; }### Answer:
@Test public void checkResource(){ boolean resource = OSUtils.checkResource(100,0); Assert.assertTrue(resource); resource = OSUtils.checkResource(0,Double.MAX_VALUE); Assert.assertFalse(resource); Configuration configuration = new PropertiesConfiguration(); configuration.setProperty(Constants.MASTER_MAX_CPULOAD_AVG,100); configuration.setProperty(Constants.MASTER_RESERVED_MEMORY,0); resource = OSUtils.checkResource(configuration,true); Assert.assertTrue(resource); configuration.setProperty(Constants.MASTER_MAX_CPULOAD_AVG,0); configuration.setProperty(Constants.MASTER_RESERVED_MEMORY,Double.MAX_VALUE); resource = OSUtils.checkResource(configuration,true); Assert.assertFalse(resource); configuration.setProperty(Constants.WORKER_MAX_CPULOAD_AVG,100); configuration.setProperty(Constants.WORKER_RESERVED_MEMORY,0); resource = OSUtils.checkResource(configuration,false); Assert.assertTrue(resource); configuration.setProperty(Constants.WORKER_MAX_CPULOAD_AVG,0); configuration.setProperty(Constants.WORKER_RESERVED_MEMORY,Double.MAX_VALUE); resource = OSUtils.checkResource(configuration,false); Assert.assertFalse(resource); }