use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class BaseCliRequestProcessorTest method testEmptyNodes.
@Test
public void testEmptyNodes() {
this.processor = new MockCliRequestProcessor(null, "test");
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(RaftError.ENOENT.getNumber(), resp.getErrorCode());
assertEquals("Empty nodes in group test", resp.getErrorMsg());
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class BaseCliRequestProcessorTest method testPeerIdNotFound.
@Test
public void testPeerIdNotFound() {
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(RaftError.ENOENT.getNumber(), resp.getErrorCode());
assertEquals("Fail to find node localhost:8081 in group test", resp.getErrorMsg());
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class BaseCliRequestProcessorTest method testDisableCli.
@Test
public void testDisableCli() {
mockNode(true);
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(RaftError.EACCES.getNumber(), resp.getErrorCode());
assertEquals("Cli service is not allowed to access node <test/localhost:8081>", resp.getErrorMsg());
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class NodeRequestProcessorTest method testOK.
@Test
public void testOK() {
Node node = Mockito.mock(Node.class, withSettings().extraInterfaces(RaftServerService.class));
Mockito.when(node.getGroupId()).thenReturn("test");
PeerId peerId = new PeerId("localhost", 8081);
Mockito.when(node.getNodeId()).thenReturn(new NodeId("test", peerId));
NodeManager.getInstance().addAddress(peerId.getEndpoint());
NodeManager.getInstance().add(node);
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(0, resp.getErrorCode());
}
use of com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse in project sofa-jraft by sofastack.
the class PingRequestProcessorTest method testHandlePing.
@Test
public void testHandlePing() throws Exception {
PingRequestProcessor processor = new PingRequestProcessor();
MockAsyncContext ctx = new MockAsyncContext();
processor.handleRequest(ctx, TestUtils.createPingRequest());
ErrorResponse response = (ErrorResponse) ctx.getResponseObject();
assertEquals(0, response.getErrorCode());
}
Aggregations