private void checkDisconnect(Application application, Stream stream) throws Exception { final Object lock = new Object(); final boolean[] result = new boolean[1]; application.addApplicationListener( new ApplicationAdapter() { @Override public void disconnected(Stream stream) throws SkypeException { result[0] = true; synchronized (lock) { lock.notify(); } } }); synchronized (lock) { stream.write("disconnect"); try { lock.wait(10000); } catch (InterruptedException e) { fail(); } } assertTrue(result[0]); }