12 |
import dk.thoerup.curcuitbreaker.CircuitBreaker; |
import dk.thoerup.curcuitbreaker.CircuitBreaker; |
13 |
import dk.thoerup.curcuitbreaker.CircuitBreakerException; |
import dk.thoerup.curcuitbreaker.CircuitBreakerException; |
14 |
import dk.thoerup.curcuitbreaker.CircuitInvocation; |
import dk.thoerup.curcuitbreaker.CircuitInvocation; |
15 |
import dk.thoerup.curcuitbreaker.notification.SystemOutNotifier; |
|
16 |
|
|
17 |
|
|
18 |
public class TestCircuitBreaker { |
public class TestCircuitBreaker { |
36 |
|
|
37 |
@Before public void setup() { |
@Before public void setup() { |
38 |
cb = new CircuitBreaker("test", THRESHOLD, DELAY); |
cb = new CircuitBreaker("test", THRESHOLD, DELAY); |
|
cb.setNotifier( new SystemOutNotifier() ); |
|
39 |
} |
} |
40 |
|
|
41 |
@Test public void defaultState() { |
@Test public void defaultState() { |
85 |
assertTrue( cb.isOpen() ); |
assertTrue( cb.isOpen() ); |
86 |
} |
} |
87 |
|
|
88 |
|
@Test public void forcedTrip() { |
89 |
|
assertTrue( cb.isClosed() ); |
90 |
|
cb.tripBreaker(); |
91 |
|
assertTrue( cb.isOpen() ); |
92 |
|
} |
93 |
|
|
94 |
@Test public void forcedResetTest() throws Exception { |
@Test public void forcedResetTest() throws Exception { |
95 |
try{ |
try{ |
96 |
cb.invoke( new FailingInvocation() ); |
cb.invoke( new FailingInvocation() ); |