Skip to content

Commit

Permalink
test update
Browse files Browse the repository at this point in the history
  • Loading branch information
chentianming11 committed May 24, 2022
1 parent 34f0aad commit 651cc2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.lianjiatech.retrofit.spring.boot.test.custom.okhttp;

import java.time.Duration;

import org.springframework.stereotype.Component;

import com.github.lianjiatech.retrofit.spring.boot.core.Constants;
Expand All @@ -22,6 +24,9 @@ public void register(SourceOkHttpClientRegistry registry) {

// 替换默认的SourceOkHttpClient
registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(5))
.writeTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.addInterceptor(chain -> {
log.info("============替换默认的SourceOkHttpClient=============");
return chain.proceed(chain.request());
Expand All @@ -30,6 +35,9 @@ public void register(SourceOkHttpClientRegistry registry) {

// 添加新的SourceOkHttpClient
registry.register("testSourceOkHttpClient", new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(5))
.writeTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.addInterceptor(chain -> {
log.info("============使用testSourceOkHttpClient=============");
return chain.proceed(chain.request());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public void register(CircuitBreakerConfigRegistry registry) {
// 注册其它的CircuitBreakerConfig
registry.register("testCircuitBreakerConfig", CircuitBreakerConfig.custom()
.slidingWindowType(CircuitBreakerConfig.SlidingWindowType.TIME_BASED)
.failureRateThreshold(30)
.minimumNumberOfCalls(10)
.failureRateThreshold(20)
.minimumNumberOfCalls(5)
.permittedNumberOfCallsInHalfOpenState(5)
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testDegradeR4j() {
.addHeader("Content-Type", "application/text; charset=utf-8")
.addHeader("Cache-Control", "no-cache")
.setBody(objectMapper.writeValueAsString(mockResult))
.setBodyDelay(10, TimeUnit.SECONDS);
.setBodyDelay(6, TimeUnit.SECONDS);
server.enqueue(response);
return degradeR4jApi.getPerson1(2L).getCode();
} catch (Exception e) {
Expand Down

0 comments on commit 651cc2d

Please sign in to comment.