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,