Skip to content

Create and Deploy Multiple Virtual Services Before a Test

sachinmaske edited this page Oct 20, 2022 · 1 revision

This example explains how multiple virtual services can be created for a single test case.

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = LisaBankClientApplication.class)
@DevTestVirtualServer()

public class AccountServiceTest {
	@Autowired
	private BankService bankServices;
	
	// Rule to handle Class scope Devtest Annotations
	@ClassRule
	public static VirtualServiceClassScopeRule ruleClass= new VirtualServiceClassScopeRule();
	// Rule to handle Method scope Devtest Annotations
	@Rule
	public VirtualServicesRule rules = new VirtualServicesRule();

	@DevTestVirtualServiceV3(serviceName = "UserServiceTest-EJB3UserControlBean",
			port = "9081",
			basePath = "/itkoExamples/EJB3UserControlBean",
			workingFolder = "AccountServiceTest/createUserWithCheckingAccount/v3/EJB3UserControlBean",
			inputFile1 = "rrpair.zip",
			dataProtocolsConfig = {
				@DataProtocolConfig(
					typeId = "SOAPDPH"
				)
			}
	)

	@DevTestVirtualServiceV3(serviceName = "UserServiceTest-EJB3AccountControlBean",
			port = "9081",
			basePath = "/itkoExamples/EJB3AccountControlBean",
			workingFolder = "AccountServiceTest/createUserWithCheckingAccount/v3/EJB3AccountControlBean",
			inputFile1 = "rrpair.zip",
			dataProtocolsConfig = {
				@DataProtocolConfig(
					typeId = "SOAPDPH"
				)
			}
	)


	@Test
	public void createUserWithCheckingAccountV3() {

		// Given
		String user = "pascal";
		String password = "password";
		int amount = 1000;
		// prepare context
		// bankServices.deleteUser(user);
		// When
		Account account = bankServices.createUserWithCheckingAccount(user, password, amount);
		// Then
		assertNotNull(account);
		assertEquals("Le balance du compte n'est pas conforme", amount, account.getBalance().intValue());
	}

}

Getting Started

Code Library

Core Functionality

Version 1.4.0

Annotation DevTestVirtualServiceV3

Version 1.3.2

Acknowledgments

Clone this wiki locally