use of com.alibaba.nacos.naming.consistency.ConsistencyService in project nacos by alibaba.
the class ServerStatusManagerTest method testUpdaterFromConsistency2.
@Test
public void testUpdaterFromConsistency2() throws NoSuchFieldException, IllegalAccessException {
SwitchDomain switchDomain = mock(SwitchDomain.class);
ServerStatusManager serverStatusManager = new ServerStatusManager(switchDomain);
Field field = ServerStatusManager.class.getDeclaredField("consistencyService");
field.setAccessible(true);
ConsistencyService consistencyService = mock(ConsistencyService.class);
when(consistencyService.isAvailable()).thenReturn(false);
field.set(serverStatusManager, consistencyService);
ServerStatusManager.ServerStatusUpdater updater = serverStatusManager.new ServerStatusUpdater();
// then
updater.run();
// then
Assert.assertEquals(ServerStatus.DOWN, serverStatusManager.getServerStatus());
}
Aggregations