use of com.alibaba.csp.sentinel.transport.HeartbeatSender in project Sentinel by alibaba.
the class HeartbeatSenderInitFuncTest method testRetrieveInterval.
@Test
public void testRetrieveInterval() {
HeartbeatSender sender = mock(HeartbeatSender.class);
long senderInterval = 5666;
long configInterval = 6777;
when(sender.intervalMs()).thenReturn(senderInterval);
HeartbeatSenderInitFunc func = new HeartbeatSenderInitFunc();
assertEquals(senderInterval, func.retrieveInterval(sender));
// Invalid interval.
SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, "-1");
assertEquals(senderInterval, func.retrieveInterval(sender));
SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, String.valueOf(configInterval));
assertEquals(configInterval, func.retrieveInterval(sender));
}
Aggregations