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.
In this section:
- Parasoft Virtualize 9.10.x or later
The tool can be installed from the UI or command line.
- Choose Parasoft> Preferences.
- In the System Properties preferences page, click Add JARs.
- Browse to and select HTTPSimpleMockingTool.jar.
- Restart Virtualize.
Command Line Installation
Add the HTTPSimpleMockingTool.jar file to the system.properties.classpath property in your localsettings 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:
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.
- Right-click the Virtual Assets project and choose Add New> Virtual Asset (.pva) File.
- Provide a name for the .pva and click Next.
- Choose the Empty folder and click Next.
- Right-click the new responder suite and choose Add New> Responder.
- Choose the Literal Message Responder and click Finish.
- In the Response tab of the newly-created Literal Message Responder, add a default message for your responder in case a matching request/response pair is not found in the traffic file and the real service is not available for recording.
- Save the modified responder.
- Right-click the responder and choose Add Output.
- Choose Outgoing Response> Payload and choose HTTP Simple Mocking Tool. This tool must be added to the outgoing response payload; other options are not applicable.
- Configure the tool options. See Tool Configuration.
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 (e.g., 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:
If you want to ignore the
availableFunds elements when matching requests, you could enter the following:
You can configure the following settings.
(Required) Specifies the host to which the request should be forwarded if a matching response cannot be found in the traffic file.
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
Specifies a regular expression pattern that indicates what traffic patterns you want excluded from the request matching process. For example, if you wanted to include dates, you could use a regular expression such as
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.