org.eclipse.microprofile.fault.tolerance.tck

## Class CircuitBreakerTest

- java.lang.Object
- - org.jboss.arquillian.testng.Arquillian
  - - org.eclipse.microprofile.fault.tolerance.tck.CircuitBreakerTest

All Implemented Interfaces:
  org.testng.IHookable, org.testng.ITestNGListener

    public class CircuitBreakerTest
    extends org.jboss.arquillian.testng.Arquillian

Test CircuitBreaker Thresholds and delays.

Author:
  Neil Young

### Nested Class Summary

### Nested classes/interfaces inherited from class org.jboss.arquillian.testng.Arquillian

`org.jboss.arquillian.testng.Arquillian.UpdateResultListener`

### Field Summary

### Fields inherited from class org.jboss.arquillian.testng.Arquillian

`ARQUILLIAN_DATA_PROVIDER`

### Constructor Summary

Constructors
Constructor and Description
`CircuitBreakerTest()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static org.jboss.shrinkwrap.api.spec.WebArchive` `deploy()`

`void`

`testCircuitClosedThenOpen()`
A test to exercise Circuit Breaker thresholds, with a default SuccessThreshold With requestVolumeThreshold = 4, failureRatio=0.75, successThreshold = 2, delay = 50000 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException 5 CircuitBreakerOpenException 6 CircuitBreakerOpenException 7 CircuitBreakerOpenException

`void`

`testCircuitDefaultSuccessThreshold()`
A test to exercise Circuit Breaker thresholds, with a default SuccessThreshold With requestVolumeThreshold = 4, failureRatio=0.75 and successThreshold = 1 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException 5 CircuitBreakerOpenException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 6 SUCCEED (CircuitBreaker will be re-closed as successThreshold is 1.

`void`

`testCircuitHighSuccessThreshold()`
A test to exercise Circuit Breaker thresholds, with a default SuccessThreshold With requestVolumeThreshold = 4, failureRatio=0.75 and successThreshold = 3 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException 5 CircuitBreakerOpenException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 6 SUCCEED 7 SUCCEED 8 RunTimeException (CircuitBreaker will be re-opened) 9 CircuitBreakerOpenException

`void`

`testCircuitReClose()`
A test to exercise Circuit Breaker thresholds, with a SuccessThreshold of 2 With requestVolumeThreshold = 4, failureRatio=0.75 and successThreshold = 2 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 5 SUCCEED 6 SUCCEED (CircuitBreaker will be re-closed as successThreshold is 2) 7 SUCCEED

`void` `testClassLevelCircuitBase()` Analogous to testCircuitClosedThenOpen but using a Class level rather than method level annotation.
`void` `testClassLevelCircuitOverride()` Analogous to testCircuitClosedThenOpen but with a Class level annotation specified that is overridden by a Method level annotation on serviceC.
`void` `testClassLevelCircuitOverrideNoDelay()` Analogous to testCircuitReClose but with a Class level annotation specified that is overridden by a Method level annotation on serviceD.
`void` `testRollingWindowCircuitOpen()` A test to exercise Circuit Breaker rolling window With requestVolumeThreshold = 4, failureRatio=0.5, expected behaviour is, Execution Behaviour ========= ========= 1 Success 2 RunTimeException 3 RunTimeException 4 Success 5 CircuitBreakerOpenException
`void` `testRollingWindowCircuitOpen2()` A test to exercise Circuit Breaker rolling window With requestVolumeThreshold = 4, failureRatio=0.5, expected behaviour is, Execution Behaviour ========= ========= 1 Success 2 RunTimeException 3 Success 4 Success 5 RuntimeException 6 CircuitBreakerOpenException

### Methods inherited from class org.jboss.arquillian.testng.Arquillian

`arquillianAfterClass, arquillianAfterSuite, arquillianAfterTest, arquillianArgumentProvider, arquillianBeforeClass, arquillianBeforeSuite, arquillianBeforeTest, run`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CircuitBreakerTest

    public CircuitBreakerTest()

### Method Detail

#### deploy

    @Deployment
    public static org.jboss.shrinkwrap.api.spec.WebArchive deploy()

#### testCircuitClosedThenOpen

    public void testCircuitClosedThenOpen()

A test to exercise Circuit Breaker thresholds, with a default SuccessThreshold With requestVolumeThreshold = 4, failureRatio=0.75, successThreshold = 2, delay = 50000 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException 5 CircuitBreakerOpenException 6 CircuitBreakerOpenException 7 CircuitBreakerOpenException

#### testCircuitReClose

    public void testCircuitReClose()

A test to exercise Circuit Breaker thresholds, with a SuccessThreshold of 2 With requestVolumeThreshold = 4, failureRatio=0.75 and successThreshold = 2 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 5 SUCCEED 6 SUCCEED (CircuitBreaker will be re-closed as successThreshold is 2) 7 SUCCEED

#### testCircuitDefaultSuccessThreshold

    public void testCircuitDefaultSuccessThreshold()

A test to exercise Circuit Breaker thresholds, with a default SuccessThreshold With requestVolumeThreshold = 4, failureRatio=0.75 and successThreshold = 1 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException 5 CircuitBreakerOpenException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 6 SUCCEED (CircuitBreaker will be re-closed as successThreshold is 1. The impact of the success of the service and the closure of the Circuit is to reset the rolling failure window to an empty state. Therefore another 4 requests need to be made - of which at least 3 need to fail - for the Circuit to open again) 7 RunTimeException 8 RunTimeException 9 RunTimeException 10 RuntimeException 11 CircuitBreakerOpenException

#### testCircuitHighSuccessThreshold

    public void testCircuitHighSuccessThreshold()

A test to exercise Circuit Breaker thresholds, with a default SuccessThreshold With requestVolumeThreshold = 4, failureRatio=0.75 and successThreshold = 3 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException 5 CircuitBreakerOpenException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 6 SUCCEED 7 SUCCEED 8 RunTimeException (CircuitBreaker will be re-opened) 9 CircuitBreakerOpenException

#### testClassLevelCircuitBase

    public void testClassLevelCircuitBase()

Analogous to testCircuitClosedThenOpen but using a Class level rather than method level annotation. With requestVolumeThreshold = 4, failureRatio=0.75, successThreshold = 2 , delay = 50000 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException 5 CircuitBreakerOpenException 6 CircuitBreakerOpenException 7 CircuitBreakerOpenException

#### testClassLevelCircuitOverride

    public void testClassLevelCircuitOverride()

Analogous to testCircuitClosedThenOpen but with a Class level annotation specified that is overridden by a Method level annotation on serviceC. With successThreshold = 2, requestVolumeThreshold = 2, failureRatio=1, delay = 50000 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 CircuitBreakerOpenException 4 CircuitBreakerOpenException 5 CircuitBreakerOpenException 6 CircuitBreakerOpenException 7 CircuitBreakerOpenException

#### testClassLevelCircuitOverrideNoDelay

    public void testClassLevelCircuitOverrideNoDelay()

Analogous to testCircuitReClose but with a Class level annotation specified that is overridden by a Method level annotation on serviceD. With successThreshold = 2, requestVolumeThreshold = 4, failureRatio=0.75, delay = 1 the expected behaviour is, Execution Behaviour ========= ========= 1 RunTimeException 2 RunTimeException 3 RunTimeException 4 RunTimeException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 5 SUCCEED 6 SUCCEED (CircuitBreaker will be re-closed as successThreshold is 2) 7 SUCCEED

#### testRollingWindowCircuitOpen

    public void testRollingWindowCircuitOpen()

A test to exercise Circuit Breaker rolling window With requestVolumeThreshold = 4, failureRatio=0.5, expected behaviour is, Execution Behaviour ========= ========= 1 Success 2 RunTimeException 3 RunTimeException 4 Success 5 CircuitBreakerOpenException

#### testRollingWindowCircuitOpen2

    public void testRollingWindowCircuitOpen2()

A test to exercise Circuit Breaker rolling window With requestVolumeThreshold = 4, failureRatio=0.5, expected behaviour is, Execution Behaviour ========= ========= 1 Success 2 RunTimeException 3 Success 4 Success 5 RuntimeException 6 CircuitBreakerOpenException