nl.hsac.fitnesse.fixture.util.ProgramResponse 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.util;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* Encapsulates a program call, and its result.
*/
public class ProgramResponse {
private Map environment = Collections.emptyMap();
private File directory = new File(".");
private String command;
private String[] arguments = new String[0];
private Integer exitCode;
private String stdOut = "";
private String stdErr = "";
public void isValid() {
if (exitCode != 0) {
throw new RuntimeException("Exit code was not 0, but: " + exitCode);
}
}
public Map getEnvironment() {
return environment;
}
public void setEnvironment(Map environment) {
this.environment = environment;
}
public File getDirectory() {
return directory;
}
public void setDirectory(File directory) {
this.directory = directory;
}
public void setDirectory(String directory) {
if (directory != null && !StringUtils.isBlank(directory)) {
setDirectory(new File(directory));
} else {
setDirectory(new File("."));
}
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
public String[] getArguments() {
return arguments;
}
public void setArguments(String... arguments) {
this.arguments = arguments;
}
public void setArguments(List arguments) {
String[] argArray = arguments.toArray(new String[arguments.size()]);
setArguments(argArray);
}
public Integer getExitCode() {
return exitCode;
}
public void setExitCode(Integer exitCode) {
this.exitCode = exitCode;
}
public String getStdOut() {
return stdOut;
}
public void setStdOut(String stdOut) {
this.stdOut = stdOut;
}
public String getStdErr() {
return stdErr;
}
public void setStdErr(String stdErr) {
this.stdErr = stdErr;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy