@Test
public void testRequestCacheWithSlowExecution() throws Exception {

    TestCircuitBreaker circuitBreaker = new TestCircuitBreaker();
    SlowCacheableCommand command1 = new SlowCacheableCommand(circuitBreaker, "A", 200);
    SlowCacheableCommand command2 = new SlowCacheableCommand(circuitBreaker, "A", 100);
    SlowCacheableCommand command3 = new SlowCacheableCommand(circuitBreaker, "A", 100);
    SlowCacheableCommand command4 = new SlowCacheableCommand(circuitBreaker, "A", 100);
    Future<String> f1 = command1.queue();
    Future<String> f2 = command2.queue();
    Future<String> f3 = command3.queue();
    Future<String> f4 = command4.queue();
    assertEquals("A", f2.get());
    assertEquals("A", f3.get());
    assertEquals("A", f4.get());
    assertEquals("A", f1.get());
    assertTrue(command1.executed);
    // the second one should not have executed as it should have received the cached value instead
    assertFalse(command2.executed);
    assertFalse(command3.executed);
    assertFalse(command4.executed);
    assertTrue(command1.getExecutionTimeInMilliseconds() > -1);
    assertFalse(command1.isResponseFromCache());
    assertTrue(command2.getExecutionTimeInMilliseconds() == -1);
    assertTrue(command2.isResponseFromCache());
    assertTrue(command3.isResponseFromCache());
    assertTrue(command3.getExecutionTimeInMilliseconds() == -1);
    assertTrue(command4.isResponseFromCache());
    assertTrue(command4.getExecutionTimeInMilliseconds() == -1);
    assertCommandExecutionEvents(command1, HystrixEventType.SUCCESS);
    assertCommandExecutionEvents(command2, HystrixEventType.SUCCESS, HystrixEventType.RESPONSE_FROM_CACHE);
    assertCommandExecutionEvents(command3, HystrixEventType.SUCCESS, HystrixEventType.RESPONSE_FROM_CACHE);
    assertCommandExecutionEvents(command4, HystrixEventType.SUCCESS, HystrixEventType.RESPONSE_FROM_CACHE);
    assertEquals(0, circuitBreaker.metrics.getCurrentConcurrentExecutionCount());
    assertSaneHystrixRequestLog(4);
    System.out.println("HystrixRequestLog: " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString());
}