@Test
public void testRequestCacheWithCommandTimeout() {

    ConcurrentLinkedQueue<HystrixCommand<List<String>>> commands = new ConcurrentLinkedQueue<HystrixCommand<List<String>>>();
    final TestCollapserTimer timer = new TestCollapserTimer();
    SuccessfulCacheableCollapsedCommand command1 = new SuccessfulCacheableCollapsedCommand(timer, "TIMEOUT", true, commands);
    SuccessfulCacheableCollapsedCommand command2 = new SuccessfulCacheableCollapsedCommand(timer, "TIMEOUT", true, commands);
    Future<String> f1 = command1.queue();
    Future<String> f2 = command2.queue();
    // increment past batch time so it executes
    timer.incrementTime(15);
    try {
        assertEquals("A", f1.get(1000, TimeUnit.MILLISECONDS));
        assertEquals("A", f2.get(1000, TimeUnit.MILLISECONDS));
        fail("exception should have been thrown");
    } catch (Exception e) {
        // expected
    }
    // it should have executed 1 command
    assertEquals(1, commands.size());
    assertTrue(commands.peek().getExecutionEvents().contains(HystrixEventType.TIMEOUT));
    assertTrue(commands.peek().getExecutionEvents().contains(HystrixEventType.COLLAPSED));
    Future<String> f3 = command1.queue();
    // increment past batch time so it executes
    timer.incrementTime(15);
    try {
        assertEquals("A", f3.get(1000, TimeUnit.MILLISECONDS));
        fail("exception should have been thrown");
    } catch (Exception e) {
        // expected
    }
    // it should still be 1 ... no new executions
    assertEquals(1, commands.size());
    assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
    Iterator<HystrixInvokableInfo<?>> cmdIterator = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().iterator();
    assertEquals(1, cmdIterator.next().getNumberCollapsed());
}