Search in sources :

Example 6 with HeartbeatSender

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));
}
Also used : HeartbeatSender(com.alibaba.csp.sentinel.transport.HeartbeatSender) Test(org.junit.Test)

Aggregations

HeartbeatSender (com.alibaba.csp.sentinel.transport.HeartbeatSender)6 AbstractDataSource (com.alibaba.csp.sentinel.datasource.AbstractDataSource)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Status (org.springframework.boot.actuate.health.Status)2 SentinelProperties (com.alibaba.cloud.sentinel.SentinelProperties)1 Endpoint (com.alibaba.csp.sentinel.transport.endpoint.Endpoint)1 Tuple2 (com.alibaba.csp.sentinel.util.function.Tuple2)1 Field (java.lang.reflect.Field)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)1