Skip to content

Commit 440bb41

Browse files
committed
test: add some UT for server/cluster module
1 parent 08360f3 commit 440bb41

File tree

8 files changed

+27
-16
lines changed

8 files changed

+27
-16
lines changed

server/src/test/java/org/apache/seata/server/cluster/listener/ClusterChangeEventTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.seata.server.cluster.listener;
1818

1919
import org.junit.jupiter.api.Test;
20+
2021
import java.time.Clock;
2122

2223
import static org.junit.jupiter.api.Assertions.*;

server/src/test/java/org/apache/seata/server/cluster/raft/sync/msg/RaftBaseMsgTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.seata.server.cluster.raft.sync.msg;
1818

1919
import org.junit.jupiter.api.Test;
20+
2021
import java.io.ByteArrayInputStream;
2122
import java.io.ByteArrayOutputStream;
2223
import java.io.ObjectInputStream;

server/src/test/java/org/apache/seata/server/cluster/raft/sync/msg/RaftBranchSessionSyncMsgTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.seata.server.cluster.raft.sync.msg.dto.BranchTransactionDTO;
2020
import org.junit.jupiter.api.Test;
21+
2122
import java.io.ByteArrayInputStream;
2223
import java.io.ByteArrayOutputStream;
2324
import java.io.ObjectInputStream;
@@ -40,8 +41,7 @@ public void testDefaultConstructor() {
4041
@Test
4142
public void testConstructorWithParameters() {
4243
BranchTransactionDTO dto = new BranchTransactionDTO("xid:123", 456L);
43-
RaftBranchSessionSyncMsg msg = new RaftBranchSessionSyncMsg(
44-
RaftSyncMsgType.ADD_BRANCH_SESSION, dto);
44+
RaftBranchSessionSyncMsg msg = new RaftBranchSessionSyncMsg(RaftSyncMsgType.ADD_BRANCH_SESSION, dto);
4545

4646
assertEquals(RaftSyncMsgType.ADD_BRANCH_SESSION, msg.getMsgType());
4747
assertEquals(dto, msg.getBranchSession());
@@ -66,8 +66,7 @@ public void testSetAndGetGroup() {
6666
@Test
6767
public void testToString() {
6868
BranchTransactionDTO dto = new BranchTransactionDTO("xid:123", 456L);
69-
RaftBranchSessionSyncMsg msg = new RaftBranchSessionSyncMsg(
70-
RaftSyncMsgType.UPDATE_BRANCH_SESSION_STATUS, dto);
69+
RaftBranchSessionSyncMsg msg = new RaftBranchSessionSyncMsg(RaftSyncMsgType.UPDATE_BRANCH_SESSION_STATUS, dto);
7170

7271
String str = msg.toString();
7372
assertNotNull(str);
@@ -78,8 +77,7 @@ public void testToString() {
7877
public void testSerialization() throws Exception {
7978
BranchTransactionDTO dto = new BranchTransactionDTO("xid:123", 456L);
8079
dto.setLockKey("table:1,2,3");
81-
RaftBranchSessionSyncMsg original = new RaftBranchSessionSyncMsg(
82-
RaftSyncMsgType.ADD_BRANCH_SESSION, dto);
80+
RaftBranchSessionSyncMsg original = new RaftBranchSessionSyncMsg(RaftSyncMsgType.ADD_BRANCH_SESSION, dto);
8381
original.setGroup("test-group");
8482

8583
// Serialize
@@ -97,7 +95,11 @@ public void testSerialization() throws Exception {
9795
// Verify
9896
assertEquals(original.getMsgType(), deserialized.getMsgType());
9997
assertEquals(original.getGroup(), deserialized.getGroup());
100-
assertEquals(original.getBranchSession().getXid(), deserialized.getBranchSession().getXid());
101-
assertEquals(original.getBranchSession().getBranchId(), deserialized.getBranchSession().getBranchId());
98+
assertEquals(
99+
original.getBranchSession().getXid(),
100+
deserialized.getBranchSession().getXid());
101+
assertEquals(
102+
original.getBranchSession().getBranchId(),
103+
deserialized.getBranchSession().getBranchId());
102104
}
103105
}

server/src/test/java/org/apache/seata/server/cluster/raft/sync/msg/RaftClusterMetadataMsgTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.seata.server.cluster.raft.sync.msg.dto.RaftClusterMetadata;
2020
import org.junit.jupiter.api.Test;
21+
2122
import java.io.ByteArrayInputStream;
2223
import java.io.ByteArrayOutputStream;
2324
import java.io.ObjectInputStream;
@@ -81,6 +82,8 @@ public void testSerialization() throws Exception {
8182

8283
// Verify
8384
assertEquals(original.getMsgType(), deserialized.getMsgType());
84-
assertEquals(original.getRaftClusterMetadata().getTerm(), deserialized.getRaftClusterMetadata().getTerm());
85+
assertEquals(
86+
original.getRaftClusterMetadata().getTerm(),
87+
deserialized.getRaftClusterMetadata().getTerm());
8588
}
8689
}

server/src/test/java/org/apache/seata/server/cluster/raft/sync/msg/RaftGlobalSessionSyncMsgTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.seata.server.cluster.raft.sync.msg.dto.GlobalTransactionDTO;
2020
import org.junit.jupiter.api.Test;
21+
2122
import java.io.ByteArrayInputStream;
2223
import java.io.ByteArrayOutputStream;
2324
import java.io.ObjectInputStream;
@@ -38,8 +39,7 @@ public void testDefaultConstructor() {
3839
@Test
3940
public void testConstructorWithParameters() {
4041
GlobalTransactionDTO dto = new GlobalTransactionDTO("xid:123456");
41-
RaftGlobalSessionSyncMsg msg = new RaftGlobalSessionSyncMsg(
42-
RaftSyncMsgType.ADD_GLOBAL_SESSION, dto);
42+
RaftGlobalSessionSyncMsg msg = new RaftGlobalSessionSyncMsg(RaftSyncMsgType.ADD_GLOBAL_SESSION, dto);
4343

4444
assertEquals(RaftSyncMsgType.ADD_GLOBAL_SESSION, msg.getMsgType());
4545
assertEquals(dto, msg.getGlobalSession());
@@ -57,8 +57,7 @@ public void testSetAndGetGlobalSession() {
5757
@Test
5858
public void testToString() {
5959
GlobalTransactionDTO dto = new GlobalTransactionDTO("xid:123");
60-
RaftGlobalSessionSyncMsg msg = new RaftGlobalSessionSyncMsg(
61-
RaftSyncMsgType.REMOVE_GLOBAL_SESSION, dto);
60+
RaftGlobalSessionSyncMsg msg = new RaftGlobalSessionSyncMsg(RaftSyncMsgType.REMOVE_GLOBAL_SESSION, dto);
6261

6362
String str = msg.toString();
6463
assertNotNull(str);
@@ -68,8 +67,8 @@ public void testToString() {
6867
@Test
6968
public void testSerialization() throws Exception {
7069
GlobalTransactionDTO dto = new GlobalTransactionDTO("xid:123456");
71-
RaftGlobalSessionSyncMsg original = new RaftGlobalSessionSyncMsg(
72-
RaftSyncMsgType.UPDATE_GLOBAL_SESSION_STATUS, dto);
70+
RaftGlobalSessionSyncMsg original =
71+
new RaftGlobalSessionSyncMsg(RaftSyncMsgType.UPDATE_GLOBAL_SESSION_STATUS, dto);
7372

7473
// Serialize
7574
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -85,6 +84,8 @@ public void testSerialization() throws Exception {
8584

8685
// Verify
8786
assertEquals(original.getMsgType(), deserialized.getMsgType());
88-
assertEquals(original.getGlobalSession().getXid(), deserialized.getGlobalSession().getXid());
87+
assertEquals(
88+
original.getGlobalSession().getXid(),
89+
deserialized.getGlobalSession().getXid());
8990
}
9091
}

server/src/test/java/org/apache/seata/server/cluster/raft/sync/msg/dto/BranchTransactionDTOTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.seata.server.cluster.raft.sync.msg.dto;
1818

1919
import org.junit.jupiter.api.Test;
20+
2021
import java.io.ByteArrayInputStream;
2122
import java.io.ByteArrayOutputStream;
2223
import java.io.ObjectInputStream;

server/src/test/java/org/apache/seata/server/cluster/raft/sync/msg/dto/GlobalTransactionDTOTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.seata.server.cluster.raft.sync.msg.dto;
1818

1919
import org.junit.jupiter.api.Test;
20+
2021
import java.io.ByteArrayInputStream;
2122
import java.io.ByteArrayOutputStream;
2223
import java.io.ObjectInputStream;

server/src/test/java/org/apache/seata/server/cluster/raft/sync/msg/dto/RaftClusterMetadataTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.seata.common.metadata.Node;
2020
import org.junit.jupiter.api.Test;
21+
2122
import java.util.Arrays;
2223

2324
import static org.junit.jupiter.api.Assertions.*;

0 commit comments

Comments
 (0)