Search in sources :

Example 6 with ConsistencyService

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());
}
Also used : Field(java.lang.reflect.Field) SwitchDomain(com.alibaba.nacos.naming.misc.SwitchDomain) ConsistencyService(com.alibaba.nacos.naming.consistency.ConsistencyService) Test(org.junit.Test)

Aggregations

ConsistencyService (com.alibaba.nacos.naming.consistency.ConsistencyService)6 Test (org.junit.Test)4 SwitchDomain (com.alibaba.nacos.naming.misc.SwitchDomain)3 Field (java.lang.reflect.Field)3 ServiceManager (com.alibaba.nacos.naming.core.ServiceManager)2 ServiceChangeV2Task (com.alibaba.nacos.naming.core.v2.upgrade.doublewrite.delay.ServiceChangeV2Task)2 BaseTest (com.alibaba.nacos.naming.BaseTest)1 Instances (com.alibaba.nacos.naming.core.Instances)1 Set (java.util.Set)1