@Configuration
@ConditionalOnProperty(value="r-tools.rest-template.mock.enable",
havingValue="true")
@ConfigurationProperties(prefix="r-tools.rest-template.mock")
@Order
public class MockRestTemplateInterceptor
extends Object
implements org.springframework.http.client.ClientHttpRequestInterceptor, org.springframework.beans.factory.InitializingBean
可以指定url请求的返回值,用于开发测试阶段请求目标尚未准备好的场景,以及测试指定的返回值的场景
匹配url地址时,会包含url地址上的参数一起匹配,方便匹配get请求的参数
默认不启用 启用设置 r-tools.rest-template.mock.enable=true
url匹配规则| 限定符和类型 | 类和说明 |
|---|---|
static class |
MockRestTemplateInterceptor.MockConf |
| 构造器和说明 |
|---|
MockRestTemplateInterceptor() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
afterPropertiesSet() |
org.springframework.http.client.ClientHttpResponse |
intercept(org.springframework.http.HttpRequest request,
byte[] body,
org.springframework.http.client.ClientHttpRequestExecution execution) |
public void afterPropertiesSet()
afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBeanpublic org.springframework.http.client.ClientHttpResponse intercept(org.springframework.http.HttpRequest request,
byte[] body,
org.springframework.http.client.ClientHttpRequestExecution execution)
throws IOException
intercept 在接口中 org.springframework.http.client.ClientHttpRequestInterceptorIOExceptionCopyright © 2022. All rights reserved.