Search in sources :

Example 1 with UpgradeJudgement

use of com.alibaba.nacos.naming.core.v2.upgrade.UpgradeJudgement in project nacos by alibaba.

the class HealthCheckTaskInterceptWrapperTest method setUp.

@Before
public void setUp() throws Exception {
    when(applicationContext.getBean(NamingMetadataManager.class)).thenReturn(namingMetadataManager);
    when(applicationContext.getBean(GlobalConfig.class)).thenReturn(globalConfig);
    when(applicationContext.getBean(SwitchDomain.class)).thenReturn(switchDomain);
    when(applicationContext.getBean(DistroMapper.class)).thenReturn(distroMapper);
    when(applicationContext.getBean(UpgradeJudgement.class)).thenReturn(upgradeJudgement);
    ApplicationUtils.injectContext(applicationContext);
    client = new IpPortBasedClient(CLIENT_ID, true);
    when(switchDomain.isHealthCheckEnabled()).thenReturn(true);
    when(distroMapper.responsible(client.getResponsibleId())).thenReturn(true);
    when(upgradeJudgement.isUseGrpcFeatures()).thenReturn(true);
    ClientBeatCheckTaskV2 beatCheckTask = new ClientBeatCheckTaskV2(client);
    taskWrapper = new HealthCheckTaskInterceptWrapper(beatCheckTask);
}
Also used : ClientBeatCheckTaskV2(com.alibaba.nacos.naming.healthcheck.heartbeat.ClientBeatCheckTaskV2) IpPortBasedClient(com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient) Before(org.junit.Before)

Example 2 with UpgradeJudgement

use of com.alibaba.nacos.naming.core.v2.upgrade.UpgradeJudgement in project nacos by alibaba.

the class NamingSubscriberServiceV2ImplTest method setUp.

@Before
public void setUp() throws Exception {
    subscriberService = new NamingSubscriberServiceV2Impl(clientManager, indexesManager, null, null, null, upgradeJudgement, switchDomain);
    ReflectionTestUtils.setField(subscriberService, "delayTaskEngine", delayTaskEngine);
    when(indexesManager.getAllClientsSubscribeService(service)).thenReturn(Collections.singletonList(testClientId));
    when(indexesManager.getAllClientsSubscribeService(service1)).thenReturn(Collections.singletonList(testClientId));
    Collection<Service> services = new LinkedList<>();
    services.add(service);
    services.add(service1);
    when(indexesManager.getSubscribedService()).thenReturn(services);
    when(clientManager.getClient(testClientId)).thenReturn(client);
    when(client.getSubscriber(service)).thenReturn(new Subscriber("1.1.1.1:1111", "Test", "unknown", "1.1.1.1", "N", service.getGroupedServiceName(), 0));
    when(client.getSubscriber(service1)).thenReturn(new Subscriber("1.1.1.1:1111", "Test", "unknown", "1.1.1.1", "N", service1.getGroupedServiceName(), 0));
    when(upgradeJudgement.isUseGrpcFeatures()).thenReturn(true);
}
Also used : Subscriber(com.alibaba.nacos.naming.pojo.Subscriber) Service(com.alibaba.nacos.naming.core.v2.pojo.Service) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 IpPortBasedClient (com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient)1 Service (com.alibaba.nacos.naming.core.v2.pojo.Service)1 ClientBeatCheckTaskV2 (com.alibaba.nacos.naming.healthcheck.heartbeat.ClientBeatCheckTaskV2)1 Subscriber (com.alibaba.nacos.naming.pojo.Subscriber)1 LinkedList (java.util.LinkedList)1