use of com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand in project x-pipe by ctripcorp.
the class RoleCommandTest method testSlave.
@Test
public void testSlave() throws Exception {
for (MASTER_STATE masterState : MASTER_STATE.values()) {
Server slave = startServer("*5\r\n" + "$5\r\nslave\r\n" + "$9\r\nlocalhost\r\n" + ":6379\r\n" + "$" + masterState.getDesc().length() + "\r\n" + masterState.getDesc() + "\r\n" + ":477\r\n");
RoleCommand roleCommand = new RoleCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(localhostInetAddress(slave.getPort())), 2000, false, scheduled);
SlaveRole role = (SlaveRole) roleCommand.execute().get();
Assert.assertEquals(SERVER_ROLE.SLAVE, role.getServerRole());
Assert.assertEquals("localhost", role.getMasterHost());
Assert.assertEquals(6379, role.getMasterPort());
Assert.assertEquals(masterState, role.getMasterState());
Assert.assertEquals(477, role.getMasterOffset());
}
}
Aggregations