    @Test
    public void removesCallbackWhenAdapterIsCollected() throws Exception {

        BindingCollectionAdapter adapter = mock(BindingCollectionAdapter.class);
        ObservableList items = mock(ObservableList.class);
        ObservableList.OnListChangedCallback callback = mock(ObservableList.OnListChangedCallback.class);
        WeakReference ref = AdapterReferenceCollector.createRef(adapter, items, callback);
        adapter = null;
        System.gc();
        do {
            Thread.sleep(50);
        } while (ref.get() != null);
        verify(items).removeOnListChangedCallback(callback);
    }