Skip to content

Instantly share code, notes, and snippets.

@vinsguru
Created April 30, 2017 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinsguru/d0eb1f6211feb679bf0d05286cdb7868 to your computer and use it in GitHub Desktop.
Save vinsguru/d0eb1f6211feb679bf0d05286cdb7868 to your computer and use it in GitHub Desktop.
public class PropertyReader extends ConfigTestElement implements TestBean, TestStateListener {
private static final Logger log = LoggingManager.getLoggerForClass();
private String propFilePath;
public PropertyReader() {
super();
}
public void testEnded() {
// TODO Auto-generated method stub
}
public void testEnded(String arg0) {
// TODO Auto-generated method stub
}
public void testStarted() {
if (StringUtils.isNotEmpty(getPropFilePath())) {
try {
Path path = Paths.get(getPropFilePath());
if (!path.isAbsolute())
path = Paths.get(FileServer.getFileServer().getBaseDir(), path.toString());
JMeterUtils.getJMeterProperties().load(new FileInputStream(path.toString()));
log.info("Property file reader - loading the properties from " + path);
} catch (FileNotFoundException e) {
log.error(e.getMessage());
} catch (IOException e) {
log.error(e.getMessage());
}
}
}
public void testStarted(String arg0) {
testStarted();
}
/**
* @return the file path
*/
public String getPropFilePath() {
return this.propFilePath;
}
/**
* @param propFilePath the file path to read
*/
public void setPropFilePath(String propFilePath) {
this.propFilePath = propFilePath;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment