import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.mule.functional.junit4.MuleArtifactFunctionalTestCase;
import org.mule.tck.junit4.rule.SystemProperty;
public class MyMuleFlowTest extends MuleArtifactFunctionalTestCase {
@Rule
public SystemProperty port = new SystemProperty("http.port", "8082");
@Override
protected String getConfigFile() {
return "my-mule-flow.xml";
}
@Test
public void testHttpFlow() throws Exception {
String url = String.format("http://localhost:%s/api", port.getValue());
String response = request(url);
assertEquals("Hello World", response);
}
private String request(String url) throws Exception {
// perform an HTTP request and return the response
}
}
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="${http.port}" doc:name="HTTP Listener Configuration" />
<flow name="my-mule-flow">
<http:listener config-ref="HTTP_Listener_Configuration" path="api" doc:name="HTTP" />
<set-payload value="Hello World" doc:name="Set Payload" />
</flow>
</mule>