@Test public void testSetFile() { try { assertTrue("E000AB01.THF is an existing file",EdigeoFileFactory.setFile( EdigeoTestUtils.fileName("E000AB01.THF"), "thf", true).exists()); } catch (FileNotFoundException e) { assertFalse(e.getMessage(),true); } try { EdigeoFileFactory.setFile(EdigeoTestUtils.fileName(""), "THF", true); assertFalse(true); } catch (FileNotFoundException e) { assertTrue(e.getMessage(), true); } try { EdigeoFileFactory.setFile(EdigeoTestUtils.fileName("unexistingFile.THF"), "THF", true); assertFalse(true); } catch (FileNotFoundException e) { assertTrue(e.getMessage(), true); } try { EdigeoFileFactory.setFile(EdigeoTestUtils.fileName("E000AB01"), "test", true); assertFalse(true); } catch (FileNotFoundException e) { assertTrue(e.getMessage(), true); } }
public static File setFile(String path, String ext, boolean mustExist) throws FileNotFoundException { File file = new File(path); if (file.isDirectory()) { throw new FileNotFoundException(path + " is a directory"); } if (file.exists()) { return file; } String fName=getEdigeofName(file.getName(),ext); file = file.getParentFile(); file = getFileHandler(file, fName, ext, mustExist); return file; }
EdigeoFileFactory { public static File setFile(String path, String ext, boolean mustExist) throws FileNotFoundException { File file = new File(path); if (file.isDirectory()) { throw new FileNotFoundException(path + " is a directory"); } if (file.exists()) { return file; } String fName=getEdigeofName(file.getName(),ext); file = file.getParentFile(); file = getFileHandler(file, fName, ext, mustExist); return file; } }
EdigeoFileFactory { public static File setFile(String path, String ext, boolean mustExist) throws FileNotFoundException { File file = new File(path); if (file.isDirectory()) { throw new FileNotFoundException(path + " is a directory"); } if (file.exists()) { return file; } String fName=getEdigeofName(file.getName(),ext); file = file.getParentFile(); file = getFileHandler(file, fName, ext, mustExist); return file; } EdigeoFileFactory(); }
EdigeoFileFactory { public static File setFile(String path, String ext, boolean mustExist) throws FileNotFoundException { File file = new File(path); if (file.isDirectory()) { throw new FileNotFoundException(path + " is a directory"); } if (file.exists()) { return file; } String fName=getEdigeofName(file.getName(),ext); file = file.getParentFile(); file = getFileHandler(file, fName, ext, mustExist); return file; } EdigeoFileFactory(); static File setFile(String path, String ext, boolean mustExist); }
EdigeoFileFactory { public static File setFile(String path, String ext, boolean mustExist) throws FileNotFoundException { File file = new File(path); if (file.isDirectory()) { throw new FileNotFoundException(path + " is a directory"); } if (file.exists()) { return file; } String fName=getEdigeofName(file.getName(),ext); file = file.getParentFile(); file = getFileHandler(file, fName, ext, mustExist); return file; } EdigeoFileFactory(); static File setFile(String path, String ext, boolean mustExist);  }