Skip to content

Create and Deploy Virtual Service with Swagger Url

sachinmaske edited this page Oct 20, 2022 · 1 revision

These example describes creating a virtual service annotated at the test method level using Swagger url.

Below annotation defines rules to create virtual service before tests.

@Rule public VirtualServicesRule rules = new VirtualServicesRule();

The scope of this annotation remains till the method executes.

@DevTestVirtualServiceV3(serviceName = "vsV3_SwaggerUrl", workingFolder = "vsV3_SwaggerUrl", port=24778
@DevTestVirtualServer(deployServiceToVse = "VSE",groupName="V3Test")
public class VirtualServiceV3CreateTest {

    @Rule
    public VirtualServicesRule rules = new VirtualServicesRule();
    String API_PROTOCOL = "http";
    
    @DevTestVirtualServiceV3(
            serviceName = "vsV3_SwaggerUrl",
            port = "24778",
            workingFolder = "vsV3_SwaggerUrl",
            swaggerurl = "https://petstore.swagger.io/v2/swagger.json"
    )
    @Test
    public void vsV3_SwaggerUrl() {
        ResponseParser responseParser = HttpUtils.GET(HttpUtils.URL_FORMAT, "http", "localhost",
                "24778", "v2/store/inventory");
        String value = responseParser.getValue("//root/integer_0");
        String str = (new File("v3/swager", "swagger.json")).toURI().toString();
        assert (responseParser != null);
        assert (value.equals("1"));
    }
}

Getting Started

Code Library

Core Functionality

Version 1.4.0

Annotation DevTestVirtualServiceV3

Version 1.3.2

Acknowledgments

Clone this wiki locally