SlideShare a Scribd company logo
JUnit Functional test cases
By: Sudha Chiraboina
 The main motto of this white paper is what
the issues to write test cases using JUnit are
and how to overcome those issues.
 ABSTRACT
1. INTRODUCTION
2. PROBLEM STATEMENT
3. SOLUTION
4. BENEFITS
5. CONCLUSION
6. REFERENCES
7. ABOUT THE AUTHOR
8. ABOUT WHISHWORKS
 We have multiple unit test frameworks to
write unit and functional test cases for our
services. When we write functional test cases
using JUnit we can’t mock mule components.
To resolve this issues we have to use MUnit
and I am going to explain what is the
problem with JUnit and how to resolve using
MUnit in the below.
 When we write functional test cases using JUnit, the test
case will directly connect to original components like SAP,
Salesforce etc. and insert/select the data. It is the issue in
JUnit functional test case why because we are writing
functional test cases to check whether entire functionality
is working as expected or not without modifying the
original components(SAP,Salesforce,Database) data, but in
JUnit functional test cases it is directly connecting to
original components and modifying the original data.
 Examples:
1. SAP Connector
 Mule flow:
 Flow of execution
1. Trigger the service with xml request.
2. Receive the input request and process it.
3. Transform the processed request to SAP IDoc
and push it to SAP.
 Functional test case using JUnit:
 Public void functionalTest(){

 File fXmlFile = new File(request.xml);
 StringBuilder sb = new StringBuilder();
 BufferedReader br = new BufferedReader(new FileReader(fXmlFile));

 String sCurrentLine = new String();
 //Read the data from file and append to string
 while ((sCurrentLine = br.readLine()) != null) {
 sb.append(sCurrentLine);
 }

 DefaultHttpClient httpclient = new DefaultHttpClient();

 HttpPost httppost = new HttpPost(requrl);

 httppost.setEntity(new StringEntity(sb.toString(), "UTF-8"));
 //Trigger the service
 HttpResponse response = httpclient.execute(httppost);

 ----
 ----
 }

 Flow of execution
1. Read the input request from request.xml file.
2. Trigger the service with above request.
3. Process the input request.
4. Transform the processed request to SAP IDoc
and push it to SAP.
 Issue
 Here we are unable to mock the SAP
component so the test case is directly
pushing the IDoc to original SAP.
 NOTE: Not only pushing the IDoc to SAP, at
the time of receiving IDoc from SAP also we
will face same issue.
• 2. Salesforce
• Mule flow
 Flow of execution
1. Trigger the service with xml request.
2. Processes the input request.
3. Create the processed request as customer in
Salesforce.
 Functional Test Case
 Public void functionalTest(){

 File fXmlFile = new File(request.xml);
 StringBuilder sb = new StringBuilder();
 BufferedReader br = new BufferedReader(new FileReader(fXmlFile));

 String sCurrentLine = new String();
 // Read the data from file and append to string
 while ((sCurrentLine = br.readLine()) != null) {
 sb.append(sCurrentLine);
 }

 DefaultHttpClient httpclient = new DefaultHttpClient();

 HttpPost httppost = new HttpPost(requrl);

 httppost.setEntity(new StringEntity(sb.toString(), "UTF-8"));
 //Trigger the service
 HttpResponse response = httpclient.execute(httppost);

 ----
 ----
 }
 Flow of Execution
1. First read the input request from request.xml
file.
2. Trigger the service with above request.
3. Process the input request.
4. Create the customer in salesforce.
 Issue
 Here also we are unable to mock the
Salesforce component so it will connect to
original Salesforce connector and create the
customer on it.
 To resolve the above JUnit functional test
case issue we have a separate framework
called MUnit. MUnit is also one framework
which is used to write test cases as same as
JUnit, but here in MUnit we can mock all
components like SAP, Salesforce, Database
etc. So to overcome the above problem we
can use MUnit to write functional test cases.
 Example
 Mocking Salesforce test case using Munit
 .mflow
 <?xml version="1.0" encoding="UTF-8"?>

 <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
 http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/5.0/mule-sfdc.xsd
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
 http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
 <vm:endpoint exchange-pattern="request-response" path="CREATE_CSTMR_VM" name="CREATE_CSTMR_VM" doc:name="VM"/>
 <vm:endpoint exchange-pattern="request-response" path="INSERT_PERSON_ACT_VM" name="INSERT_PERSON_ACT_VM"
doc:name="VM"/>
 <flow name="CreateCustomerSFServiceTSFlow1" doc:name="CreateCustomerSFServiceTSFlow1">
 <vm:inbound-endpoint exchange-pattern="request-response" ref="CREATE_CSTMR_VM" doc:name="VM"/>
 <component class="com.vertu.services.ecom.maintaincustmr.processor.CreateCustomerProcessor"
doc:name="CreateCustomerProcessor"/>
 </flow>
 <flow name="CreateCustomerSFServiceTSFlow2" doc:name="CreateCustomerSFServiceTSFlow2">
 <vm:inbound-endpoint exchange-pattern="request-response" ref="INSERT_PERSON_ACT_VM" doc:name="VM"/>
 <sfdc:create config-ref="ECOM_SALESFORCE_CONNECTOR" type="#[payload.Type]" doc:name="Salesforce">
 <sfdc:objects ref="#[payload.Object]"/>
 </sfdc:create>
 </flow>
 </mule>
 Here we have a Salesforce component to create the customer in Salesforce and return the customer-id as payload. So in functional test
case we should mock this component without connecting to original Salesforce.
 How to mock Salesforce component in MUnit functional test case

 To mock Salesforce component, first we should know

 Endpoint type.
 Name of the message processor and namespace of endpoint (from auto-generated
XML).
 The type of payload the endpoint returns.


 Mocking above flow Salesforce component

 Create the salesforce response payload.

 List<Map<String,Object>> l1 = new ArrayList<Map<String,Object>>();
 Map<String,Object> m1 = new HashMap<Srtring,Object>>();
 m1.put(“custid”,”1234”);
 l1.add(m1);

 Mock the salesforce component and return the above created list as response
payload.

 whenMessageProcessor("create").ofNamespace("sfdc").
 thenReturn( muleMessageWithPayload( l1) );
 MUnit functional test case for above flow
 public class MUnitSalesforceStubTest extends FunctionalMunitSuite {
 /**
 * The purpose of this method is to define the list of flow
 * files which will be loaded by Munit test case before executing
 * Munit test case. Specify multiple flow files as comma
 * separated XML files.
 */
 @Override
 protected String getConfigResources() {
 return "src/main/app/MUnitSFTest.xml";
 }
 /**
 *The purpose of this method is to define the list of
 flow name which will execute in Munit test case.
 */
 protected List<String> getFlowsExcludedOfInboundDisabling(){
 List<String> list = new ArrayList<String>();
 list.add("CreateCustomerSFServiceTSFlow2");
 return list;
 }
 /**
 * The purpose of this method is to flip between mock
 * and real time interfaces. Return false to Mock
 * all endpoints in your flow
 */
 @Override
 public boolean haveToMockMuleConnectors() {
 return true;
 }
 /**
 * Java based Munit test case. Contains mocking and
 * invocation of flows and assertions.
 */
 @Test
 public void validateEchoFlow() throws Exception {

 List<Map<String,Object>> l1 = new ArrayList<Map<String,Object>>();
 Map<String,Object> m1 = new HashMap<Srtring,Object>>();
 m1.put(“custid”,”1234”);
 l1.add(m1);

 // Mock SFDC outbound endpoint
 whenMessageProcessor("query").ofNamespace("sfdc").thenReturn( muleMessageWithPayload( l1)
);

 // Run the Munit test case by passing a test payload
 MuleEvent resultEvent = runFlow( " CreateCustomerSFServiceTSFlow1", testEvent(“request”));
 // The resultEvent contains response from the VM flow
 System.out.println( "The flow response is:: " + resultEvent.getMessage().getPayloadAsString() );
 // Do any assertion here using Assert.equals() for asserting response // payload
 }
 }
 Mocking Database component test case using MUnit
 .mflow
<flow name="CheckAcctIDFlow" doc:name="CheckAcctIDFlow">
<vm:inbound-endpoint exchange-pattern="request-response"
ref="FETCH_ACT_GUID_VM1" doc:name="FETCH_ACT_GUID_VM1"/>
<logger
message="#[message.inboundProperties['ACCT_GUID']]"
level="INFO" doc:name="Logger"/>
<jdbc-ee:outbound-endpoint exchange-pattern="request-
response" queryKey="Get_ACC_ID" queryTimeout="-1" connector-
ref="CDMR_JDBC_CONNECTOR" doc:name="Get_ACCT_ID"/>
</flow>
 Here we have a database component used to select and return
the account-id from database. So we need to mock this
component in functional test case.
 Mocking above flow Database component

 Create the database response payload.

 List<Map<String,Object>> l1 = new
ArrayList<Map<String,Object>>();
 Map<String,Object> m1 = new
HashMap<Srtring,Object>>();
 m1.put(“accountid”,”1234”);
 l1.add(m1);

 Mock the database component and return the above
created list as response payload.

 whenEndpointWithAddress( "jdbc://Get_ACC_ID"
).thenReturn(new DefaultMuleMessage(l1,
muleContext ) );
 MUnit functional test case for above flow
 public class MUnitSalesforceStubTest extends FunctionalMunitSuite {
 /**
 * The purpose of this method is to define the list of flow
 * files which will be loaded by Munit test case before executing
 * Munit test case. Specify multiple flow files as comma
 * separated XML files.
 */
 @Override
 protected String getConfigResources() {
 return "src/main/app/MUnitSFTest.xml";
 }

 /**
 * The purpose of this method is to flip between mock
 * and real time interfaces. Return false to Mock
 * all endpoints in your flow
 */
 @Override
 public boolean haveToMockMuleConnectors() {
 return true;
 }
 /**
 * Java based Munit test case. Contains mocking and
 * invocation of flows and assertions.
 */
 @Test
 public void validateEchoFlow() throws Exception {

 List<Map<String,Object>> l1 = new ArrayList<Map<String,Object>>();
 Map<String,Object> m1 = new HashMap<Srtring,Object>>();
 m1.put(“accountid”,”1234”);
 l1.add(m1);
 // Mock Database outbound endpoint
 whenEndpointWithAddress( "jdbc://Get_ACC_ID"
).thenReturn(new DefaultMuleMessage(l1,
muleContext ) );

 // Run the Munit test case by passing a test payload
 MuleEvent resultEvent = runFlow( " CheckAcctIDFlow
", testEvent(“request”));
 // The resultEvent contains response from the VM
flow
 System.out.println( "The flow response is:: " +
resultEvent.getMessage().getPayloadAsString() );
 // Do any assertion here using Assert.equals() for
asserting response // payload
 }
 }
 Create Java based or Mule flow based unit test cases
 Mock endpoints (Salesforce, Database, or SAP etc.) to
return custom payloads for unit testing
 Dynamically flip/parameterize Munit test cases to Mock
payloads or use real time interfaces
 Support functional unit testing similar to Mule Functional
test case
 Support Assertion through Spy processors and additionally
verify flows using Message verifiers (introspect payload at
different flows for flow navigation)
 Support Asynchronous flow processing and request-
response processors
 Mock without custom database or in memory database
 Automate test cases using Maven and generate HTML
reports using Surefire plugins
 When we write test cases using JUnit we can’t
mock all mule components and the test case
will connect to original connectors(SAP,
Salesforce). So to overcome this issue we can
use MUnit to write test cases effectively.
 https://github.com/mulesoft/munit
 http://www.mulesoft.org/documentation/dis
play/EARLYACCESS/MUnit
 http://java.dzone.com/articles/mule-best-
practices-backed

More Related Content

What's hot

Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
Ravinder Singh
 
Creating restful api using mule esb
Creating restful api using mule esbCreating restful api using mule esb
Creating restful api using mule esb
RaviShankar Mishra
 
Data weave in Mule
Data weave in MuleData weave in Mule
Data weave in Mule
RaviShankar Mishra
 
Mule expression language - Part 1
Mule expression language - Part 1Mule expression language - Part 1
Mule expression language - Part 1
Karthik Selvaraj
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
Praneethchampion
 
Java mule
Java muleJava mule
Java mule
Gandham38
 
Mule Ajax Connector
Mule Ajax ConnectorMule Ajax Connector
Mule Ajax Connector
Ankush Sharma
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mule
Rajkattamuri
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
AnilKumar Etagowni
 
Mule testing
Mule   testingMule   testing
Mule testing
Sindhu VL
 
Mule - HTTP Listener
Mule - HTTP ListenerMule - HTTP Listener
Mule - HTTP Listener
Ankush Sharma
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
javeed_mhd
 
Mule Collection Splitter
Mule Collection SplitterMule Collection Splitter
Mule Collection Splitter
Ankush Sharma
 
Mule message processor or routers
Mule message processor or routersMule message processor or routers
Mule message processor or routers
Son Nguyen
 
Integration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESBIntegration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESB
Rupesh Sinha
 
How to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis moduleHow to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis module
Priyobroto Ghosh (Mule ESB Certified)
 
Splitting with mule part2
Splitting with mule part2Splitting with mule part2
Splitting with mule part2
Anirban Sen Chowdhary
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
Praneethchampion
 

What's hot (18)

Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
Creating restful api using mule esb
Creating restful api using mule esbCreating restful api using mule esb
Creating restful api using mule esb
 
Data weave in Mule
Data weave in MuleData weave in Mule
Data weave in Mule
 
Mule expression language - Part 1
Mule expression language - Part 1Mule expression language - Part 1
Mule expression language - Part 1
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
 
Java mule
Java muleJava mule
Java mule
 
Mule Ajax Connector
Mule Ajax ConnectorMule Ajax Connector
Mule Ajax Connector
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mule
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
 
Mule testing
Mule   testingMule   testing
Mule testing
 
Mule - HTTP Listener
Mule - HTTP ListenerMule - HTTP Listener
Mule - HTTP Listener
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
Mule Collection Splitter
Mule Collection SplitterMule Collection Splitter
Mule Collection Splitter
 
Mule message processor or routers
Mule message processor or routersMule message processor or routers
Mule message processor or routers
 
Integration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESBIntegration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESB
 
How to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis moduleHow to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis module
 
Splitting with mule part2
Splitting with mule part2Splitting with mule part2
Splitting with mule part2
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
 

Similar to Junit in mule demo

Munit junit test case
Munit junit test caseMunit junit test case
Munit junit test case
prudhvivreddy
 
J unit
J unitJ unit
Junit in mule
Junit in muleJunit in mule
Junit in mule
Sunil Komarapu
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
F K
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
AbdulImrankhan7
 
Enjoy Munit with Mule
Enjoy Munit with MuleEnjoy Munit with Mule
Enjoy Munit with Mule
Bui Kiet
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interface
krishananth
 
Mocking with salesforce using Munit
Mocking with salesforce using MunitMocking with salesforce using Munit
Mocking with salesforce using Munit
Son Nguyen
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
Visual Engineering
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
Neeraj Kaushik
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands OnjBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
Mauricio (Salaboy) Salatino
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMMario Fusco
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
Naga Muruga
 
Workflow Foundation 4
Workflow Foundation 4Workflow Foundation 4
Workflow Foundation 4
Robert MacLean
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at Pinterest
Pavan Chitumalla
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
Ivano Malavolta
 
Web based development
Web based developmentWeb based development
Web based development
Mumbai Academisc
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
Nataliya Patsovska
 

Similar to Junit in mule demo (20)

Munit junit test case
Munit junit test caseMunit junit test case
Munit junit test case
 
J unit
J unitJ unit
J unit
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Enjoy Munit with Mule
Enjoy Munit with MuleEnjoy Munit with Mule
Enjoy Munit with Mule
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interface
 
Mocking with salesforce using Munit
Mocking with salesforce using MunitMocking with salesforce using Munit
Mocking with salesforce using Munit
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands OnjBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
 
Notes on c++
Notes on c++Notes on c++
Notes on c++
 
Workflow Foundation 4
Workflow Foundation 4Workflow Foundation 4
Workflow Foundation 4
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at Pinterest
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
 
Web based development
Web based developmentWeb based development
Web based development
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 

More from Sudha Ch

Git hub plugin setup and working with Git hub on anypoint studio
Git hub plugin setup and working with Git hub on anypoint studioGit hub plugin setup and working with Git hub on anypoint studio
Git hub plugin setup and working with Git hub on anypoint studio
Sudha Ch
 
Mule management console installation with Tomcat
Mule management console installation with TomcatMule management console installation with Tomcat
Mule management console installation with Tomcat
Sudha Ch
 
How to commit a project in svn using svn plugin in anypoint studio
How to commit a project in svn using svn plugin in anypoint studioHow to commit a project in svn using svn plugin in anypoint studio
How to commit a project in svn using svn plugin in anypoint studio
Sudha Ch
 
JUnit and MUnit Set Up In Anypoint Studio
JUnit and MUnit Set Up In Anypoint StudioJUnit and MUnit Set Up In Anypoint Studio
JUnit and MUnit Set Up In Anypoint Studio
Sudha Ch
 
How To Install Sonar Qube Plugin In Anypoint Studio
How To Install Sonar Qube Plugin In Anypoint StudioHow To Install Sonar Qube Plugin In Anypoint Studio
How To Install Sonar Qube Plugin In Anypoint Studio
Sudha Ch
 
Vm component in mule demo
Vm component in mule demoVm component in mule demo
Vm component in mule demo
Sudha Ch
 
Until successful component in mule demo
Until successful component in mule demoUntil successful component in mule demo
Until successful component in mule demo
Sudha Ch
 
Quartz component in mule demo
Quartz component in mule demoQuartz component in mule demo
Quartz component in mule demo
Sudha Ch
 
Message properties component in mule demo
Message properties component in mule demoMessage properties component in mule demo
Message properties component in mule demo
Sudha Ch
 
For each component in mule demo
For each component in mule demoFor each component in mule demo
For each component in mule demo
Sudha Ch
 
Filter expression in mule demo
Filter expression in mule demoFilter expression in mule demo
Filter expression in mule demo
Sudha Ch
 
File component in mule demo
File component in mule demoFile component in mule demo
File component in mule demo
Sudha Ch
 
Database component in mule demo
Database component in mule demoDatabase component in mule demo
Database component in mule demo
Sudha Ch
 
Choice component in mule demo
Choice component in mule demoChoice component in mule demo
Choice component in mule demo
Sudha Ch
 
Mule esb made system integration easy
Mule esb made system integration easyMule esb made system integration easy
Mule esb made system integration easy
Sudha Ch
 
Telling the world why we love mule soft!
Telling the world why we love mule soft!Telling the world why we love mule soft!
Telling the world why we love mule soft!
Sudha Ch
 
Telling the world why we love mule soft!
Telling the world why we love mule soft!Telling the world why we love mule soft!
Telling the world why we love mule soft!
Sudha Ch
 

More from Sudha Ch (17)

Git hub plugin setup and working with Git hub on anypoint studio
Git hub plugin setup and working with Git hub on anypoint studioGit hub plugin setup and working with Git hub on anypoint studio
Git hub plugin setup and working with Git hub on anypoint studio
 
Mule management console installation with Tomcat
Mule management console installation with TomcatMule management console installation with Tomcat
Mule management console installation with Tomcat
 
How to commit a project in svn using svn plugin in anypoint studio
How to commit a project in svn using svn plugin in anypoint studioHow to commit a project in svn using svn plugin in anypoint studio
How to commit a project in svn using svn plugin in anypoint studio
 
JUnit and MUnit Set Up In Anypoint Studio
JUnit and MUnit Set Up In Anypoint StudioJUnit and MUnit Set Up In Anypoint Studio
JUnit and MUnit Set Up In Anypoint Studio
 
How To Install Sonar Qube Plugin In Anypoint Studio
How To Install Sonar Qube Plugin In Anypoint StudioHow To Install Sonar Qube Plugin In Anypoint Studio
How To Install Sonar Qube Plugin In Anypoint Studio
 
Vm component in mule demo
Vm component in mule demoVm component in mule demo
Vm component in mule demo
 
Until successful component in mule demo
Until successful component in mule demoUntil successful component in mule demo
Until successful component in mule demo
 
Quartz component in mule demo
Quartz component in mule demoQuartz component in mule demo
Quartz component in mule demo
 
Message properties component in mule demo
Message properties component in mule demoMessage properties component in mule demo
Message properties component in mule demo
 
For each component in mule demo
For each component in mule demoFor each component in mule demo
For each component in mule demo
 
Filter expression in mule demo
Filter expression in mule demoFilter expression in mule demo
Filter expression in mule demo
 
File component in mule demo
File component in mule demoFile component in mule demo
File component in mule demo
 
Database component in mule demo
Database component in mule demoDatabase component in mule demo
Database component in mule demo
 
Choice component in mule demo
Choice component in mule demoChoice component in mule demo
Choice component in mule demo
 
Mule esb made system integration easy
Mule esb made system integration easyMule esb made system integration easy
Mule esb made system integration easy
 
Telling the world why we love mule soft!
Telling the world why we love mule soft!Telling the world why we love mule soft!
Telling the world why we love mule soft!
 
Telling the world why we love mule soft!
Telling the world why we love mule soft!Telling the world why we love mule soft!
Telling the world why we love mule soft!
 

Recently uploaded

Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 

Recently uploaded (20)

Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 

Junit in mule demo

  • 1. JUnit Functional test cases By: Sudha Chiraboina
  • 2.  The main motto of this white paper is what the issues to write test cases using JUnit are and how to overcome those issues.
  • 3.  ABSTRACT 1. INTRODUCTION 2. PROBLEM STATEMENT 3. SOLUTION 4. BENEFITS 5. CONCLUSION 6. REFERENCES 7. ABOUT THE AUTHOR 8. ABOUT WHISHWORKS
  • 4.  We have multiple unit test frameworks to write unit and functional test cases for our services. When we write functional test cases using JUnit we can’t mock mule components. To resolve this issues we have to use MUnit and I am going to explain what is the problem with JUnit and how to resolve using MUnit in the below.
  • 5.  When we write functional test cases using JUnit, the test case will directly connect to original components like SAP, Salesforce etc. and insert/select the data. It is the issue in JUnit functional test case why because we are writing functional test cases to check whether entire functionality is working as expected or not without modifying the original components(SAP,Salesforce,Database) data, but in JUnit functional test cases it is directly connecting to original components and modifying the original data.  Examples: 1. SAP Connector  Mule flow:
  • 6.
  • 7.  Flow of execution 1. Trigger the service with xml request. 2. Receive the input request and process it. 3. Transform the processed request to SAP IDoc and push it to SAP.
  • 8.  Functional test case using JUnit:  Public void functionalTest(){   File fXmlFile = new File(request.xml);  StringBuilder sb = new StringBuilder();  BufferedReader br = new BufferedReader(new FileReader(fXmlFile));   String sCurrentLine = new String();  //Read the data from file and append to string  while ((sCurrentLine = br.readLine()) != null) {  sb.append(sCurrentLine);  }   DefaultHttpClient httpclient = new DefaultHttpClient();   HttpPost httppost = new HttpPost(requrl);   httppost.setEntity(new StringEntity(sb.toString(), "UTF-8"));  //Trigger the service  HttpResponse response = httpclient.execute(httppost);   ----  ----  } 
  • 9.  Flow of execution 1. Read the input request from request.xml file. 2. Trigger the service with above request. 3. Process the input request. 4. Transform the processed request to SAP IDoc and push it to SAP.  Issue  Here we are unable to mock the SAP component so the test case is directly pushing the IDoc to original SAP.  NOTE: Not only pushing the IDoc to SAP, at the time of receiving IDoc from SAP also we will face same issue.
  • 11.
  • 12.  Flow of execution 1. Trigger the service with xml request. 2. Processes the input request. 3. Create the processed request as customer in Salesforce.
  • 13.  Functional Test Case  Public void functionalTest(){   File fXmlFile = new File(request.xml);  StringBuilder sb = new StringBuilder();  BufferedReader br = new BufferedReader(new FileReader(fXmlFile));   String sCurrentLine = new String();  // Read the data from file and append to string  while ((sCurrentLine = br.readLine()) != null) {  sb.append(sCurrentLine);  }   DefaultHttpClient httpclient = new DefaultHttpClient();   HttpPost httppost = new HttpPost(requrl);   httppost.setEntity(new StringEntity(sb.toString(), "UTF-8"));  //Trigger the service  HttpResponse response = httpclient.execute(httppost);   ----  ----  }
  • 14.  Flow of Execution 1. First read the input request from request.xml file. 2. Trigger the service with above request. 3. Process the input request. 4. Create the customer in salesforce.  Issue  Here also we are unable to mock the Salesforce component so it will connect to original Salesforce connector and create the customer on it.
  • 15.  To resolve the above JUnit functional test case issue we have a separate framework called MUnit. MUnit is also one framework which is used to write test cases as same as JUnit, but here in MUnit we can mock all components like SAP, Salesforce, Database etc. So to overcome the above problem we can use MUnit to write functional test cases.
  • 16.  Example  Mocking Salesforce test case using Munit  .mflow  <?xml version="1.0" encoding="UTF-8"?>   <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd  http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/5.0/mule-sfdc.xsd  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd  http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">  <vm:endpoint exchange-pattern="request-response" path="CREATE_CSTMR_VM" name="CREATE_CSTMR_VM" doc:name="VM"/>  <vm:endpoint exchange-pattern="request-response" path="INSERT_PERSON_ACT_VM" name="INSERT_PERSON_ACT_VM" doc:name="VM"/>  <flow name="CreateCustomerSFServiceTSFlow1" doc:name="CreateCustomerSFServiceTSFlow1">  <vm:inbound-endpoint exchange-pattern="request-response" ref="CREATE_CSTMR_VM" doc:name="VM"/>  <component class="com.vertu.services.ecom.maintaincustmr.processor.CreateCustomerProcessor" doc:name="CreateCustomerProcessor"/>  </flow>  <flow name="CreateCustomerSFServiceTSFlow2" doc:name="CreateCustomerSFServiceTSFlow2">  <vm:inbound-endpoint exchange-pattern="request-response" ref="INSERT_PERSON_ACT_VM" doc:name="VM"/>  <sfdc:create config-ref="ECOM_SALESFORCE_CONNECTOR" type="#[payload.Type]" doc:name="Salesforce">  <sfdc:objects ref="#[payload.Object]"/>  </sfdc:create>  </flow>  </mule>  Here we have a Salesforce component to create the customer in Salesforce and return the customer-id as payload. So in functional test case we should mock this component without connecting to original Salesforce.
  • 17.  How to mock Salesforce component in MUnit functional test case   To mock Salesforce component, first we should know   Endpoint type.  Name of the message processor and namespace of endpoint (from auto-generated XML).  The type of payload the endpoint returns.    Mocking above flow Salesforce component   Create the salesforce response payload.   List<Map<String,Object>> l1 = new ArrayList<Map<String,Object>>();  Map<String,Object> m1 = new HashMap<Srtring,Object>>();  m1.put(“custid”,”1234”);  l1.add(m1);   Mock the salesforce component and return the above created list as response payload.   whenMessageProcessor("create").ofNamespace("sfdc").  thenReturn( muleMessageWithPayload( l1) );
  • 18.  MUnit functional test case for above flow  public class MUnitSalesforceStubTest extends FunctionalMunitSuite {  /**  * The purpose of this method is to define the list of flow  * files which will be loaded by Munit test case before executing  * Munit test case. Specify multiple flow files as comma  * separated XML files.  */  @Override  protected String getConfigResources() {  return "src/main/app/MUnitSFTest.xml";  }  /**  *The purpose of this method is to define the list of  flow name which will execute in Munit test case.  */  protected List<String> getFlowsExcludedOfInboundDisabling(){  List<String> list = new ArrayList<String>();  list.add("CreateCustomerSFServiceTSFlow2");  return list;  }  /**  * The purpose of this method is to flip between mock  * and real time interfaces. Return false to Mock  * all endpoints in your flow  */  @Override  public boolean haveToMockMuleConnectors() {  return true;  }
  • 19.  /**  * Java based Munit test case. Contains mocking and  * invocation of flows and assertions.  */  @Test  public void validateEchoFlow() throws Exception {   List<Map<String,Object>> l1 = new ArrayList<Map<String,Object>>();  Map<String,Object> m1 = new HashMap<Srtring,Object>>();  m1.put(“custid”,”1234”);  l1.add(m1);   // Mock SFDC outbound endpoint  whenMessageProcessor("query").ofNamespace("sfdc").thenReturn( muleMessageWithPayload( l1) );   // Run the Munit test case by passing a test payload  MuleEvent resultEvent = runFlow( " CreateCustomerSFServiceTSFlow1", testEvent(“request”));  // The resultEvent contains response from the VM flow  System.out.println( "The flow response is:: " + resultEvent.getMessage().getPayloadAsString() );  // Do any assertion here using Assert.equals() for asserting response // payload  }  }
  • 20.  Mocking Database component test case using MUnit  .mflow <flow name="CheckAcctIDFlow" doc:name="CheckAcctIDFlow"> <vm:inbound-endpoint exchange-pattern="request-response" ref="FETCH_ACT_GUID_VM1" doc:name="FETCH_ACT_GUID_VM1"/> <logger message="#[message.inboundProperties['ACCT_GUID']]" level="INFO" doc:name="Logger"/> <jdbc-ee:outbound-endpoint exchange-pattern="request- response" queryKey="Get_ACC_ID" queryTimeout="-1" connector- ref="CDMR_JDBC_CONNECTOR" doc:name="Get_ACCT_ID"/> </flow>  Here we have a database component used to select and return the account-id from database. So we need to mock this component in functional test case.
  • 21.  Mocking above flow Database component   Create the database response payload.   List<Map<String,Object>> l1 = new ArrayList<Map<String,Object>>();  Map<String,Object> m1 = new HashMap<Srtring,Object>>();  m1.put(“accountid”,”1234”);  l1.add(m1);   Mock the database component and return the above created list as response payload.   whenEndpointWithAddress( "jdbc://Get_ACC_ID" ).thenReturn(new DefaultMuleMessage(l1, muleContext ) );
  • 22.  MUnit functional test case for above flow  public class MUnitSalesforceStubTest extends FunctionalMunitSuite {  /**  * The purpose of this method is to define the list of flow  * files which will be loaded by Munit test case before executing  * Munit test case. Specify multiple flow files as comma  * separated XML files.  */  @Override  protected String getConfigResources() {  return "src/main/app/MUnitSFTest.xml";  }   /**  * The purpose of this method is to flip between mock  * and real time interfaces. Return false to Mock  * all endpoints in your flow  */  @Override  public boolean haveToMockMuleConnectors() {  return true;  }  /**  * Java based Munit test case. Contains mocking and  * invocation of flows and assertions.  */  @Test  public void validateEchoFlow() throws Exception {   List<Map<String,Object>> l1 = new ArrayList<Map<String,Object>>();  Map<String,Object> m1 = new HashMap<Srtring,Object>>();  m1.put(“accountid”,”1234”);  l1.add(m1);
  • 23.  // Mock Database outbound endpoint  whenEndpointWithAddress( "jdbc://Get_ACC_ID" ).thenReturn(new DefaultMuleMessage(l1, muleContext ) );   // Run the Munit test case by passing a test payload  MuleEvent resultEvent = runFlow( " CheckAcctIDFlow ", testEvent(“request”));  // The resultEvent contains response from the VM flow  System.out.println( "The flow response is:: " + resultEvent.getMessage().getPayloadAsString() );  // Do any assertion here using Assert.equals() for asserting response // payload  }  }
  • 24.  Create Java based or Mule flow based unit test cases  Mock endpoints (Salesforce, Database, or SAP etc.) to return custom payloads for unit testing  Dynamically flip/parameterize Munit test cases to Mock payloads or use real time interfaces  Support functional unit testing similar to Mule Functional test case  Support Assertion through Spy processors and additionally verify flows using Message verifiers (introspect payload at different flows for flow navigation)  Support Asynchronous flow processing and request- response processors  Mock without custom database or in memory database  Automate test cases using Maven and generate HTML reports using Surefire plugins
  • 25.  When we write test cases using JUnit we can’t mock all mule components and the test case will connect to original connectors(SAP, Salesforce). So to overcome this issue we can use MUnit to write test cases effectively.