|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert com.exoftware.exactor.Command
Base class for all commands executed by the framework.
The class provides access to the parameters of the command and the script
which contains the command.
The class extends junit.framework.Assert
so all the assert methods
are available for use.
execute
method.
If the command is responsible for performing a check then the execute
method
should throw an AssertionFailedError
in the event that the check was
unsuccessful, e.g.
public void execute() throws Exception
{
if( !"hello".equals( "goodbye" ) )
throw new AssertionFailedError( "Values not equal" );
}
or using the convenience method,
public void execute() throws Exception
{
assertEquals( "hello", "goodbye" );
}
Constructor Summary | |
Command()
|
Method Summary | |
void |
addParameter(Parameter p)
Add a parameter to the command. |
int |
countParameters()
Returns the number of parameters added to the command. |
void |
execute()
Subclasses should implement this method to perform the actions of their command. |
int |
getLineNumber()
Returns the number of the line in the script where this command is defined. |
java.lang.String |
getName()
Returns the command name for this command. |
Parameter |
getParameter(int index)
Returns the parameter at the specified index. |
Parameter |
getParameter(int index,
java.lang.String defaultValue)
Returns the parameter at the specified index. |
Parameter[] |
getParameters()
Returns all the parameters in this command. |
Script |
getScript()
Returns the script that owns this command. |
boolean |
hasParameters()
Check whether the command has any parameters. |
java.lang.String |
parametersAsString()
Return all parameters as single string for display purposes. |
java.lang.String |
resolveFileRelativeToScriptFile(java.lang.String fileName)
Resolves a filename relative to actual file used to create the script file. |
void |
setLineNumber(int lineNumber)
set the line number of the command in the script. |
void |
setName(java.lang.String name)
Set the name of the command. |
void |
setScript(Script s)
Set the owning script for this command. |
void |
substituteParameters(Parameter[] substitutions)
Substitute the supplied parameters for any placeholder parameters in the command. |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Command()
Method Detail |
public void addParameter(Parameter p) throws java.lang.NullPointerException
p
- the parameter to add.
java.lang.NullPointerException
- if the supplied parameter is null
.public boolean hasParameters()
true
if the command has parameters,
otherwise false
.public int countParameters()
public Parameter getParameter(int index) throws java.lang.IndexOutOfBoundsException
index
- the index of the parameter to return.
java.lang.IndexOutOfBoundsException
- if the command has no parameters, or
if the index is out of range (index < 0 || index >= countParameters()).public Parameter getParameter(int index, java.lang.String defaultValue)
index
- the index of the parameter to return.
new Parameter(defaultValue)
;public Parameter[] getParameters()
public Script getScript()
public void setScript(Script s) throws java.lang.NullPointerException
s
- the script that owns this command.
java.lang.NullPointerException
- if the supplied script is null
.public void execute() throws java.lang.Exception
AssertionFailedError
should be thrown in the
event that the check fails.
By default this method fails with a "Not implemented" message.
java.lang.Exception
- if an error occurs.AssertionFailedError
public int getLineNumber()
public void setLineNumber(int lineNumber)
lineNumber
- the line number of this command.public java.lang.String getName()
public void setName(java.lang.String name)
name
- the name of the command.public void substituteParameters(Parameter[] substitutions) throws java.lang.RuntimeException
$n
,
where n
is the index into the supplied substitutions array.
If n
is not a valid index into the substitutions array then the
parameter is left unchanged.
substitutions
- the array of parameters to use for substitutions.
java.lang.RuntimeException
public java.lang.String parametersAsString()
public java.lang.String resolveFileRelativeToScriptFile(java.lang.String fileName)
fileName
- to be resolved
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |