org.finra.jtaf.core.commands
Class ExpectFailure

java.lang.Object
  extended by org.finra.jtaf.core.model.invocationtarget.InvocationTarget
      extended by org.finra.jtaf.core.model.invocationtarget.Command
          extended by org.finra.jtaf.core.commands.ExpectFailure

public class ExpectFailure
extends Command

This command surrounds a block of commands to be executed that are expected to throw an exception. If one of them throws an exception, no more commands from the block are executed and the remainder of the script is run through. If no exception is thrown, an ExpectedFailureException to signify this.


Field Summary
 
Fields inherited from class org.finra.jtaf.core.model.invocationtarget.Command
interpreter, recordResult
 
Fields inherited from class org.finra.jtaf.core.model.invocationtarget.InvocationTarget
globalContext
 
Constructor Summary
ExpectFailure(String name)
          This called when instantiating the command before it is executed by the interpreter.
 
Method Summary
protected  void execute(IInvocationContext ctx)
          This method goes through all of the commands within the ExpectFailure block and executes them until they have all been executed or an exception has been thrown.
 
Methods inherited from class org.finra.jtaf.core.model.invocationtarget.Command
acceptInvocationTargetVisitor, clearContext, deinitialize, executeInvocation, getBooleanOrDefault, getContext, getFloatOrDefault, getIntegerOrDefault, getOptionalObject, getOptionalString, getRequiredBoolean, getRequiredFloat, getRequiredInteger, getRequiredObject, getRequiredString, getStringOrDefault, initialize, launch, recordResult
 
Methods inherited from class org.finra.jtaf.core.model.invocationtarget.InvocationTarget
addOptionalParameter, addProduction, addRequiredParameter, cleanGlobalContext, getAllParameters, getFromGlobalContext, getGlobalContext, getName, getOptionalParameters, getProductions, getRequiredParameters, getUsage, putToGlobalContext, setGlobalContext, setUsage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpectFailure

public ExpectFailure(String name)
              throws NameFormatException
This called when instantiating the command before it is executed by the interpreter. The recordResult variable is set to false because details about the ExpectFailure step aren't needed, unlike the commands within the ExpectFailure block.

Parameters:
name - - The name of the command
Throws:
NameFormatException
Method Detail

execute

protected void execute(IInvocationContext ctx)
                throws Throwable
This method goes through all of the commands within the ExpectFailure block and executes them until they have all been executed or an exception has been thrown. If an exception is thrown and it is not an ExpectedFailureException from a nested ExpectFailure, no more commands in the block are executed and the rest of the script is run. If the exception is an ExpectedFailureException, it is thrown and if no exception is encountered when executing the block, a new ExpectedFailureException is thrown.

Specified by:
execute in class Command
Parameters:
ctx - - The current context when this method is executed.
Throws:
Throwable - - Either a ExpectedFailureException or the exception thrown by a command in the block


Copyright © 2014. All rights reserved.