-
Notifications
You must be signed in to change notification settings - Fork 5
Create and Deploy Virtual Service with Parameterized VSM File
sachinmaske edited this page Oct 20, 2022
·
1 revision
Below example describe how to create and deploy virtual service by using VSM/VSI file and changing port and documentation.
Add the below virtual service annotation above each test method. This annotation should refer to the Requests/Responses pair folder and define virtual service configuration such as service name, listening port, path, type of protocol and parameters.
@DevTestVirtualServer()
public class BasicTest {
static final Log logger = LogFactory.getLog(BasicTest.class);
@Autowired
private BankService bankServices;
@Rule
public VirtualServicesRule rules = new VirtualServicesRule();
@DevTestVirtualServiceV3(
serviceName = "vsV3_VSMVSI_CustomPort",
description = "Test Case vsV3_VSMVSI_CustomPort",
port = "24000",
workingFolder = "v3/vsmvsi_port_parameter",
inputFile1 = "Op8AndOp9.vsi",
inputFile2 = "Op8AndOp9.vsm"
)
@Test
public void vsV3_VSMVSI_CustomPort() {
ResponseParser op8Response = HttpUtils.GET(HttpUtils.URL_FORMAT, "http", "localhost", "24000", "import/test/operation-8");
ResponseParser op9Response = HttpUtils.GET(HttpUtils.URL_FORMAT, "http", "localhost", "24000", "import/test/operation-9");
assert (op8Response != null);
assert (op8Response.getValue("$.TCEntry[0].termsType").equals("Operation 8 terms"));
assert (op9Response != null);
assert (op9Response.getValue("$.TCEntry[0].termsType").equals("Operation 9 terms"));
}
}
The port and the description values passed in the virtual service annotation will replace the value in the VSM file. The VSM file should contains ${listenPort} for port and ${documentation} for the description. Below is the example of a VSM file.
<?xml version="1.0" ?>
<VSModel name="Op8AndOp9" version="5">
<meta>
<create version="10.6.0" buildNumber="10.6.0.23" author="admin" date="09/15/2022" host="C02CP01UPWDG" />
<lastEdited version="10.6.0" buildNumber="10.6.0.23" author="admin" date="09/15/2022" host="C02CP01UPWDG" />
</meta>
<id>8FF615E034F311ED8AAE5C5230A69BCF</id>
<Documentation>${documentation}</Documentation>
<IsInProject>true</IsInProject>
<sig>ZWQ9NSZ0Y3Y9NSZsaXNhdj0xMC42LjAgKDEwLjYuMC4yMykmbm9kZXM9LTE2Mjc5NzUwMTQ=</sig>
<subprocess>false</subprocess>
....
....
....
</CustomFilterData>
</Filter>
<outputAsObject>false</outputAsObject>
<onExceptionStep>abort</onExceptionStep>
<listenPort>${listenPort}</listenPort>
<basePath>/</basePath>
<bindOnly>false</bindOnly>
<useSSL>false</useSSL>
<sslClientAuthType>none</sslClientAuthType>
</Node>
....
....
....
Annotation DevTestVirtualServiceV3
- Create and Deploy a Virtual Service Before a Test
- Create and Deploy a Virtual Service Before Any Test from the Class
- Create and Deploy Multiple Virtual Services Before a Test
- Create Update and Deploy Virtual Service Before a Test
- Create, Update and Deploy Virtual Service Before any Test from the Class
- Create and Deploy Virtual Service with RR Pair
- Create and Deploy Virtual Service with RR Pair Zip File
- Create and Deploy Virtual Service with Swagger File
- Create and Deploy Virtual Service with Swagger Url
- Create and Deploy Virtual Service with RAML File
- Create and Deploy Virtual Service with RAML Url
- Create and Deploy Virtual Service with WADL File
- Create and Deploy Virtual Service with WADL Url
- Create and Deploy Virtual Service with VSM/VSI File
- Create and Deploy Virtual Service and Update Data and Config File
- Create and Deploy Virtual Service with Parameterized VSM File
- Create and Deploy Virtual Service with Parameterized Input File
- Create and Deploy Virtual Service with SSL End-Point
- Create and Deploy a Virtual Service before a Test
- Create and Deploy a Virtual Service before Any Test from the Class
- Create and Deploy Multiple Virtual Services before a Test
- Create and Deploy with VRS
- Create and Deploy with RR Pair
- Create and Deploy with VSM
- Parameterized DevTest Virtual Service Annotation
- Generate RR Pairs Utility