@Test public void testDataOpenFileNumWhenCreateFileWriter() { if (os.startsWith(MAC_OS_NAME) || os.startsWith(LINUX_OS_NAME)) { for (int i = 0; i < testFileNum; i++) { fileList.add(new File(currDir + testFileName + i)); } totalOpenFileNumBefore = openFileNumUtil .get(OpenFileNumUtil.OpenFileNumStatistics.DATA_OPEN_FILE_NUM); for (File file : fileList) { if (file.exists()) { try { fileWriterList.add(new FileWriter(file)); } catch (IOException e) { LOGGER.error(e.getMessage()); } } else { try { boolean flag = file.createNewFile(); if (!flag) { LOGGER.error( "create test file {} failed when execute testTotalOpenFileNumWhenCreateFileWriter().", file.getPath()); } } catch (IOException e) { LOGGER.error(e.getMessage()); } try { fileWriterList.add(new FileWriter(file)); } catch (IOException e) { LOGGER.error(e.getMessage()); } } } totalOpenFileNumAfter = openFileNumUtil .get(OpenFileNumUtil.OpenFileNumStatistics.DATA_OPEN_FILE_NUM); totalOpenFileNumChange = totalOpenFileNumAfter - totalOpenFileNumBefore; assertEquals(testFileNum, totalOpenFileNumChange); } else { assertEquals(-2, openFileNumUtil.get(OpenFileNumUtil.OpenFileNumStatistics.DATA_OPEN_FILE_NUM)); } }
public int get(OpenFileNumStatistics statistics) { EnumMap<OpenFileNumStatistics, Integer> statisticsMap = getStatisticMap(); return statisticsMap.getOrDefault(statistics, UNKNOWN_STATISTICS_ERROR_CODE); }
OpenFileNumUtil { public int get(OpenFileNumStatistics statistics) { EnumMap<OpenFileNumStatistics, Integer> statisticsMap = getStatisticMap(); return statisticsMap.getOrDefault(statistics, UNKNOWN_STATISTICS_ERROR_CODE); } }
OpenFileNumUtil { public int get(OpenFileNumStatistics statistics) { EnumMap<OpenFileNumStatistics, Integer> statisticsMap = getStatisticMap(); return statisticsMap.getOrDefault(statistics, UNKNOWN_STATISTICS_ERROR_CODE); } private  OpenFileNumUtil(); }
OpenFileNumUtil { public int get(OpenFileNumStatistics statistics) { EnumMap<OpenFileNumStatistics, Integer> statisticsMap = getStatisticMap(); return statisticsMap.getOrDefault(statistics, UNKNOWN_STATISTICS_ERROR_CODE); } private  OpenFileNumUtil(); static OpenFileNumUtil getInstance(); int get(OpenFileNumStatistics statistics); }
OpenFileNumUtil { public int get(OpenFileNumStatistics statistics) { EnumMap<OpenFileNumStatistics, Integer> statisticsMap = getStatisticMap(); return statisticsMap.getOrDefault(statistics, UNKNOWN_STATISTICS_ERROR_CODE); } private  OpenFileNumUtil(); static OpenFileNumUtil getInstance(); int get(OpenFileNumStatistics statistics);  }