// this latch limits the calls to the log service
final CountDownLatch latch = new CountDownLatch(3);
// override pause method to allow test synchronization
BundleActivator logClientActivator = new Activator() {
@Override protected void pauseTestThread() {
// report log call
latch.countDown();
// nothing else left to do?
if (latch.getCount() == 0) {
LockSupport.park();
}
}
};
logClientActivator.start(context);
// timeout in case test deadlocks
if (!latch.await(5, TimeUnit.SECONDS)) {
fail("Still expecting" + latch.getCount() + " calls");
}
logClientActivator.stop(context);
// VERIFY - check the behavior matches
// ===================================
verify(context, serviceRef, logService);