Skip to content

Create and Deploy with VRS

sachinmaske edited this page Oct 20, 2022 · 1 revision

This example describes on how to create and deploy virtual service from request/response pairs that uses non-HTTP configured mode i.e. VRS file.

Below annotation should be given before class name. It describes configurations related to Virtual service environment.

@DevTestVirtualServer(registryHost = "localhost",deployServiceToVse = "VSE", login = "admin", password="admin")

Below annotation should be given before test method. It describe configurations of virtual service.

@DevTestVirtualServiceFromVrs(serviceName = "getUserWithVrs", workingFolder = "soapWithVrs", vrsConfig = @Config(value = "transport.vrs", parameters = {
			@Parameter(name = "port", value = "9081"),
			@Parameter(name = "basePath", value = "/itkoExamples/EJB3UserControlBean") }))
  • serviceName = Any name you want to provide for this service
  • workingFolder = path of the directory where the RR pair and .vrs file is placed.
  • vsrConfig = name of recording session file i.e .vrs file.

Rest of the attributes are optional

Below is the example of creating and deploying virtual service using recorded traffic file.

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = LisaBankClientApplication.class)
@DevTestVirtualServer()
public class UserServiceTest {
	static final Log logger = LogFactory.getLog(UserServiceTest.class);

	@Autowired
	private BankService bankServices;

	@Rule
	public VirtualServicesRule rules = new VirtualServicesRule();
	
	@DevTestVirtualServiceFromVrs(serviceName = "getUserWithVrs", workingFolder = "soapWithVrs", vrsConfig = @Config(value = "transport.vrs", parameters = {
			@Parameter(name = "port", value = "9081"),
			@Parameter(name = "basePath", value = "/itkoExamples/EJB3UserControlBean") }))
	@Test
	public void getUser() {
		User[] users = bankServices.getListUser();
		assertNotNull(users);
		printUsers(users);
		assertEquals(1, users.length);
	}

	private void printUsers(User[] users) {
		for (User user : users) {
			logger.info(user.getFname() + " " + user.getLname() + " " + user.getLogin());
		}

	}
}

Getting Started

Code Library

Core Functionality

Version 1.4.0

Annotation DevTestVirtualServiceV3

Version 1.3.2

Acknowledgments

Clone this wiki locally