Package org.ikasan.testharness.flow.rule
Class IkasanFlowTestRule
- java.lang.Object
-
- org.ikasan.testharness.flow.rule.IkasanFlowTestRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class IkasanFlowTestRule extends java.lang.Object implements org.junit.rules.TestRuleJUnit Rule implementation allowing flow tests to be created and executed using a builder pattern.The underlying Flow will be automatically stopped and checked when the rule is evaluated at the end of the test
- Author:
- Ikasan Development Team
-
-
Constructor Summary
Constructors Constructor Description IkasanFlowTestRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)Applies the basic flow test rules: 1.voidassertIsSatisfied()IkasanFlowTestRuleblockEnd()Close the current block of repeated componentsIkasanFlowTestRuleblockStart()Start a block of repeated componentsIkasanFlowTestRulebroker(java.lang.String name)Expect a brokerIkasanFlowTestRuleconsumer(java.lang.String name)Expect a consumerIkasanFlowTestRuleconverter(java.lang.String name)Expect a converterIkasanFlowTestRulefilter(java.lang.String name)Expect a filtervoidfireScheduledConsumer()Invoke the scheduled consumer via its triggerSchedulerNow methodvoidfireScheduledConsumerSynchronously(org.quartz.JobExecutionContext jobExecutionContext)Invoke the scheduled consumer with a given JobExecutionContext (can be mocked).java.lang.ObjectgetComponent(java.lang.String componentName)Gets component of given name from this flow.<T> TgetComponentConfig(java.lang.String componentName, java.lang.Class<T> classType)Gets configuration of component with given name from this flow.java.lang.StringgetFlowState()IkasanFlowTestRulemultiRecipientRouter(java.lang.String name)Expect a MultiRecipientRoutervoidpauseFlow()Pause a running flow.IkasanFlowTestRuleproducer(java.lang.String name)Expect a producerIkasanFlowTestRulerepeat(int n)Repeat the current block n times;voidresumeFlow()Resume a paused flow.IkasanFlowTestRulerouter(java.lang.String name)Expect a SingleRecipientRouterIkasanFlowTestRulescheduledConsumer(java.lang.String name)Expect a consumerIkasanFlowTestRulesequencer(java.lang.String name)Expect a sequencervoidsleep(long time)Sleep for a bit to let a flow execution completeIkasanFlowTestRulesplitter(java.lang.String name)Expect a splittervoidstartFlow()Setup the flow expectations and start the given flow.voidstartFlow(FlowSubject testHarnessFlowEventListener)Setup the flow expectations and start the given flow.voidstartPauseFlow()Setup the flow expectations and start and pause the given flow.voidstopFlow()voidstopFlowWithAwait(java.lang.String testName, java.lang.String[] stopStates)Stopping flow is asynchronous so this will be more reliable when stopping the flowIkasanFlowTestRuletranslator(java.lang.String name)Expect a translatorIkasanFlowTestRulewithErrorEndState()Indicate the flow end state will be 'stoppedInError', used in negative testingIkasanFlowTestRulewithFlow(org.ikasan.spec.flow.Flow flow)Set the flow which this Rule will check
-
-
-
Method Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)Applies the basic flow test rules: 1. Stop the flow and assert it is stopped; or stoppedInError if withErrorEndState() was called when building 2. Assert the flowTestHarness for component invocation completeness- Specified by:
applyin interfaceorg.junit.rules.TestRule- Parameters:
base- a base Statementdescription- a Description (not used)- Returns:
- a Statement, wrapping the provided instance, that can be evaluated by JUnit
-
withFlow
public IkasanFlowTestRule withFlow(org.ikasan.spec.flow.Flow flow)
Set the flow which this Rule will check- Parameters:
flow- the Flow- Returns:
- this rule
-
withErrorEndState
public IkasanFlowTestRule withErrorEndState()
Indicate the flow end state will be 'stoppedInError', used in negative testing- Returns:
- this rule
-
consumer
public IkasanFlowTestRule consumer(java.lang.String name)
Expect a consumer- Parameters:
name- the consumer name- Returns:
- this rule
-
scheduledConsumer
public IkasanFlowTestRule scheduledConsumer(java.lang.String name)
Expect a consumer- Parameters:
name- the consumer name- Returns:
- this rule
-
splitter
public IkasanFlowTestRule splitter(java.lang.String name)
Expect a splitter- Parameters:
name- the splitter name- Returns:
- this rule
-
converter
public IkasanFlowTestRule converter(java.lang.String name)
Expect a converter- Parameters:
name- the converter name- Returns:
- this rule
-
producer
public IkasanFlowTestRule producer(java.lang.String name)
Expect a producer- Parameters:
name- the producer name- Returns:
- this rule
-
router
public IkasanFlowTestRule router(java.lang.String name)
Expect a SingleRecipientRouter- Parameters:
name- the router name- Returns:
- this rule
-
multiRecipientRouter
public IkasanFlowTestRule multiRecipientRouter(java.lang.String name)
Expect a MultiRecipientRouter- Parameters:
name- the MRR name- Returns:
- this rule
-
translator
public IkasanFlowTestRule translator(java.lang.String name)
Expect a translator- Parameters:
name- the translator name- Returns:
- this rule
-
broker
public IkasanFlowTestRule broker(java.lang.String name)
Expect a broker- Parameters:
name- the broker name- Returns:
- this rule
-
filter
public IkasanFlowTestRule filter(java.lang.String name)
Expect a filter- Parameters:
name- the filter name- Returns:
- this rule
-
sequencer
public IkasanFlowTestRule sequencer(java.lang.String name)
Expect a sequencer- Parameters:
name- the sequencer name- Returns:
- this rule
-
blockStart
public IkasanFlowTestRule blockStart()
Start a block of repeated components- Returns:
- this rule
-
blockEnd
public IkasanFlowTestRule blockEnd()
Close the current block of repeated components- Returns:
- this rule
-
repeat
public IkasanFlowTestRule repeat(int n)
Repeat the current block n times;- Parameters:
n- number of times to repeat the block- Returns:
- this rule
-
fireScheduledConsumer
public void fireScheduledConsumer()
Invoke the scheduled consumer via its triggerSchedulerNow methodThis method executes the underlying Job asynchronously
-
fireScheduledConsumerSynchronously
public void fireScheduledConsumerSynchronously(org.quartz.JobExecutionContext jobExecutionContext)
Invoke the scheduled consumer with a given JobExecutionContext (can be mocked). This method executes synchronously - when the flow finished executing the given task this method will then return.- Parameters:
jobExecutionContext- a JobExecutionContext
-
startFlow
public void startFlow(FlowSubject testHarnessFlowEventListener)
Setup the flow expectations and start the given flow.- Parameters:
testHarnessFlowEventListener- the test harness flow listener
-
startFlow
public void startFlow()
Setup the flow expectations and start the given flow.
-
startPauseFlow
public void startPauseFlow()
Setup the flow expectations and start and pause the given flow.
-
resumeFlow
public void resumeFlow()
Resume a paused flow.
-
pauseFlow
public void pauseFlow()
Pause a running flow.
-
stopFlow
public void stopFlow()
-
stopFlowWithAwait
public void stopFlowWithAwait(java.lang.String testName, java.lang.String[] stopStates)Stopping flow is asynchronous so this will be more reliable when stopping the flow- Parameters:
testName-stopStates-
-
assertIsSatisfied
public void assertIsSatisfied()
-
getFlowState
public java.lang.String getFlowState()
-
getComponent
public java.lang.Object getComponent(java.lang.String componentName)
Gets component of given name from this flow.- Parameters:
componentName- component name to be looked up in flow- Returns:
- component as Object
-
getComponentConfig
public <T> T getComponentConfig(java.lang.String componentName, java.lang.Class<T> classType)Gets configuration of component with given name from this flow.- Parameters:
componentName- component name to be looked up in flowclassType- class Type to configuration object- Returns:
- configuration object casted to T
-
sleep
public void sleep(long time)
Sleep for a bit to let a flow execution complete- Parameters:
time- the number of milliseconds to sleep for
-
-