DefaultRedisMasterReplication extends AbstractRedisMasterReplication { @Override public void masterConnected(Channel channel) { redisMaster.setMasterState(MASTER_STATE.REDIS_REPL_HANDSHAKE); super.masterConnected(channel); cancelReplConf(); } DefaultRedisMasterReplication(RedisMaster redisMaster, RedisKeeperServer redisKeeperServer,
										 NioEventLoopGroup nioEventLoopGroup, ScheduledExecutorService scheduled,
										 int replTimeoutMilli, KeeperResourceManager resourceManager);  DefaultRedisMasterReplication(RedisMaster redisMaster, RedisKeeperServer redisKeeperServer,
										 NioEventLoopGroup nioEventLoopGroup, ScheduledExecutorService scheduled,
										 KeeperResourceManager resourceManager); @Override void masterConnected(Channel channel); @Override void masterDisconntected(Channel channel); void setMasterConnectRetryDelaySeconds(int masterConnectRetryDelaySeconds); @Override void stopReplication(); @Override PARTIAL_STATE partialState();  }
@Test public void testStopReceivingDataWhenNotStarted() throws Exception { when(redisMaster.masterEndPoint()).thenReturn(new DefaultEndPoint("localhost", randomPort())); defaultRedisMasterReplication.initialize(); try { defaultRedisMasterReplication.handleResponse(mock(Channel.class), Unpooled.wrappedBuffer(randomString().getBytes())); Assert.fail(); }catch (RedisMasterReplicationStateException e){ logger.info("{}", e.getMessage()); } defaultRedisMasterReplication.start(); Channel channel = mock(Channel.class); when(channel.closeFuture()).thenReturn(mock(ChannelFuture.class)); defaultRedisMasterReplication.masterConnected(channel); defaultRedisMasterReplication.handleResponse(channel, Unpooled.wrappedBuffer(randomString().getBytes())); defaultRedisMasterReplication.stop(); try { defaultRedisMasterReplication.handleResponse(mock(Channel.class), Unpooled.wrappedBuffer(randomString().getBytes())); Assert.fail(); }catch (RedisMasterReplicationStateException e){ logger.info("{}", e.getMessage()); } defaultRedisMasterReplication.dispose(); try { defaultRedisMasterReplication.handleResponse(mock(Channel.class), Unpooled.wrappedBuffer(randomString().getBytes())); Assert.fail(); }catch (RedisMasterReplicationStateException e){ logger.info("{}", e.getMessage()); } }