Skip to content

Commit 6b8e85d

Browse files
author
maple
committed
bugfix: ensure visibility of rm and The methods in MockTest are executed in order
1 parent cb3e99b commit 6b8e85d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

test-old-version/src/test/java/io/seata/MockTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@
2929
import io.seata.rm.DefaultResourceManager;
3030
import org.apache.seata.mockserver.MockCoordinator;
3131
import org.apache.seata.mockserver.MockServer;
32-
import org.junit.jupiter.api.AfterAll;
33-
import org.junit.jupiter.api.Assertions;
34-
import org.junit.jupiter.api.BeforeAll;
35-
import org.junit.jupiter.api.Test;
32+
import org.junit.jupiter.api.*;
3633
import org.slf4j.Logger;
3734
import org.slf4j.LoggerFactory;
3835

3936
/**
4037
* the type MockServerTest
4138
*/
39+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
4240
public class MockTest {
4341

4442
static String RESOURCE_ID = "mock-action-061";
@@ -57,39 +55,45 @@ public static void after() {
5755
}
5856

5957
@Test
58+
@Order(1)
6059
public void testCommit() throws Exception {
6160
String xid = doTestCommit(0);
6261
Assertions.assertEquals(1, Action1Impl.getCommitTimes(xid));
6362
Assertions.assertEquals(0, Action1Impl.getRollbackTimes(xid));
6463
}
6564

6665
@Test
66+
@Order(2)
6767
public void testCommitRetry() throws Exception {
6868
String xid = doTestCommit(2);
6969
Assertions.assertEquals(3, Action1Impl.getCommitTimes(xid));
7070
Assertions.assertEquals(0, Action1Impl.getRollbackTimes(xid));
7171
}
7272

7373
@Test
74+
@Order(3)
7475
public void testRollback() throws Exception {
7576
String xid = doTestRollback(0);
7677
Assertions.assertEquals(0, Action1Impl.getCommitTimes(xid));
7778
Assertions.assertEquals(1, Action1Impl.getRollbackTimes(xid));
7879
}
7980

8081
@Test
82+
@Order(4)
8183
public void testRollbackRetry() throws Exception {
8284
String xid = doTestRollback(2);
8385
Assertions.assertEquals(0, Action1Impl.getCommitTimes(xid));
8486
Assertions.assertEquals(3, Action1Impl.getRollbackTimes(xid));
8587
}
8688

8789
@Test
90+
@Order(5)
8891
public void testTm() throws Exception {
8992
TmClientTest.testTm();
9093
}
9194

9295
@Test
96+
@Order(6)
9397
public void testRm() throws Exception {
9498
RmClientTest.testRm("testRM01");
9599
}

test-old-version/src/test/java/io/seata/core/rpc/netty/RmClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
public class RmClientTest {
3636

3737
protected static final Logger LOGGER = LoggerFactory.getLogger(RmClientTest.class);
38-
private static DefaultResourceManager rm = null;
38+
private static volatile DefaultResourceManager rm = null;
3939

4040
public static void testRm(String resourceId) throws TransactionException, NoSuchMethodException {
4141
String xid = "1111";

0 commit comments

Comments
 (0)