@Test
public void testCircuitBreakerAcrossMultipleCommandsButSameCircuitBreaker() throws InterruptedException {

    HystrixCommandKey key = HystrixCommandKey.Factory.asKey("SharedCircuitBreaker");
    TestCircuitBreaker circuitBreaker = new TestCircuitBreaker(key);
    /* fail 3 times and then it should trip the circuit and stop executing */
    // failure 1
    TestHystrixCommand<Integer> attempt1 = getSharedCircuitBreakerCommand(key, ExecutionIsolationStrategy.THREAD, AbstractTestHystrixCommand.FallbackResult.SUCCESS, circuitBreaker);
    System.out.println("COMMAND KEY (from cmd): " + attempt1.commandKey.name());
    attempt1.execute();
    Thread.sleep(100);
    assertTrue(attempt1.isResponseFromFallback());
    assertFalse(attempt1.isCircuitBreakerOpen());
    assertFalse(attempt1.isResponseShortCircuited());
    // failure 2 with a different command, same circuit breaker
    TestHystrixCommand<Integer> attempt2 = getSharedCircuitBreakerCommand(key, ExecutionIsolationStrategy.THREAD, AbstractTestHystrixCommand.FallbackResult.SUCCESS, circuitBreaker);
    attempt2.execute();
    Thread.sleep(100);
    assertTrue(attempt2.isFailedExecution());
    assertTrue(attempt2.isResponseFromFallback());
    assertFalse(attempt2.isCircuitBreakerOpen());
    assertFalse(attempt2.isResponseShortCircuited());
    // failure 3 of the Hystrix, 2nd for this particular HystrixCommand
    TestHystrixCommand<Integer> attempt3 = getSharedCircuitBreakerCommand(key, ExecutionIsolationStrategy.THREAD, AbstractTestHystrixCommand.FallbackResult.SUCCESS, circuitBreaker);
    attempt3.execute();
    Thread.sleep(100);
    assertTrue(attempt3.isFailedExecution());
    assertTrue(attempt3.isResponseFromFallback());
    assertFalse(attempt3.isResponseShortCircuited());
    // it should now be 'open' and prevent further executions
    // after having 3 failures on the Hystrix that these 2 different HystrixCommand objects are for
    assertTrue(attempt3.isCircuitBreakerOpen());
    // attempt 4
    TestHystrixCommand<Integer> attempt4 = getSharedCircuitBreakerCommand(key, ExecutionIsolationStrategy.THREAD, AbstractTestHystrixCommand.FallbackResult.SUCCESS, circuitBreaker);
    attempt4.execute();
    Thread.sleep(100);
    assertTrue(attempt4.isResponseFromFallback());
    // this should now be true as the response will be short-circuited
    assertTrue(attempt4.isResponseShortCircuited());
    // this should remain open
    assertTrue(attempt4.isCircuitBreakerOpen());
    assertSaneHystrixRequestLog(4);
    assertCommandExecutionEvents(attempt1, HystrixEventType.FAILURE, HystrixEventType.FALLBACK_SUCCESS);
    assertCommandExecutionEvents(attempt2, HystrixEventType.FAILURE, HystrixEventType.FALLBACK_SUCCESS);
    assertCommandExecutionEvents(attempt3, HystrixEventType.FAILURE, HystrixEventType.FALLBACK_SUCCESS);
    assertCommandExecutionEvents(attempt4, HystrixEventType.SHORT_CIRCUITED, HystrixEventType.FALLBACK_SUCCESS);
}