Friday, 15 January 2010

java - Testing sub-flows in Mule -



java - Testing sub-flows in Mule -

i have started writing test cases mule project.

i have written functional test case main flows follows.

public void testmainflow_1() throws exception{ muleclient client = mulecontext.getclient(); mulemessage result = client.send(helloserviceaddress, fileasstring("samplepayloads/input_request.xml"), properties); assertnotnull("null result", result); assertequals(result.getpayloadasstring(), fileasstring("sampleresponses/sampleresponse.xml")); }

but how can test sub-flows. don't have end-points. how can pass payload them , test it.

given below flow config.

<flow name="main_flow" > .... .... <flow-ref name="subflow_1" /> .... .... <flow-ref name="subflow_2" /> .... .... </flow> <sub-flow name="subflow_1"> .... <some-transformer ... /> <out-bound phone call web-service /> <some-transformer ... /> .... </sub-flow> <sub-flow name="subflow_2"> .... <some-transformer ... /> <out-bound phone call web-service /> <some-transformer ... /> .... </sub-flow>

using functionaltestcase should simple as:

messageprocessor subflow = mulecontext.getregistry().lookupobject("subflow_1"); muleevent result = subflow.process(gettestevent("test_data"));

but it doesn't work.

for now, best approach imo consists in having test config contains flow wrappers sub-flows want test , load test config alongside main config in functionaltestcase.

@genjosanzo's approach works based on associating sub-flow pre-existing main-flow test code itself. think stricter create test flows instead.

java unit-testing mule functional-testing flow

No comments:

Post a Comment