Files
ManuAgent/server/src/test/java/tech/easyflow/manuagent/common/GlobalExceptionHandlerTest.java
2026-08-29 14:02:28 +08:00

25 lines
770 B
Java

package tech.easyflow.manuagent.common;
import static org.assertj.core.api.Assertions.assertThatCode;
import org.junit.jupiter.api.Test;
import org.springframework.web.context.request.async.AsyncRequestNotUsableException;
/**
* 验证统一异常边界对流式连接终止的处理。
*/
class GlobalExceptionHandlerTest {
/**
* 客户端断开已提交的流式响应时不再尝试写入 JSON 错误体。
*/
@Test
void shouldIgnoreExpectedStreamDisconnect() {
GlobalExceptionHandler handler = new GlobalExceptionHandler();
assertThatCode(() -> handler.handleClientDisconnect(
new AsyncRequestNotUsableException("ServletOutputStream failed to flush")))
.doesNotThrowAnyException();
}
}