Search code examples
unit-testingmulejunit4esbmule-studio

Junit Test to test Http Outbound endpoint in Mule Flow


I have a basic Mule ESB application with a basic flow like: "Http Inbound endpoint (request-response mode) -> logger -> HTTP Outbound Endpoint (request-response mode) -> Java component"

Query: How do I write a junit test case to test the above flow. As can be seen, I have a HTTP Outbound Endpoint (request-response mode) which refers to some big application which does lots of processing and then returns a response. Do I mock this HTTP outbound endpoint? I don't want to test only the HTTP Outbound Endpoint (request-response mode) individually. I want to junit test the flow as a whole.

Thanks in Advance. Jai Shammi Raj Kulkarni


Solution

  • public void httpEndpoint() throws IOException
        {
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet("http://localhost:8085/api/search");
            HttpResponse response = client.execute(httpGet);
            assertNotNull(response);
        }