@@ -0,0 +1,3239 @@
+/*%0A * Copyright 1999-2018 Alibaba Group Holding Ltd.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.alibaba.nacos.client.naming.backups;%0A%0Aimport com.alibaba.nacos.api.exception.NacosException;%0Aimport com.alibaba.nacos.api.naming.pojo.ServiceInfo;%0Aimport com.alibaba.nacos.client.naming.cache.ServiceInfoHolder;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0Aimport org.mockito.Mockito;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.util.Date;%0Aimport java.util.HashMap;%0Aimport java.util.concurrent.ScheduledExecutorService;%0A%0Apublic class FailoverReactorTest %7B%0A    %0A    @Test%0A    public void testInit() throws NacosException, NoSuchFieldException, IllegalAccessException %7B%0A        ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);%0A        Mockito.when(holder.getServiceInfoMap()).thenReturn(new HashMap%3C%3E());%0A        FailoverReactor failoverReactor = new FailoverReactor(holder, %22/tmp%22);%0A        Field executorService = FailoverReactor.class.getDeclaredField(%22executorService%22);%0A        executorService.setAccessible(true);%0A        ScheduledExecutorService o = (ScheduledExecutorService) executorService.get(failoverReactor);%0A        Assert.assertFalse(o.isShutdown());%0A        failoverReactor.shutdown();%0A        Assert.assertTrue(o.isShutdown());%0A    %7D%0A    %0A    @Test%0A    public void testAddDay() throws NacosException %7B%0A        ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);%0A        Mockito.when(holder.getServiceInfoMap()).thenReturn(new HashMap%3C%3E());%0A        FailoverReactor failoverReactor = new FailoverReactor(holder, %22/tmp%22);%0A        Date date = new Date();%0A        Date actual = failoverReactor.addDay(date, 1);%0A        Assert.assertEquals(date.getTime() + 24 * 60 * 60 * 1000, actual.getTime());%0A        failoverReactor.shutdown();%0A    %7D%0A    %0A    @Test%0A    public void testIsFailoverSwitch() throws NacosException %7B%0A        ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);%0A        Mockito.when(holder.getServiceInfoMap()).thenReturn(new HashMap%3C%3E());%0A        FailoverReactor failoverReactor = new FailoverReactor(holder, %22/tmp%22);%0A        Assert.assertFalse(failoverReactor.isFailoverSwitch());%0A        failoverReactor.shutdown();%0A        %0A    %7D%0A    %0A    @Test%0A    public void testGetService() throws NacosException %7B%0A        ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);%0A        Mockito.when(holder.getServiceInfoMap()).thenReturn(new HashMap%3C%3E());%0A        FailoverReactor failoverReactor = new FailoverReactor(holder, %22/tmp%22);%0A        ServiceInfo info = failoverReactor.getService(%22aa@@bb%22);%0A        Assert.assertEquals(new ServiceInfo(%22aa@@bb%22).toString(), info.toString());%0A        failoverReactor.shutdown();%0A        %0A    %7D%0A%7D

add ut for package c.a.nacos.client.naming.backups (#5157)