Skip to content

Commit

Permalink
增加拦截点
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyouling committed Feb 27, 2025
1 parent cc83193 commit 5444db5
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 317 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,34 @@ public void instanceEx() {
test("instanceEx", BREAKER_MSG, BREAKER_REQUEST_COUNT);
}

/**
* 错误注入-返回空
*/
@Test
public void faultNull() {
final String result = RequestUtils.get(BASE_URL + "faultNull", Collections.emptyMap(), String.class);
Assertions.assertNull(result);
}

/**
* 错误注入-抛异常
*/
@Test
public void faultThrowEx() {
test("faultThrowEx", "Request has been aborted by fault-ThrowException", 1);
}

/**
* 错误注入-返回空
*/
@Test
public void faultDelay() {
final long start = System.currentTimeMillis();
long delay = 2000L;
RequestUtils.get(BASE_URL + "faultDelay", Collections.emptyMap(), String.class);
Assertions.assertTrue((System.currentTimeMillis() - start) >= delay);
}

/**
* 隔离仓测试
*/
Expand All @@ -136,6 +164,15 @@ public void bulkHead() throws InterruptedException {
threadPoolExecutor.shutdown();
}

/**
* 重试
*/
@Test
public void retry() {
final String result = RequestUtils.get(BASE_URL + "retry", Collections.emptyMap(), String.class);
Assertions.assertEquals(result, "3");
}

/**
* 测试熔断-异常
*/
Expand Down
Loading

0 comments on commit 5444db5

Please sign in to comment.