public class TestContext extends Object
Modifier and Type | Field and Description |
---|---|
protected Map<String,StopTimer> |
timers
Timers registered in test context, that can be stopped
|
protected Map<String,Object> |
variables
Local variables
|
Constructor and Description |
---|
TestContext()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addException(CitrusRuntimeException exception)
Add new exception to the context marking the test as failed.
|
void |
addVariables(Map<String,Object> variablesToSet)
Add several new variables to test context.
|
void |
addVariables(String[] variableNames,
Object[] variableValues)
Add variables to context.
|
void |
clear()
Clears variables in this test context.
|
org.springframework.context.ApplicationContext |
getApplicationContext()
Gets the Spring bean application context.
|
EndpointFactory |
getEndpointFactory()
Gets the endpoint factory.
|
List<CitrusRuntimeException> |
getExceptions()
Gets the value of the exceptions property.
|
FunctionRegistry |
getFunctionRegistry()
Get the current function registry.
|
GlobalMessageConstructionInterceptors |
getGlobalMessageConstructionInterceptors()
Gets the global message construction interceptors.
|
Map<String,Object> |
getGlobalVariables()
Set global variables.
|
MessageListeners |
getMessageListeners()
Gets the message listeners.
|
MessageStore |
getMessageStore()
Gets the value of the messageStore property.
|
MessageValidatorRegistry |
getMessageValidatorRegistry()
Get the message validator registry.
|
NamespaceContextBuilder |
getNamespaceContextBuilder()
Gets the namespace context builder.
|
ReferenceResolver |
getReferenceResolver()
Gets the value of the referenceResolver property.
|
TestListeners |
getTestListeners()
Gets the test listeners.
|
ValidationMatcherRegistry |
getValidationMatcherRegistry()
Get the current validation matcher registry
|
String |
getVariable(String variableExpression)
Gets the value for the given variable expression.
|
<T> T |
getVariable(String variableExpression,
Class<T> type)
Gets typed variable value.
|
Object |
getVariableObject(String variableExpression)
Gets the value for the given variable as object representation.
|
Map<String,Object> |
getVariables()
Getter for test variables in this context.
|
CitrusRuntimeException |
handleError(String testName,
String packageName,
String message,
Exception cause)
Handles error creating a new CitrusRuntimeException and
informs test listeners.
|
boolean |
hasVariables()
Checks if variables are present right now.
|
void |
onInboundMessage(Message receivedMessage)
Informs message listeners if present that inbound message was received.
|
void |
onOutboundMessage(Message message)
Informs message listeners if present that new outbound message is about to be sent.
|
void |
registerTimer(String timerId,
StopTimer timer)
Registers a StopTimer in the test context, so that the associated timer can be stopped later on.
|
String |
replaceDynamicContentInString(String str)
Method replacing variable declarations and place holders as well as
function expressions in a string
|
String |
replaceDynamicContentInString(String str,
boolean enableQuoting)
Method replacing variable declarations and functions in a string, optionally
the variable values get surrounded with single quotes.
|
String |
resolveDynamicValue(String expression)
Checks weather the given expression is a variable or function and resolves the value
accordingly
|
<T> T[] |
resolveDynamicValuesInArray(T[] array)
Replaces variables and functions in array with respective values and
returns the new array representation.
|
<T> List<T> |
resolveDynamicValuesInList(List<T> list)
Replaces variables and functions in a list with respective values and
returns the new list representation.
|
<T> Map<String,T> |
resolveDynamicValuesInMap(Map<String,T> map)
Replaces variables and functions inside a map with respective values and returns a new
map representation.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Sets the Spring bean application context.
|
void |
setEndpointFactory(EndpointFactory endpointFactory)
Sets the endpoint factory.
|
void |
setFunctionRegistry(FunctionRegistry functionRegistry)
Set the function registry.
|
void |
setGlobalMessageConstructionInterceptors(GlobalMessageConstructionInterceptors messageConstructionInterceptors)
Sets the global messsage construction interceptors.
|
void |
setGlobalVariables(GlobalVariables globalVariables)
Get global variables.
|
void |
setMessageListeners(MessageListeners messageListeners)
Set the message listeners.
|
void |
setMessageStore(MessageStore messageStore)
Sets the messageStore property.
|
void |
setMessageValidatorRegistry(MessageValidatorRegistry messageValidatorRegistry)
Set the message validator registry.
|
void |
setNamespaceContextBuilder(NamespaceContextBuilder namespaceContextBuilder)
Sets the namespace context builder.
|
void |
setReferenceResolver(ReferenceResolver referenceResolver)
Sets the referenceResolver property.
|
void |
setTestListeners(TestListeners testListeners)
Set the test listeners.
|
void |
setValidationMatcherRegistry(ValidationMatcherRegistry validationMatcherRegistry)
Set the validation matcher registry
|
void |
setVariable(String variableName,
Object value)
Creates a new variable in this test context with the respective value.
|
void |
setVariables(Map<String,Object> variables)
Setter for test variables in this context.
|
boolean |
stopTimer(String timerId)
Stops the timer matching the supplied id
|
void |
stopTimers()
Stops all timers
|
public String getVariable(String variableExpression)
variableExpression
- expression to search for.CitrusRuntimeException
public <T> T getVariable(String variableExpression, Class<T> type)
T
- variableExpression
- type
- public Object getVariableObject(String variableExpression)
variableExpression
- expression to search for.CitrusRuntimeException
public void setVariable(String variableName, Object value)
variableName
- the name of the new variablevalue
- the new variable valueCitrusRuntimeException
public void addVariables(String[] variableNames, Object[] variableValues)
variableNames
- the variable names to setvariableValues
- the variable values to setpublic void addVariables(Map<String,Object> variablesToSet)
variablesToSet
- the list of variables to set.public <T> Map<String,T> resolveDynamicValuesInMap(Map<String,T> map)
map
- optionally having variable entries.public <T> List<T> resolveDynamicValuesInList(List<T> list)
list
- having optional variable entries.public <T> T[] resolveDynamicValuesInArray(T[] array)
array
- having optional variable entries.public void clear()
public boolean hasVariables()
public String replaceDynamicContentInString(String str)
str
- the string to parse.public String replaceDynamicContentInString(String str, boolean enableQuoting)
str
- the string to parse for variable place holders.enableQuoting
- flag marking surrounding quotes should be added or not.public String resolveDynamicValue(String expression)
expression
- the expression to resolvepublic CitrusRuntimeException handleError(String testName, String packageName, String message, Exception cause)
testName
- packageName
- message
- cause
- public void setVariables(Map<String,Object> variables)
variables
- public Map<String,Object> getVariables()
public void setGlobalVariables(GlobalVariables globalVariables)
globalVariables
- public Map<String,Object> getGlobalVariables()
public void setMessageStore(MessageStore messageStore)
messageStore
- public MessageStore getMessageStore()
public FunctionRegistry getFunctionRegistry()
public void setFunctionRegistry(FunctionRegistry functionRegistry)
functionRegistry
- the functionRegistry to setpublic void setMessageValidatorRegistry(MessageValidatorRegistry messageValidatorRegistry)
messageValidatorRegistry
- the messageValidatorRegistry to setpublic MessageValidatorRegistry getMessageValidatorRegistry()
public ValidationMatcherRegistry getValidationMatcherRegistry()
public void setValidationMatcherRegistry(ValidationMatcherRegistry validationMatcherRegistry)
validationMatcherRegistry
- public MessageListeners getMessageListeners()
public void setMessageListeners(MessageListeners messageListeners)
messageListeners
- public TestListeners getTestListeners()
public void setTestListeners(TestListeners testListeners)
testListeners
- public GlobalMessageConstructionInterceptors getGlobalMessageConstructionInterceptors()
public void setGlobalMessageConstructionInterceptors(GlobalMessageConstructionInterceptors messageConstructionInterceptors)
messageConstructionInterceptors
- public EndpointFactory getEndpointFactory()
public void setEndpointFactory(EndpointFactory endpointFactory)
endpointFactory
- public ReferenceResolver getReferenceResolver()
public void setReferenceResolver(ReferenceResolver referenceResolver)
referenceResolver
- public void setNamespaceContextBuilder(NamespaceContextBuilder namespaceContextBuilder)
namespaceContextBuilder
- public NamespaceContextBuilder getNamespaceContextBuilder()
public org.springframework.context.ApplicationContext getApplicationContext()
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
applicationContext
- public void onInboundMessage(Message receivedMessage)
receivedMessage
- public void onOutboundMessage(Message message)
message
- public void registerTimer(String timerId, StopTimer timer)
timerId
- a unique timer idpublic boolean stopTimer(String timerId)
timerId
- public void stopTimers()
public void addException(CitrusRuntimeException exception)
exception
- public List<CitrusRuntimeException> getExceptions()
Copyright © 2008–2018 ConSol Software GmbH. All rights reserved.