For a Detailed Explanation of RAML and Usage of this Mock Service, refer to wiki-document
Exploring Vertx and RAML - To create a Mock Service which takes RAML files as input, parses the RAML and creates the web services based on the resources available in RAML File. Finally returns the example section as output when the URL is hit.
- Creates a HTTP connection for the RAML file defined.
- Reads the contents of the RAML file and creates mock web services for the path defined in RAML.
- On hitting/accesing the URL -
- If found, It returns the example provided in the RAML as the output.
- If not found, then based on the base URI
- If any externals servers have been added the call will be forwarded to respective servers and the output of external server will be transfered to client.
- If any externals servers have been added the call will be forwarded to respective servers and the output of external server will be transfered to client.
You can download the mock service jar
java -jar [Folder Path where RAMLs are present]
Option: Folder Path for RAML - This is optional.
Ex :
java -jar vertx/target/mock-service.jar /home/kishore/mygit/vertx/vertx/src/main/resources/raml/
After this command execution, the server starts at port 4123. It can be accessed using
- If the response from the example section provided appears then the service is working fine.
- Alternatively, you can use Postman to check the response based on get/post method types.
Access the Admin URL at
Say the resource "/getAccounts.json" was not defined in the RAML contract. In which case you would like to get this info from third party/External server. Then go to Admin URL mentioned above and add the below details
For URL http://mybankdomain.com:8080/bankService/getAccounts.json
- BaseURI - bankService
- Port - 8080
- Hostname - mybankdomain.com
Now make the request and you'll be able to get the contents from that server as well.
Add below repo and profiles in your .m2/settings.xml for downloading raml parsers
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshot Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
<profile>
<id>Mule</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>MuleRepository</id>
<name>MuleRepository</name>
<url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<activeProfiles>
<activeProfile>Mule</activeProfile>
</activeProfiles>