add a test

This commit is contained in:
Naoyuki Kanezawa
2014-09-09 03:32:49 +09:00
parent e55caef0b7
commit 92c57e8448
2 changed files with 24 additions and 0 deletions

View File

@@ -336,4 +336,24 @@ public class ServerConnectionTest extends Connection {
assertThat((String)values.take(), is("hi"));
socket.close();
}
@Test(timeout = TIMEOUT)
public void disconnectFromServer() throws URISyntaxException, InterruptedException {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
socket.emit("requestDisconnect");
}
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
values.offer("disconnected");
}
});
socket.connect();
assertThat((String)values.take(), is("disconnected"));
}
}