本文整理了Java中org.springframework.test.web.client.MockRestServiceServer.reset()
方法的一些代码示例,展示了MockRestServiceServer.reset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MockRestServiceServer.reset()
方法的具体详情如下:
包路径:org.springframework.test.web.client.MockRestServiceServer
类名称:MockRestServiceServer
方法名:reset
[英]Reset the internal state removing all expectations and recorded requests.
[中]重置内部状态,删除所有期望和记录的请求。
代码示例来源:origin: spring-projects/spring-framework
@Test
public void resetAndReuseServer() {
MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate).build();
server.expect(requestTo("/foo")).andRespond(withSuccess());
this.restTemplate.getForObject("/foo", Void.class);
server.verify();
server.reset();
server.expect(requestTo("/bar")).andRespond(withSuccess());
this.restTemplate.getForObject("/bar", Void.class);
server.verify();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void resetAndReuseServerWithUnorderedExpectationManager() {
MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate)
.ignoreExpectOrder(true).build();
server.expect(requestTo("/foo")).andRespond(withSuccess());
this.restTemplate.getForObject("/foo", Void.class);
server.verify();
server.reset();
server.expect(requestTo("/foo")).andRespond(withSuccess());
server.expect(requestTo("/bar")).andRespond(withSuccess());
this.restTemplate.getForObject("/bar", Void.class);
this.restTemplate.getForObject("/foo", Void.class);
server.verify();
}
代码示例来源:origin: org.springframework.boot/spring-boot-test-autoconfigure
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
ApplicationContext applicationContext = testContext.getApplicationContext();
String[] names = applicationContext
.getBeanNamesForType(MockRestServiceServer.class, false, false);
for (String name : names) {
applicationContext.getBean(name, MockRestServiceServer.class).reset();
}
}
内容来源于网络,如有侵权,请联系作者删除!