public Bucket getUpdatedSnapshot() throws InterruptedException {
        updater.gotData.await(10, TimeUnit.SECONDS);
        Bucket s = receiver.getSnapshot();
        long startedWaitingForSnapshot = System.currentTimeMillis();
        // just waiting for the correct snapshot being constructed (yes, this is
        // necessary)
        while (s == null || s.entrySet().size() == 0) {
            if (System.currentTimeMillis() - startedWaitingForSnapshot > (10L * 1000L)) {
                throw new RuntimeException("Test timed out.");
            }
            Thread.sleep(10);
            s = receiver.getSnapshot();
        }
        return s;
    }
Common code for running unit tests of simplemetrics

@author ean
container-core/src/main/java/com/yahoo/metrics/simple/UnitTestSetup.java