This is an automated email from the ASF dual-hosted git repository.
jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push:
new a948dc79c3 test: add unit test case for fury serializer (#7501)
a948dc79c3 is described below
commit a948dc79c3bc55235c1c7d13fcc90116954b745d
Author: GoodBoyCoder <[email protected]>
AuthorDate: Mon Jul 7 09:51:43 2025 +0800
test: add unit test case for fury serializer (#7501)
---
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
.../seata/serializer/fury/FurySerializerTest.java | 26 ++++++++++++++++++++++
.../java/org/seata/test/TestUnSafeSerializer.java | 26 ++++++++++++++++++++++
4 files changed, 54 insertions(+)
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index dd5580e529..10adc5b5e8 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -106,6 +106,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7457](https://github.com/apache/incubator-seata/pull/7457)] improve unit
test coverage of seata-rm moudle
- [[#7464](https://github.com/apache/incubator-seata/pull/7464)] improve unit
test coverage of seata-gRPC moudle
- [[#7468](https://github.com/apache/incubator-seata/pull/7468)] add UT for
SupportSqlWhereMethod class
+- [[#7501](https://github.com/apache/incubator-seata/pull/7501)] add unit test
case for fury serializer
### refactor:
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index feb02abf81..a3b362d45c 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -106,6 +106,7 @@
- [[#7457](https://github.com/apache/incubator-seata/pull/7457)] 增加 rm 模块的单测
- [[#7464](https://github.com/apache/incubator-seata/pull/7464)] 增加 gRPC 模块的单测
- [[#7468](https://github.com/apache/incubator-seata/pull/7468)] 为
SupportSqlWhereMethod 类添加 UT
+- [[#7501](https://github.com/apache/incubator-seata/pull/7501)] 补充Fury的单元测试用例
### refactor:
diff --git
a/serializer/seata-serializer-fury/src/test/java/org/apache/seata/serializer/fury/FurySerializerTest.java
b/serializer/seata-serializer-fury/src/test/java/org/apache/seata/serializer/fury/FurySerializerTest.java
index 95bc18be76..79e9325ed8 100644
---
a/serializer/seata-serializer-fury/src/test/java/org/apache/seata/serializer/fury/FurySerializerTest.java
+++
b/serializer/seata-serializer-fury/src/test/java/org/apache/seata/serializer/fury/FurySerializerTest.java
@@ -16,14 +16,20 @@
*/
package org.apache.seata.serializer.fury;
+import org.apache.fury.Fury;
+import org.apache.fury.config.CompatibleMode;
+import org.apache.fury.exception.DeserializationException;
+import org.apache.fury.exception.InsecureException;
import org.apache.seata.core.exception.TransactionExceptionCode;
import org.apache.seata.core.model.BranchStatus;
import org.apache.seata.core.model.BranchType;
import org.apache.seata.core.protocol.ResultCode;
import org.apache.seata.core.protocol.transaction.BranchCommitRequest;
import org.apache.seata.core.protocol.transaction.BranchCommitResponse;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.seata.test.TestUnSafeSerializer;
import static org.assertj.core.api.Assertions.assertThat;
@@ -76,4 +82,24 @@ public class FurySerializerTest {
assertThat(t.getMsg()).isEqualTo(branchCommitResponse.getMsg());
assertThat(t.getResultCode()).isEqualTo(branchCommitResponse.getResultCode());
}
+
+ @Test
+ public void testUnSafeDeserializer() {
+ // Test deserialization of an object that is not in allow list
+ TestUnSafeSerializer testUnSafeSerializer = new TestUnSafeSerializer();
+ Fury fury = Fury.builder()
+ .requireClassRegistration(false)
+ .withRefTracking(true)
+ .withCompatibleMode(CompatibleMode.COMPATIBLE)
+ .build();
+ Assertions.assertThrows(
+ DeserializationException.class, () ->
furySerializer.deserialize(fury.serialize(testUnSafeSerializer)));
+ }
+
+ @Test
+ public void testUnSafeSerializer() {
+ // Test serialization of an object that is not in allow list
+ TestUnSafeSerializer testUnSafeSerializer = new TestUnSafeSerializer();
+ Assertions.assertThrows(InsecureException.class, () ->
furySerializer.serialize(testUnSafeSerializer));
+ }
}
diff --git
a/serializer/seata-serializer-fury/src/test/java/org/seata/test/TestUnSafeSerializer.java
b/serializer/seata-serializer-fury/src/test/java/org/seata/test/TestUnSafeSerializer.java
new file mode 100644
index 0000000000..9127eedad0
--- /dev/null
+++
b/serializer/seata-serializer-fury/src/test/java/org/seata/test/TestUnSafeSerializer.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.seata.test;
+
+import org.apache.seata.core.protocol.AbstractMessage;
+
+public class TestUnSafeSerializer extends AbstractMessage {
+ @Override
+ public short getTypeCode() {
+ return 0;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]