Virtualan (www.virtualan.io) - "Service Virtualization as Code" Service
"Virtualan would be build with spring boot framework that would convert API service as Virtualized service" in matter of adding couple of annotations. Simply as Virtualized service and which currently supports spring-boot based Rest service (API) with Spring-RestController or CXF-Jaxrs as Virtualized service with @VirtualService and @ApiVirtual"
Virtualan would perform a "Request Matching" with following attribute choices:
- End point Rest URL
- HTTP Verbs
- Query/Path/Header parameters
- Request message body
This concept is very interesting to me. Just came up with open source spring-boot version of Virtualan. -"Service Virtualization as Code".
I have been working on this from last year. https://tutorials.virtualan.io/#/ Virtualan would support this couple of ways:
I. Spring-boot Rest Service as Virtualized service using couple of annotations.
Would you think? Just adding 2 simple annotation changes the code as Virtualized service? Yes. The following annotations would changes the code as Virtualized Service. You can deploy on docker. "Boom!!!!" Your Virtual service is ready.
@VirtualService && @ApiVirtual
Example Project: https://github.com/elans3/virtualan-springboot-controller-example/blob/master/README.md
II. OpenAPI interface Specification(Yaml) deployed as Virtualized service:
Just adding a swagger/openapi specification in the maven/pom.xml would generate as Virtualized service.
- OpenAPITools/openapi-generator <https://github.com/openapitools/openapi-generator> - This Code Generator would generate Open API Specification as Virtualized service.
- Add the OpenAPITools-Code Generator maven plugin to perform this transformation.
Example Code Project: https://github.com/virtualansoftware/service-virtualization-openapi
To populate Mock Data in Virtualized service/Mock Service:
- Using Virtualan-UI: https://tutorials.virtualan.io/#/Virtualan-mock-data
- Using Virtualan-Rest service: Refer the following examples to populate via rest client
- https://github.com/elan-venture/virtualan/blob/master/test/virtualan-test-data/src/main/resources/features/pet/pet.feature
- https://github.com/elan-venture/virtualan/tree/master/samples/virtualan-openapi-spring-mapping/src/test/java/io/
Why/How to store the mock data in the centralized place:
It always provides a choice to choose your data base and configure(spring-jpa). Need to provide data base information in the Application.properties in the "src/main/resources" directory of your spring boot application: This would requires if you don't want to loose the existing mock data because as you redeploy the code the data would be lost.
- virtualan.datasource.driver-class-name=<org.hsqldb.jdbcDriver
- virtualan.datasource.jdbcurl=<jdbc:hsqldb:mem:dataSource>
- virtualan.datasource.username=<sa>
- virtualan.datasource.password=<>
The following SQL's needs to be executed to set up the specific Data base: (Need to build support SQL's to run the initial setup.. Feature is under construction)
Great share, Elan!
6+ years of experience in IT Leadership | Principal Consultant @ Thoughtworks | Solutions, Consulting, Roadmap Strategy, Full Stack, Multi Cloud & Multi Region, Big Data Pipelines & Migration, Digital Transformation
6 年i tried this myself and it worked really well. Excellent work by Elan and many more congratulations to your contribution