From 23f4b14dba26bbe3311465b613daab06bba11de5 Mon Sep 17 00:00:00 2001 From: cancaicai <2356672992@qq.com> Date: Mon, 2 Sep 2024 15:14:00 +0800 Subject: [PATCH] chore: improve rpcresponseFactoryTest --- .../sofa/jraft/rpc/RpcResponseFactoryTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jraft-core/src/test/java/com/alipay/sofa/jraft/rpc/RpcResponseFactoryTest.java b/jraft-core/src/test/java/com/alipay/sofa/jraft/rpc/RpcResponseFactoryTest.java index 74852443f..679c78153 100644 --- a/jraft-core/src/test/java/com/alipay/sofa/jraft/rpc/RpcResponseFactoryTest.java +++ b/jraft-core/src/test/java/com/alipay/sofa/jraft/rpc/RpcResponseFactoryTest.java @@ -26,6 +26,13 @@ import static org.junit.Assert.assertEquals; public class RpcResponseFactoryTest { + @Test + public void testNewResponseWithNull() { + ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, null); + assertEquals(response.getErrorCode(), 0); + assertEquals(response.getErrorMsg(), "OK"); + } + @Test public void testNewResponseFromStatus() { ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, Status.OK()); @@ -42,13 +49,21 @@ public void testNewResponseWithErrorStatus() { } @Test - public void testNewResponseWithVaridicArgs() { + public void testNewResponseWithVaridicNumberArgs() { ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, 300, "hello %s %d", "world", 99); assertEquals(response.getErrorCode(), 300); assertEquals(response.getErrorMsg(), "hello world 99"); } + @Test + public void testNewResponseWithVaridicStringArgs() { + ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, 300, + "hello %s %s", "world", "99"); + assertEquals(response.getErrorCode(), 300); + assertEquals(response.getErrorMsg(), "hello world 99"); + } + @Test public void testNewResponseWithArgs() { ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, 300,