CheckUtilities { public static void checkFileValidity(String filename) throws IOException { File file = new File(filename); if (!file.exists()) { throw new IOException(ExceptionMessageMap.getMessage("020001") + " { filename=[" + filename + "] }"); } }  static void checkFileValidity(String filename); static void checkFileValidity(File file); static void checkIntArgumentGreaterThan(int toCheck, int lowerBound, String variableName); static void checkNullArgument(Object obj, String variableName); static void checkNullListArgument(List<?> list, String variableName); static boolean checkListsEqual(List<?> l1, List<?> l2); static boolean checkObjectsEqual(Object o1, Object o2); static void checkStringArgument(String str, String variableName); static void checkStringListArgument(List<String> str, String variableName); static boolean checkUnorderedListsEqual(List<?> l1, List<?> l2); static void checkIntIndexInListRange(List<?> list, int index); static void checkIntInRange(int index, int start, int end); static void validateListRefType(List<Ref> list, Ref.RefType type, String variableName); static void validateArgumentRefType(Ref name, Ref.RefType type, String variableName); static void checkDirectoryArgument(File fileName, String variableName);  }
@Test public void testCheckFileValidity() { final String unixFileDir = "/tmp/"; final String windowsFileDir = ""; final String filename1 = "bababa.3223.5asdbbw3gni.gagwe"; final String filename2 = "baasdfbj65adaba.sdh3hs2s5y23.5asdbbw3gni.gagwe"; String dirBase = null; if (System.getProperty("os.name").contains("indows")) { dirBase = windowsFileDir; } else { dirBase = unixFileDir; } String fullFilePath = dirBase + filename1; File file = new File(fullFilePath); if (file.exists()) { fullFilePath = dirBase + filename2; file = new File(fullFilePath); if (file.exists()) { assertTrue( "In checking for file validity, the two test filenames are already in existance.", false); } } assertCheckFileValidityIOException(fullFilePath, "020001: File or path does not exist. { filename=[" + fullFilePath + "] }"); try { if (!file.createNewFile()) { assertTrue("Unable to create temporary file to test checkFileValidity", false); } } catch (IOException e) { e.printStackTrace(); assertTrue("Unable to create temporary file to test checkFileValidity", false); } assertCheckFileValidityIsValid(fullFilePath); if (!file.delete()) { assertTrue("Unable to delete temporary file after testing checkFileValidity", false); } }