The Parasoft HTTP Simple Mocking Tool allows a Virtual Asset to learn and replicate the transactions between the application under test and a back-end component. It can be used to record and simulate traffic without the use of the proxy.
The tool can be installed from the UI or command line.
Add the HTTPSimpleMockingTool.jar file to the system.properties.classpath
property in your settings properties file. For example:
system.properties.classpath=<PATH_TO_JAR>/HTTPSimpleMockingTool.jar
Alternatively, you could add the HTTPSimpleMockingTool.jar file to the VirtualAssets/system_jars
folder. Create this folder if it does not already exist. Make the following API call to reload the .jar:
http://<VIRTUALIZE_SERVER_HOST>:<VIRTUALIZE_SERVER_PORT>/soavirt/api/<VERSION>/preferences/systemProperties/reload
The HTTP Simple Mocking Tool is used as an output to a Message Responder tool. It is attached to the payload of the outgoing response.
Once the tool is configured and the associated virtual asset is deployed to a Virtualize server, you can start using it for mocking. When you're ready to use the tool to record and Virtualize traffic, send requests from the client to the virtual asset's endpoint shown in the virtual asset deployment settings.
The virtual asset will process the requests sent to its endpoint and forward them to the tool. The tool will look for a correlated request/response pair in the specified traffic file.
If a match is found, the correlated request is sent to the client. If no match is found, the tool forwards the message to the actual service and attempts to record a request/response pair. If recording is not possible (for example, because the service is not responding), the message responder associated with this tool will respond to the client with the default "catch all" message that you provided.
This behavior is illustrated in the following diagram:
If you want to exclude certain traffic patterns from the request matching process, you can use the Exclude Pattern field described in Tool Configuration. For example, assume you have the following request:
POST /parabank/services/LoanProcessor HTTP/1.1 soapaction: "" connection: keep-alive cache-control: no-cache pragma: no-cache accept: */* user-agent: Apache CXF 2.4.2 content-type: text/xml; charset=UTF-8 content-length: 412 host: localhost:8080 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:requestLoan xmlns:ns2="http://service.parabank.parasoft.com/"> <ns2:loanRequest> <requestDate>2016-06-07T15:20:52.410-07:00</requestDate> <customerId>12212</customerId> <availableFunds>1510.67</availableFunds> <loanAmount>100</loanAmount> <downPayment>10</downPayment> </ns2:loanRequest> </ns2:requestLoan> </soap:Body> </soap:Envelope> |
If you want to ignore the requestDate
and availableFunds
elements when matching requests, you could enter the following:
(<requestDate>.*</requestDate>)|(<availableFunds>.*</availableFunds>)
You can configure the following settings.
Backend Host | (Required) Specifies the host to which the request should be forwarded if a matching response cannot be found in the traffic file. |
---|---|
Backend Port | Specifies the port to which the request should be forwarded if a matching response cannot be found in the traffic file. The default is |
Traffic File Path | Specifies the location of the traffic file where request response pairs are recorded. The default is |
Exclude Pattern | Specifies a regular expression pattern that indicates what traffic patterns you want excluded from the request matching process. For example, if you wanted to exclude dates, you could use a regular expression such as |
Debug | Specifies if processing details and error information is communicated via the Event Log. The default is |
This tool does not contain any third-party software.