/** * This file was automatically generated by the Mule Development Kit */ #set($D='$') #set($moduleNameLower = "${muleModuleName.toLowerCase()}") #set($moduleGroupIdPath = $groupId.replace(".", "/")) package ${package}; import org.mule.api.MuleEvent; import org.mule.construct.Flow; import org.mule.tck.FunctionalTestCase; import org.mule.tck.AbstractMuleTestCase; import org.junit.Test; public class ${muleModuleName}ExpresionLanguageTest extends FunctionalTestCase { @Override protected String getConfigResources() { return "mule-config.xml"; } @Test public void testFlow() throws Exception { runFlowAndExpectProperty("testFlow", "test1", "Evaluated Expression"); } /** * Run the flow specified by name and assert equality on the expected output * * @param flowName The name of the flow to run * @param expect The expected output */ protected <T> void runFlowAndExpectProperty(String flowName, String propertyName, T expect) throws Exception { Flow flow = lookupFlowConstruct(flowName); MuleEvent event = AbstractMuleTestCase.getTestEvent(null); MuleEvent responseEvent = flow.process(event); assertEquals(expect, responseEvent.getMessage().getOutboundProperty(propertyName)); } /** * Run the flow specified by name using the specified payload and assert * equality on the expected output * * @param flowName The name of the flow to run * @param expect The expected output * @param payload The payload of the input event */ protected <T, U> void runFlowWithPayloadAndExpect(String flowName, T expect, U payload) throws Exception { Flow flow = lookupFlowConstruct(flowName); MuleEvent event = AbstractMuleTestCase.getTestEvent(payload); MuleEvent responseEvent = flow.process(event); assertEquals(expect, responseEvent.getMessage().getPayload()); } /** * Retrieve a flow by name from the registry * * @param name Name of the flow to retrieve */ protected Flow lookupFlowConstruct(String name) { return (Flow) AbstractMuleTestCase.muleContext.getRegistry().lookupFlowConstruct(name); } }