`

介绍个不错的RESTFUL MOCK的工具wiremock

 
阅读更多
介绍个不错的RESTFUL MOCK的工具wiremock,地址在:
http://wiremock.org/docs/running-standalone/

简单使用:
java -jar wiremock-standalone-2.17.0.jar


public static void main(String[] args) throws IOException {
		configureFor(8682);
		removeAllMappings();

		mock("/order/1", "01");
		mock("/order/2", "02");
	}

	private static void mock(String url, String file) throws IOException {
		ClassPathResource resource = new ClassPathResource("mock/response/" + file + ".txt");
		String content = StringUtils.join(FileUtils.readLines(resource.getFile(), "UTF-8").toArray(), "\n");
		stubFor(get(urlPathEqualTo(url)).willReturn(aResponse().withBody(content).withStatus(200)));
	}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics