Search in sources :

Example 1 with OpenState

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);
}
Also used : CircuitBreaker(net.jodah.failsafe.CircuitBreaker) OpenState(net.jodah.failsafe.internal.OpenState)

Aggregations

CircuitBreaker (net.jodah.failsafe.CircuitBreaker)1 OpenState (net.jodah.failsafe.internal.OpenState)1