When Traffic Parrot receives a request via any protocol or technology like HTTP, JMS, gRPC and others, it will try to simulate the system it is replacing by sending back a response to the client that sent the request.
To decide which response to send, it will go through all the request to response mappings it has available to find the response to be returned.
A request to response mapping defines which response to return given a request.
For example, in HTTP, you could say:
For any request to URL '/hello' that is a GET request return a response with body 'Hello World!'
The way you do that in Traffic Parrot is by using the user interface to record mappings, import them or add them manually.
{ "id" : "a6263f39-5826-48a5-a409-4d78037c303e", "request" : { "url" : "/MODApis/Api/v2/Quote/json?AAPL", "method" : "GET" }, "response" : { "status" : 200, "body" : "{\r\n \"Status\": \"SUCCESS\",\r\n \"High\": 116.91,\r\n \"MSDate\": 42664,\r\n \"Change\": -0.46,\r\n \"LastPrice\": 116.6,\r\n \"Timestamp\": \"Fri Oct 21 00:00:00 UTC-04:00 2016\",\r\n \"ChangePercentYTD\": 105.26,\r\n \"Name\": \"Apple Inc\",\r\n \"Open\": 116.81,\r\n \"Volume\": 23192665,\r\n \"Low\": 116.28,\r\n \"ChangeYTD\": 105.26,\r\n \"ChangePercent\": -0.3929608748,\r\n \"MarketCap\": 628292453800\r\n}", "headers" : { "Content-Type" : "text/javascript; charset=UTF-8" } }, "uuid" : "a6263f39-5826-48a5-a409-4d78037c303e" }
Traffic Parrot support matching attributes of requests using the following matchers.
Protocol/technology | Matchers available |
---|---|
HTTP(S) | list of HTTP(S) matchers |
JMS | list of JMS matchers |
Native IBM MQ | list of MQ matchers |
gRPC | list of gRPC matchers |
Files | list of files matchers |
Traffic Parrot stores request to response mappings on the filesystem.
Protocol/technology | Mappings location |
---|---|
HTTP(S) | mappings and __files (where it stores bodies of responses during a recording) |
JMS | jms-mappings |
Native IBM MQ | ibm-mq-mappings |
gRPC | grpc-mappings |
Files | file-mappings |
You can change the root directory by changing the value of the trafficparrot.virtualservice.trafficFilesRootUrl property.
XPath (XML Path Language) is a query language for finding and selecting elements in an XML document. Traffic Parrot allows to match requests using XPath.
We recommend the following reading to users who would like to take their XPaths skills to an advanced level:
This documentation is for an old version of Traffic Parrot. There is a more recent Traffic Parrot version available for download at trafficparrot.com