### Question:
SakuliPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer { protected void addPropertiesFromFile(Properties props, String filePath, boolean active) { if (active) { logger.info("read in properties from '{}'", filePath); try { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(filePath); Iterator<String> keyIt = propertiesConfiguration.getKeys(); while (keyIt.hasNext()) { String key = keyIt.next(); Object value = propertiesConfiguration.getProperty(key); props.put(key, value); } } catch (ConfigurationException | NullPointerException e) { throw new RuntimeException("Error by reading the property file '" + filePath + "'", e); } } } SakuliPropertyPlaceholderConfigurer(); static void assignEncryptionProperties(Properties props); Properties getPropsRef(); @PreDestroy void restoreProperties(); boolean isLoadSakuliDefaultProperties(); void setLoadSakuliDefaultProperties(boolean loadSakuliDefaultProperties); boolean isLoadSakuliProperties(); void setLoadSakuliProperties(boolean loadSakuliProperties); boolean isLoadTestSuiteProperties(); void setLoadTestSuiteProperties(boolean loadTestSuiteProperties); boolean isWritePropertiesToSahiConfig(); void setWritePropertiesToSahiConfig(boolean writePropertiesToSahiConfig); static String ENCRYPTION_KEY_VALUE; static String TEST_SUITE_FOLDER_VALUE; static String SAKULI_HOME_FOLDER_VALUE; static String SAHI_HOME_VALUE; static String TEST_SUITE_BROWSER; static String ENCRYPTION_INTERFACE_VALUE; }### Answer:
@Test public void testAddPropertiesFromFile() throws Exception { Path sakuliPropFile = Paths.get(getClass().getResource("/JUnit-sakuli.properties").toURI()); assertTrue(Files.exists(sakuliPropFile)); Properties props = new Properties(); testling.addPropertiesFromFile(props, sakuliPropFile.toAbsolutePath().toString(), true); assertTrue(props.size() > 0); assertEquals(props.getProperty(ActionProperties.TAKE_SCREENSHOTS), "true", "assert of property " + ActionProperties.TAKE_SCREENSHOTS); }
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "Error by reading the property file '.*invalid.properties'") public void testAddPropertiesFromFileRuntimeException() throws Exception { Properties props = new Properties(); testling.addPropertiesFromFile(props, "invalid.properties", true); }