use of com.alibaba.nacos.client.naming.cache.ServiceInfoHolder 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.cache.ServiceInfoHolder 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