nl.hsac.fitnesse.fixture.slim.PropertiesFileFixture Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hsac-fitnesse-fixtures Show documentation
Show all versions of hsac-fitnesse-fixtures Show documentation
Fixtures to assist in testing via FitNesse
package nl.hsac.fitnesse.fixture.slim;
import nl.hsac.fitnesse.fixture.util.PropertiesHelper;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
/**
* Deals with .properties files.
*/
public class PropertiesFileFixture extends ValuesFileFixture {
/**
* Adds the properties loaded from the specified file to current values.
*
* @param filename .properties file to load
* @return true when file is loaded
* @throws IOException when unable to load file's content.
*/
@Override
public boolean loadValuesFrom(String filename) {
String propContent = textIn(filename);
PropertiesHelper propHelper = getEnvironment().getPropertiesHelper();
Properties properties = propHelper.parsePropertiesString(propContent);
Map propAsMap = propHelper.convertPropertiesToMap(properties);
getCurrentValues().putAll(propAsMap);
return true;
}
@Override
protected String createContaining(String filename, Map map) {
Properties p = new Properties();
p.putAll(map);
PropertiesHelper propHelper = getEnvironment().getPropertiesHelper();
String fileContent = propHelper.writePropertiesToString(p);
return createContaining(filename, fileContent);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy