@Test
public void testSemaphoreIsolatedResponseFromCache() throws Exception {

    CountDownLatch commandLatch = new CountDownLatch(1);
    CountDownLatch threadPoolLatch = new CountDownLatch(1);
    Subscriber<List<HystrixCommandCompletion>> commandListSubscriber = getLatchedSubscriber(commandLatch);
    readCommandStream.observe().buffer(500, TimeUnit.MILLISECONDS).take(1)
            .doOnNext(new Action1<List<HystrixCommandCompletion>>() {
                @Override
                public void call(List<HystrixCommandCompletion> hystrixCommandCompletions) {
                    System.out.println("LIST : " + hystrixCommandCompletions);
                    assertEquals(3, hystrixCommandCompletions.size());
                }
            })
            .subscribe(commandListSubscriber);
    Subscriber<HystrixCommandCompletion> threadPoolSubscriber = getLatchedSubscriber(threadPoolLatch);
    readThreadPoolStream.observe().take(1).subscribe(threadPoolSubscriber);
    ExecutionResult result = ExecutionResult.from(HystrixEventType.SUCCESS);
    ExecutionResult cache1 = ExecutionResult.from(HystrixEventType.RESPONSE_FROM_CACHE);
    ExecutionResult cache2 = ExecutionResult.from(HystrixEventType.RESPONSE_FROM_CACHE);
    writeToStream.executionDone(result, commandKey, threadPoolKey);
    writeToStream.executionDone(cache1, commandKey, threadPoolKey);
    writeToStream.executionDone(cache2, commandKey, threadPoolKey);
    assertTrue(commandLatch.await(1000, TimeUnit.MILLISECONDS));
    assertFalse(threadPoolLatch.await(1000, TimeUnit.MILLISECONDS));
}