I am new to mule ESB. I am trying to do integration test for a rest endpoint exposed via mule flow. The following code, hits POST REST endpoint but how can we say the rest params and http method (get or post or delete etc.,) :
MuleClient client = new MuleClient(muleContext);
String payload = "foo";
Map<String, Object> properties = new HashMap<String, Object>();
MuleMessage result = client.send("http://localhost:5000/rest/resource", payload, properties);
Should we set any thing in the payload or properties (Map) that is passed ?
After looking into source code, I am able to set Http method with following properties.,
Example Get Request:
MuleClient client = new MuleClient(muleContext);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("Content-type", "text/plain");
properties.put("Accept", "text/plain");
properties.put("http.method", "GET");
MuleMessage result = client.send("http://localhost:5000/rest/resource?param1=268", null, properties);
Example Post request:
MuleClient client = new MuleClient(muleContext);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("Content-Type", "application/json");
properties.put("http.method", "POST");
String payload = "{...json here...}";
MuleMessage result = client.send("http://localhost:5000/rest/resource", payload, properties);
Hope it helps someone else.,