private static File getDirectory(String propertyName, String beamRelDefaultPath) { String filePath = System.getProperty(propertyName); if (filePath != null) { return new File(filePath); } return new File(SystemUtils.getBeamHomeDir(), SystemUtils.convertToLocalPath(beamRelDefaultPath)); } }
public void testGetEnvisatTestDataDir() { File file = null; try { file = GlobalTestConfig.getBeamTestDataInputDirectory(); } catch (SecurityException e) { fail("SecurityException not expected"); } assertNotNull(file); System.setProperty(GlobalTestConfig.BEAM_TEST_DATA_INPUT_DIR_PROPERTY_NAME, SystemUtils.convertToLocalPath("C:/envi/test/data/")); try { file = GlobalTestConfig.getBeamTestDataInputDirectory(); } catch (SecurityException e) { fail("SecurityException not expected"); } assertEquals(new File(SystemUtils.convertToLocalPath("C:/envi/test/data/")), file); System.getProperties().remove(GlobalTestConfig.BEAM_TEST_DATA_INPUT_DIR_PROPERTY_NAME); try { file = GlobalTestConfig.getBeamTestDataInputDirectory(); } catch (SecurityException e) { fail("SecurityException not expected"); } final File defaultFile = new File(SystemUtils.getBeamHomeDir(), SystemUtils.convertToLocalPath( GlobalTestConfig.BEAM_TEST_DATA_INPUT_DIR_DEFAULT_PATH)); assertEquals(defaultFile, file); }