public void testRelocate() throws Exception {
DummySimpleClientListener listener =
new DummySimpleClientListener(
new PasswordAuthentication("guest", password));
SimpleClient client = new SimpleClient(listener);
int port = 5383;
int newPort = 5384;
Properties props =
createProperties(
"host", "localhost",
"port", Integer.toString(port),
"connectTimeout", Long.toString(TIMEOUT));
SimpleServer server = new SimpleServer(port);
SimpleServer newServer = new SimpleServer(newPort);
try {
server.start();
newServer.start();
client.login(props);
synchronized (client) {
client.wait(TIMEOUT);
}
assertTrue(listener.loggedIn);
assertFalse(listener.reconnecting);
assertFalse(listener.reconnected);
MessageBuffer msg =
new MessageBuffer(MessageBuffer.getSize("Relocate") + 4);
msg.putString("Relocate").putInt(newPort);
client.send(ByteBuffer.wrap(msg.getBuffer()).asReadOnlyBuffer());
synchronized (client) {
client.wait(TIMEOUT);
}
assertTrue(listener.reconnecting);
assertTrue(listener.reconnected);
} finally {