use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class ProtobufSerializerTest method testEncodeDecodeResponseContent.
@Test
public void testEncodeDecodeResponseContent() throws Exception {
final PingRequest reqObject = TestUtils.createPingRequest();
final RpcRequestCommand request = cmdFactory.createRequestCommand(reqObject);
final ErrorResponse respObject = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, new Status(-1, "test"));
final RpcResponseCommand response = cmdFactory.createResponse(respObject, request);
response.setResponseClass(ErrorResponse.class.getName());
assertTrue(serializer.serializeContent(response));
response.setResponseObject(null);
assertTrue(serializer.deserializeContent(response, null));
assertNotNull(response.getResponseObject());
assertEquals(respObject, response.getResponseObject());
assertNotSame(respObject, response.getResponseObject());
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class RpcResponseFactoryTest method testNewResponseWithVaridicArgs.
@Test
public void testNewResponseWithVaridicArgs() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, 300, "hello %s %d", "world", 99);
assertEquals(response.getErrorCode(), 300);
assertEquals(response.getErrorMsg(), "hello world 99");
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class RpcResponseFactoryTest method testNewResponseWithErrorStatus.
@Test
public void testNewResponseWithErrorStatus() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, new Status(300, "test"));
assertEquals(response.getErrorCode(), 300);
assertEquals(response.getErrorMsg(), "test");
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class RpcResponseFactoryTest method testNewResponseWithRaftError.
@Test
public void testNewResponseWithRaftError() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, RaftError.EAGAIN, "hello world");
assertEquals(response.getErrorCode(), RaftError.EAGAIN.getNumber());
assertEquals(response.getErrorMsg(), "hello world");
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class BaseCliRequestProcessorTest method testSingleNode.
@Test
public void testSingleNode() {
Node node = this.mockNode(false);
this.processor = new MockCliRequestProcessor(null, "test");
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertSame(this.processor.ctx.node, node);
assertNotNull(resp);
assertEquals(0, resp.getErrorCode());
}
Aggregations