use of com.ctrip.xpipe.api.command.Command in project x-pipe by ctripcorp.
the class DefaultRedisMasterReplicationTest method testCancelScheduleWhenConnected.
@Test
public void testCancelScheduleWhenConnected() throws IOException {
AtomicInteger replConfCount = new AtomicInteger();
defaultRedisMasterReplication = new DefaultRedisMasterReplication(redisMaster, redisKeeperServer, nioEventLoopGroup, scheduled, replTimeoutMilli) {
@Override
protected Command<Object> createReplConf() {
replConfCount.incrementAndGet();
return super.createReplConf();
}
};
defaultRedisMasterReplication.onContinue(RunidGenerator.DEFAULT.generateRunid(), RunidGenerator.DEFAULT.generateRunid());
Channel channel = mock(Channel.class);
when(channel.closeFuture()).thenReturn(new DefaultChannelPromise(channel));
defaultRedisMasterReplication.masterConnected(channel);
int countBefore = replConfCount.get();
sleep(DefaultRedisMasterReplication.REPLCONF_INTERVAL_MILLI * 2);
int countAfter = replConfCount.get();
Assert.assertEquals(countBefore, countAfter);
}
Aggregations