use of com.alibaba.nacos.api.remote.response.HealthCheckResponse in project nacos by alibaba.
the class GrpcRequestAcceptorTest method testHandleRequestSuccess.
@Test
public void testHandleRequestSuccess() {
ApplicationUtils.setStarted(true);
Mockito.when(requestHandlerRegistry.getByRequestType(Mockito.anyString())).thenReturn(mockHandler);
Mockito.when(connectionManager.checkValid(Mockito.any())).thenReturn(true);
String ip = "1.1.1.1";
ConnectionMeta connectionMeta = new ConnectionMeta(connectId, ip, ip, 8888, 9848, "GRPC", "", "", new HashMap<>());
Connection connection = new GrpcConnection(connectionMeta, null, null);
Mockito.when(connectionManager.getConnection(Mockito.any())).thenReturn(connection);
RequestMeta metadata = new RequestMeta();
metadata.setClientIp("127.0.0.1");
metadata.setConnectionId(connectId);
HealthCheckRequest mockRequest = new HealthCheckRequest();
Payload payload = GrpcUtils.convert(mockRequest, metadata);
StreamObserver<Payload> streamObserver = new StreamObserver<Payload>() {
@Override
public void onNext(Payload payload) {
System.out.println("Receive data from server: " + payload);
Object res = GrpcUtils.parse(payload);
Assert.assertTrue(res instanceof HealthCheckResponse);
}
@Override
public void onError(Throwable throwable) {
Assert.fail(throwable.getMessage());
}
@Override
public void onCompleted() {
System.out.println("complete");
}
};
streamStub.request(payload, streamObserver);
ApplicationUtils.setStarted(false);
}
use of com.alibaba.nacos.api.remote.response.HealthCheckResponse in project nacos by alibaba.
the class HealthCheckRequestHandlerTest method testHandle.
@Test
public void testHandle() {
HealthCheckRequestHandler handler = new HealthCheckRequestHandler();
HealthCheckResponse response = handler.handle(null, null);
Assert.assertNotNull(response);
}
Aggregations