当前位置: 首页>>代码示例>>Java>>正文


Java WireMockRule.stubFor方法代码示例

本文整理汇总了Java中com.github.tomakehurst.wiremock.junit.WireMockRule.stubFor方法的典型用法代码示例。如果您正苦于以下问题:Java WireMockRule.stubFor方法的具体用法?Java WireMockRule.stubFor怎么用?Java WireMockRule.stubFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.tomakehurst.wiremock.junit.WireMockRule的用法示例。


在下文中一共展示了WireMockRule.stubFor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MockPersistenceProvider

import com.github.tomakehurst.wiremock.junit.WireMockRule; //导入方法依赖的package包/类
/**
 * Create a mock persistence using a wire mock rule.
 * Recommended: Use {@link #DEFAULT_MOCK_PERSISTENCE_PORT} as port.
 * @param rule The wire mock rule to create the mocking stubs for.
 */
public MockPersistenceProvider(WireMockRule rule) {
	this.port = rule.port();
	rule.stubFor(WireMock.get(WireMock.urlEqualTo(
			"/" + Service.PERSISTENCE.getServiceName() + "/rest/orders"))
					.willReturn(WireMock.okJson(getOrders())));
	rule.stubFor(WireMock.get(WireMock.urlEqualTo(
			"/" + Service.PERSISTENCE.getServiceName() + "/rest/orderitems"))
					.willReturn(WireMock.okJson(getOrderItems())));
	rule.stubFor(WireMock.get(WireMock.urlEqualTo(
			"/" + Service.PERSISTENCE.getServiceName() + "/rest/generatedb/finished"))
					.willReturn(WireMock.ok("true")));
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:18,代码来源:MockPersistenceProvider.java

示例2: initializeServiceQueryStubs

import com.github.tomakehurst.wiremock.junit.WireMockRule; //导入方法依赖的package包/类
private void initializeServiceQueryStubs(WireMockRule rule,
		List<Integer> persistencePorts, List<Integer> recommenderPorts)
		throws JsonProcessingException {
	List<String> persistences = new LinkedList<String>();
	for (int persistencePort: persistencePorts) {
		persistences.add("localhost:" + persistencePort);
	}
	String json = new ObjectMapper().writeValueAsString(persistences);
	rule.stubFor(WireMock.get(WireMock.urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.PERSISTENCE.getServiceName() + "/"))
					.willReturn(WireMock.okJson(json)));
	List<String> recommenders = new LinkedList<String>();
	for (int recommenderPort: recommenderPorts) {
		recommenders.add("localhost:" + recommenderPort);
	}
	json = new ObjectMapper().writeValueAsString(recommenders);
	rule.stubFor(WireMock.get(WireMock.urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.RECOMMENDER.getServiceName() + "/"))
					.willReturn(WireMock.okJson(json)));
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:21,代码来源:MockRegistry.java

示例3: initializeUpdateAndHeartbeatStubs

import com.github.tomakehurst.wiremock.junit.WireMockRule; //导入方法依赖的package包/类
private void initializeUpdateAndHeartbeatStubs(WireMockRule rule) {
	rule.stubFor(WireMock.put(WireMock.urlMatching(
			"/tools.descartes.petsupplystore.registry/rest/services/.*"))
					.willReturn(WireMock.ok()));
	rule.stubFor(WireMock.delete(WireMock.urlMatching(
			"/tools.descartes.petsupplystore.registry/rest/services/.*"))
					.willReturn(WireMock.ok()));
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:9,代码来源:MockRegistry.java

示例4: initializeMockRegistry

import com.github.tomakehurst.wiremock.junit.WireMockRule; //导入方法依赖的package包/类
private void initializeMockRegistry(WireMockRule wireMockRule, int count, int startport)
		throws JsonProcessingException {
	List<String> strings = new LinkedList<String>();
	for (int i = 0; i < count; i++) {
		strings.add("localhost:" + (startport + i));
	}
	String json = new ObjectMapper().writeValueAsString(strings);
	wireMockRule.stubFor(WireMock.get(WireMock.urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.PERSISTENCE.getServiceName()))
					.willReturn(WireMock.okJson(json)));
	wireMockRule.stubFor(WireMock.post(WireMock.urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/"
					+ Service.PERSISTENCE.getServiceName() + "/*"))
	.willReturn(WireMock.ok()));
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:16,代码来源:TomcatTestHandler.java


注:本文中的com.github.tomakehurst.wiremock.junit.WireMockRule.stubFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。