fix disconnection while in opening state

This commit is contained in:
nkzawa
2016-01-31 23:55:53 +09:00
parent f7810c19d3
commit 599eb98c6e
3 changed files with 40 additions and 5 deletions

View File

@@ -591,6 +591,33 @@ public class ConnectionTest extends Connection {
assertThat((Boolean) values.take(), is(true));
}
@Test(timeout = TIMEOUT)
public void connectWhileDisconnectingAnotherSocket() throws URISyntaxException, InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
final Manager manager = new Manager(new URI(uri()));
final Socket socket1 = manager.socket("/foo");
socket1.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
final Socket socket2 = manager.socket("/asd");
socket2.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
values.offer("done");
socket2.disconnect();
}
});
socket2.open();
socket1.disconnect();
}
});
socket1.open();
values.take();
manager.close();
}
@Test(timeout = TIMEOUT)
public void tryToReconnectTwiceAndFailWithIncorrectAddress() throws URISyntaxException, InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();