Skip to content

Instantly share code, notes, and snippets.

@sdeepaks
Last active November 30, 2017 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdeepaks/acae97611cdc03ca76385067937daa2a to your computer and use it in GitHub Desktop.
Save sdeepaks/acae97611cdc03ca76385067937daa2a to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:anypoint-mq="http://www.mulesoft.org/schema/mule/anypoint-mq" xmlns:error-handling="http://www.mulesoft.org/schema/mule/error-handling" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:mulerequester="http://www.mulesoft.org/schema/mule/mulerequester" xmlns:synchronize="http://www.mulesoft.org/schema/mule/synchronize"
xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/synchronize http://www.mulesoft.org/schema/mule/synchronize/current/mule-synchronize.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
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/mulerequester http://www.mulesoft.org/schema/mule/mulerequester/current/mule-mulerequester.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/error-handling http://www.mulesoft.org/schema/mule/error-handling/current/mule-error-handling.xsd
http://www.mulesoft.org/schema/mule/anypoint-mq http://www.mulesoft.org/schema/mule/anypoint-mq/current/mule-anypoint-mq.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8088" doc:name="HTTP Listener Configuration"/>
<anypoint-mq:config name="Anypoint_MQ_Configuration" doc:name="Anypoint MQ Configuration">
<anypoint-mq:provider url="https://mq-us-east-1.anypoint.mulesoft.com/api/v1" clientId="aaAAFffsshA6hhg8A8sas9" clientSecret="786Djahj&amp;haas&amp;jadhjad9999A"/>
</anypoint-mq:config>
<flow name="ReceiveDataFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/fetchData" doc:name="HTTP"/>
<anypoint-mq:consume config-ref="Anypoint_MQ_Configuration" destination="dpk-a-queue" doc:name="Anypoint MQ"/>
<json:json-to-xml-transformer doc:name="JSON to XML"/>
</flow>
<flow name="SendDataFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/sendData" doc:name="HTTP"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
"test":{
"data":{
"name":"dk",
"age":"26"
}
}
}]]></dw:set-payload>
</dw:transform-message>
<anypoint-mq:publish config-ref="Anypoint_MQ_Configuration" destination="dpk-a-queue" doc:name="Publish to MQ"/>
<logger message="Data Pushed to ActiveMQ" level="INFO" doc:name="Logger"/>
</flow>
</mule>
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:mock="http://www.mulesoft.org/schema/mule/mock" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.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
http://www.mulesoft.org/schema/mule/mock http://www.mulesoft.org/schema/mule/mock/current/mule-mock.xsd">
<munit:config name="munit" doc:name="MUnit configuration"/>
<spring:beans>
<spring:import resource="classpath:testbatch.xml"/>
</spring:beans>
<munit:test name="test-mq-ReceiveDataFlowTest" description="Test">
<mock:when messageProcessor=".*:.*" doc:name="Mock">
<mock:with-attributes>
<mock:with-attribute name="doc:name" whereValue="#['Anypoint MQ']"/>
</mock:with-attributes>
<mock:then-return payload="{ &quot;test&quot;:{ &quot;data&quot;:{ &quot;name&quot;:&quot;dk&quot;, &quot;age&quot;:&quot;26&quot; } } }" encoding="UTF-8" mimeType="application/json"/>
</mock:when>
<flow-ref name="ReceiveDataFlow" doc:name="Flow-ref to ReceiveDataFlow"/>
<logger level="INFO" doc:name="Logger"/>
<munit:assert-on-equals expectedValue="dk" actualValue="#[xpath3('test/data/name')]" doc:name="Assert Equals"/>
</munit:test>
<munit:test name="test-mq-SendDataFlowTest" description="Test">
<mock:when messageProcessor=".*:.*" doc:name="Mock">
<mock:with-attributes>
<mock:with-attribute name="doc:name" whereValue="#['Publish to MQ']"/>
</mock:with-attributes>
<mock:then-return payload="Success"/>
</mock:when>
<flow-ref name="SendDataFlow" doc:name="Flow-ref to SendDataFlow"/>
<munit:assert-on-equals expectedValue="Success" actualValue="#[payload]" doc:name="Assert Equals"/>
</munit:test>
</mule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment