use of com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testUnsubscribe.
@Test
public void testUnsubscribe() throws NacosException, IllegalAccessException, NoSuchFieldException {
String ns = "ns1";
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
Properties props = new Properties();
props.setProperty("serverAddr", "localhost");
InstancesChangeNotifier notifier = new InstancesChangeNotifier();
NamingClientProxyDelegate delegate = new NamingClientProxyDelegate(ns, holder, props, notifier);
NamingGrpcClientProxy mockGrpcClient = Mockito.mock(NamingGrpcClientProxy.class);
Field grpcClientProxyField = NamingClientProxyDelegate.class.getDeclaredField("grpcClientProxy");
grpcClientProxyField.setAccessible(true);
grpcClientProxyField.set(delegate, mockGrpcClient);
String serviceName = "service1";
String groupName = "group1";
String clusters = "cluster1";
delegate.unsubscribe(serviceName, groupName, clusters);
verify(mockGrpcClient, times(1)).unsubscribe(serviceName, groupName, clusters);
}
use of com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testServerHealthy.
@Test
public void testServerHealthy() throws IllegalAccessException, NacosException, NoSuchFieldException {
String ns = "ns1";
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
Properties props = new Properties();
props.setProperty("serverAddr", "localhost");
InstancesChangeNotifier notifier = new InstancesChangeNotifier();
NamingClientProxyDelegate delegate = new NamingClientProxyDelegate(ns, holder, props, notifier);
NamingGrpcClientProxy mockGrpcClient = Mockito.mock(NamingGrpcClientProxy.class);
Field grpcClientProxyField = NamingClientProxyDelegate.class.getDeclaredField("grpcClientProxy");
grpcClientProxyField.setAccessible(true);
grpcClientProxyField.set(delegate, mockGrpcClient);
Mockito.when(mockGrpcClient.serverHealthy()).thenReturn(true);
Assert.assertTrue(delegate.serverHealthy());
}
use of com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testGetServiceList.
@Test
public void testGetServiceList() throws NacosException, NoSuchFieldException, IllegalAccessException {
String ns = "ns1";
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
Properties props = new Properties();
props.setProperty("serverAddr", "localhost");
InstancesChangeNotifier notifier = new InstancesChangeNotifier();
NamingClientProxyDelegate delegate = new NamingClientProxyDelegate(ns, holder, props, notifier);
NamingGrpcClientProxy mockGrpcClient = Mockito.mock(NamingGrpcClientProxy.class);
Field grpcClientProxyField = NamingClientProxyDelegate.class.getDeclaredField("grpcClientProxy");
grpcClientProxyField.setAccessible(true);
grpcClientProxyField.set(delegate, mockGrpcClient);
AbstractSelector selector = new ExpressionSelector();
int pageNo = 1;
int pageSize = 10;
String groupName = "group2";
delegate.getServiceList(pageNo, pageSize, groupName, selector);
verify(mockGrpcClient, times(1)).getServiceList(pageNo, pageSize, groupName, selector);
}
use of com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testShutdown.
@Test
public void testShutdown() throws NacosException, IllegalAccessException, NoSuchFieldException {
String ns = "ns1";
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
Properties props = new Properties();
props.setProperty("serverAddr", "localhost");
InstancesChangeNotifier notifier = new InstancesChangeNotifier();
NamingClientProxyDelegate delegate = new NamingClientProxyDelegate(ns, holder, props, notifier);
NamingGrpcClientProxy mockGrpcClient = Mockito.mock(NamingGrpcClientProxy.class);
Field grpcClientProxyField = NamingClientProxyDelegate.class.getDeclaredField("grpcClientProxy");
grpcClientProxyField.setAccessible(true);
grpcClientProxyField.set(delegate, mockGrpcClient);
delegate.shutdown();
verify(mockGrpcClient, times(1)).shutdown();
}
use of com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testQueryInstancesOfService.
@Test
public void testQueryInstancesOfService() throws NacosException, IllegalAccessException, NoSuchFieldException {
String ns = "ns1";
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
Properties props = new Properties();
props.setProperty("serverAddr", "localhost");
InstancesChangeNotifier notifier = new InstancesChangeNotifier();
NamingClientProxyDelegate delegate = new NamingClientProxyDelegate(ns, holder, props, notifier);
NamingGrpcClientProxy mockGrpcClient = Mockito.mock(NamingGrpcClientProxy.class);
Field grpcClientProxyField = NamingClientProxyDelegate.class.getDeclaredField("grpcClientProxy");
grpcClientProxyField.setAccessible(true);
grpcClientProxyField.set(delegate, mockGrpcClient);
String serviceName = "service1";
String groupName = "group1";
String clusters = "cluster1";
delegate.queryInstancesOfService(serviceName, groupName, clusters, 0, false);
verify(mockGrpcClient, times(1)).queryInstancesOfService(serviceName, groupName, clusters, 0, false);
}
Aggregations