Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#8181](https://github.com/apache/incubator-seata/pull/8181)] fix AuthControllerWithRandomPasswordTest flaky failure caused by Spring Boot test context caching
- [[#8297](https://github.com/apache/incubator-seata/pull/8297)] upload JDK 25 coverage with Redis and Nacos tests, retain the JDK test matrix, and use the upstream Codecov CLI upload
- [[#8315](https://github.com/apache/incubator-seata/pull/8315)] run the gRPC interceptor GrpcTest on JUnit 5
- [[#8323](https://github.com/apache/incubator-seata/pull/8323)] assert expected exceptions in five core tests

### refactor:

Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
- [[#8181](https://github.com/apache/incubator-seata/pull/8181)] 修复 AuthControllerWithRandomPasswordTest 因 Spring Boot 测试上下文缓存导致的偶发失败
- [[#8297](https://github.com/apache/incubator-seata/pull/8297)] 保留 JDK 测试矩阵,改为上传 JDK 25 覆盖率并开启 Redis/Nacos 条件测试,沿用上游 Codecov CLI 上传方式
- [[#8315](https://github.com/apache/incubator-seata/pull/8315)] 使用 JUnit 5 运行 gRPC 拦截器 GrpcTest
- [[#8323](https://github.com/apache/incubator-seata/pull/8323)] 在五个 core 测试中断言预期异常

### refactor:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,9 @@ public void testGetHasResultWithRunTimeExceptionWithMessage() throws Exception {
messageFuture.setTimeout(TIME_OUT_FIELD);
RuntimeException runtimeException = new RuntimeException("test_runtime");
messageFuture.setResultMessage(runtimeException);
try {
messageFuture.get(TIME_OUT_FIELD, TimeUnit.MILLISECONDS);
} catch (Exception e) {
assertThat(e.getMessage()).isEqualTo(runtimeException.getMessage());
}
RuntimeException e = Assertions.assertThrows(
RuntimeException.class, () -> messageFuture.get(TIME_OUT_FIELD, TimeUnit.MILLISECONDS));
assertThat(e.getMessage()).isEqualTo(runtimeException.getMessage());
}

/**
Expand Down Expand Up @@ -177,11 +175,9 @@ public void testGetHasResultWithThrowableWithMessage() throws Exception {
messageFuture.setTimeout(TIME_OUT_FIELD);
Throwable throwable = new Throwable("test_throwable");
messageFuture.setResultMessage(throwable);
try {
messageFuture.get(TIME_OUT_FIELD, TimeUnit.MILLISECONDS);
} catch (Exception e) {
assertThat(e.getMessage()).isEqualTo(new RuntimeException(throwable).getMessage());
}
RuntimeException e = Assertions.assertThrows(
RuntimeException.class, () -> messageFuture.get(TIME_OUT_FIELD, TimeUnit.MILLISECONDS));
assertThat(e.getMessage()).isEqualTo(new RuntimeException(throwable).getMessage());
}

private RpcMessage buildRepcMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -306,11 +307,8 @@ public void testGetServerMessageSenderNotNull() {
public void testGetServerMessageSenderThrowsException() {
DefaultServerMessageListenerImpl newListener = new DefaultServerMessageListenerImpl(transactionMessageHandler);

try {
newListener.getServerMessageSender();
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("must not be null"));
}
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, newListener::getServerMessageSender);
assertTrue(e.getMessage().contains("must not be null"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.seata.core.rpc.netty;

import io.netty.channel.Channel;
import org.apache.seata.common.exception.FrameworkException;
import org.apache.seata.core.protocol.RegisterRMRequest;
import org.apache.seata.core.protocol.RegisterTMRequest;
import org.apache.seata.core.rpc.RpcContext;
Expand All @@ -37,6 +38,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -291,11 +293,10 @@ public void testGetChannelWithEmptyResourceId() {
@Test
public void testGetChannelWithInvalidClientId() {
String clientId = "invalid-client-id";
try {
ChannelManager.getChannel("jdbc:mysql://localhost:3306/seata", clientId, false);
} catch (Exception e) {
assertTrue(e.getMessage().contains("Invalid Client ID"), "Should throw exception for invalid client ID");
}
FrameworkException e = assertThrows(
FrameworkException.class,
() -> ChannelManager.getChannel("jdbc:mysql://localhost:3306/seata", clientId, false));
assertTrue(e.getMessage().contains("Invalid Client ID"), "Should throw exception for invalid client ID");
}

@Test
Expand Down Expand Up @@ -595,13 +596,12 @@ public void testGetChannelWithClientIdWithoutSplitChar() throws Exception {
ChannelManager.registerRMChannel(request, channel);

String clientIdWithoutSplit = "testappnosplit";
try {
ChannelManager.getChannel("jdbc:mysql://localhost:3306/seata", clientIdWithoutSplit, false);
} catch (Exception e) {
assertTrue(
e.getMessage().contains("Invalid Client ID"),
"Should throw exception for clientId without split character");
}
FrameworkException e = assertThrows(
FrameworkException.class,
() -> ChannelManager.getChannel("jdbc:mysql://localhost:3306/seata", clientIdWithoutSplit, false));
assertTrue(
e.getMessage().contains("Invalid Client ID"),
"Should throw exception for clientId without split character");
}

@Test
Expand Down
Loading