use of com.alibaba.nacos.client.naming.remote.NamingClientProxy in project nacos by alibaba.
the class NamingTestUtils method getBeatReactorByReflection.
public static BeatReactor getBeatReactorByReflection(NamingService namingService) throws NoSuchFieldException, IllegalAccessException {
Field clientProxyField = namingService.getClass().getDeclaredField("clientProxy");
clientProxyField.setAccessible(true);
NamingClientProxy namingClientProxy = (NamingClientProxy) clientProxyField.get(namingService);
Field httpClientProxyField = namingClientProxy.getClass().getDeclaredField("httpClientProxy");
httpClientProxyField.setAccessible(true);
NamingHttpClientProxy httpClientProxy = (NamingHttpClientProxy) httpClientProxyField.get(namingClientProxy);
return httpClientProxy.getBeatReactor();
}
use of com.alibaba.nacos.client.naming.remote.NamingClientProxy in project nacos by alibaba.
the class ServiceInfoUpdateServiceTest method testScheduleUpdateIfAbsent.
@Test
public void testScheduleUpdateIfAbsent() throws InterruptedException, NacosException {
String serviceName = "aa";
String group = "bb";
String clusters = "cc";
ServiceInfo info = new ServiceInfo();
info.setName(serviceName);
info.setGroupName(group);
info.setClusters(clusters);
info.setLastRefTime(System.currentTimeMillis());
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
NamingClientProxy proxy = Mockito.mock(NamingClientProxy.class);
Mockito.when(proxy.queryInstancesOfService(serviceName, group, clusters, 0, false)).thenReturn(info);
InstancesChangeNotifier notifyer = Mockito.mock(InstancesChangeNotifier.class);
Properties prop = new Properties();
final ServiceInfoUpdateService serviceInfoUpdateService = new ServiceInfoUpdateService(prop, holder, proxy, notifyer);
serviceInfoUpdateService.scheduleUpdateIfAbsent("aa", "bb", "cc");
TimeUnit.SECONDS.sleep(2);
Mockito.verify(proxy).queryInstancesOfService(serviceName, group, clusters, 0, false);
}
use of com.alibaba.nacos.client.naming.remote.NamingClientProxy in project nacos by alibaba.
the class ServiceInfoUpdateServiceTest method testStopUpdateIfContain.
@Test
public void testStopUpdateIfContain() throws NacosException {
String serviceName = "aa";
String group = "bb";
String clusters = "cc";
ServiceInfo info = new ServiceInfo();
info.setName(serviceName);
info.setGroupName(group);
info.setClusters(clusters);
info.setLastRefTime(System.currentTimeMillis());
NamingClientProxy proxy = Mockito.mock(NamingClientProxy.class);
Mockito.when(proxy.queryInstancesOfService(serviceName, group, clusters, 0, false)).thenReturn(info);
InstancesChangeNotifier notifyer = Mockito.mock(InstancesChangeNotifier.class);
Properties prop = new Properties();
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
final ServiceInfoUpdateService serviceInfoUpdateService = new ServiceInfoUpdateService(prop, holder, proxy, notifyer);
serviceInfoUpdateService.scheduleUpdateIfAbsent(serviceName, group, clusters);
serviceInfoUpdateService.stopUpdateIfContain(serviceName, group, clusters);
serviceInfoUpdateService.shutdown();
}
Aggregations