use of net.jodah.failsafe.internal.OpenState in project failsafe by jhalterman.
the class OpenStateTest method testAllowsExecution.
public void testAllowsExecution() throws Throwable {
// Given
CircuitBreaker breaker = new CircuitBreaker().withDelay(100, TimeUnit.MILLISECONDS);
breaker.open();
OpenState state = new OpenState(breaker);
assertTrue(breaker.isOpen());
assertFalse(state.allowsExecution(null));
// When
Thread.sleep(110);
// Then
assertTrue(state.allowsExecution(null));
assertEquals(breaker.getState(), State.HALF_OPEN);
}
Aggregations