test: fix BeatReactorTest

This commit is contained in:
chuntaojun 2020-03-27 13:15:31 +08:00
parent 418f88d4c6
commit 36b99c74ac

View File

@ -1,7 +1,10 @@
package com.alibaba.nacos.client;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.common.ResponseCode;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.CommonParams;
import com.alibaba.nacos.api.naming.NamingResponseCode;
import com.alibaba.nacos.client.naming.beat.BeatInfo;
import com.alibaba.nacos.client.naming.beat.BeatReactor;
import com.alibaba.nacos.client.naming.net.NamingProxy;
@ -39,7 +42,11 @@ public class BeatReactorTest {
beatInfo.setScheduled(false);
beatInfo.setPeriod(1000L);
Mockito.doReturn(new JSONObject()).when(namingProxy).sendBeat(beatInfo, true);
JSONObject result = new JSONObject();
result.put(CommonParams.LIGHT_BEAT_ENABLED, true);
result.put(CommonParams.CODE, ResponseCode.OK);
Mockito.doReturn(result).when(namingProxy).sendBeat(beatInfo, true);
beatReactor.addBeatInfo("testService", beatInfo);
Assert.assertEquals(1, getActiveThread(beatReactor));