
net.sf.testium.systemundertest.RestartSutCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of standard-sut-control-plugin Show documentation
Show all versions of standard-sut-control-plugin Show documentation
Standard SUT Control Plugin for the Testium Executor
The newest version!
/**
*
*/
package net.sf.testium.systemundertest;
import java.io.File;
import java.io.FileNotFoundException;
import net.sf.testium.configuration.SutControlConfiguration;
import net.sf.testium.executor.TestStepCommandExecutor;
import org.testtoolinterfaces.testresult.TestResult.VERDICT;
import org.testtoolinterfaces.testresult.TestStepResult;
import org.testtoolinterfaces.testresult.impl.TestStepCommandResultImpl;
import org.testtoolinterfaces.testsuite.ParameterArrayList;
import org.testtoolinterfaces.testsuite.TestStepCommand;
import org.testtoolinterfaces.testsuite.TestSuiteException;
import org.testtoolinterfaces.utils.RunTimeData;
import org.testtoolinterfaces.utils.Trace;
/**
* @author arjan.kranenburg
*
* Simple class for restarting the System Under Test.
*/
public final class RestartSutCommand implements TestStepCommandExecutor
{
private static final String myAction = "restart";
private SutControlConfiguration myConfig;
private TestStepCommandExecutor myStartCommand;
private TestStepCommandExecutor myStopCommand;
private StandardSutControl mySutControl;
/**
* @param SutControlConfiguration
* @param TestStepCommandExecutor
* @param TestStepCommandExecutor
* @param standardSutControl
*/
public RestartSutCommand( SutControlConfiguration aConfig,
TestStepCommandExecutor aStartCommand,
TestStepCommandExecutor aStopCommand,
StandardSutControl aSutControl )
{
Trace.println( Trace.CONSTRUCTOR );
myConfig = aConfig;
myStartCommand = aStartCommand;
myStopCommand = aStopCommand;
mySutControl = aSutControl;
}
public TestStepResult execute( TestStepCommand aStep,
RunTimeData aVariables,
File aLogDir ) throws TestSuiteException
{
Trace.println( Trace.EXEC );
TestStepResult result = new TestStepCommandResultImpl( aStep );
String param = myConfig.getRestartParameter();
if ( param.isEmpty() )
{
TestStepCommand stopStep = new TestStepCommand( 0,
"Stop Command",
"Stop",
mySutControl,
new ParameterArrayList() );
// TestStepResult stopResult =
myStopCommand.execute(stopStep, aVariables, aLogDir);
TestStepCommand startStep = new TestStepCommand( 0,
"Start Command",
"Start",
mySutControl,
new ParameterArrayList() );
TestStepResult startResult = myStartCommand.execute(startStep, aVariables, aLogDir);
// TODO Combine the 2 results as sub stepResult of the new result
return startResult;
}
else
{
File command = myConfig.getCommand();
File runLog = new File( aLogDir, "sutRestart.log" );
result.addTestLog("sutRestart", "sutRestart.log");
try
{
StandardSutControl.execute(command, param, runLog);
result.setResult(VERDICT.PASSED);
}
catch (FileNotFoundException exc)
{
Trace.print(Trace.UTIL, exc );
result.setResult(VERDICT.FAILED);
result.setComment(exc.getMessage());
}
return result;
}
}
public String getCommand()
{
Trace.println( Trace.GETTER );
return myAction;
}
public boolean verifyParameters( ParameterArrayList aParameters ) throws TestSuiteException
{
Trace.println( Trace.EXEC_PLUS );
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy