@Test
public void testOpensOnFailure() throws Exception {

    long start = System.currentTimeMillis();
    impl.state = CircuitBreaker.BreakerState.OPEN;
    expect(mockCallable.call()).andThrow(new RuntimeException());
    replay(mockCallable);
    try {
        impl.invoke(mockCallable);
        fail("should have thrown an exception");
    } catch (RuntimeException expected) {
    }
    long end = System.currentTimeMillis();
    verify(mockCallable);
    assertEquals(CircuitBreaker.BreakerState.OPEN, impl.state);
    assertTrue(impl.lastFailure.get() >= start);
    assertTrue(impl.lastFailure.get() <= end);
}