/[projects]/CircuitBreaker/test/dk/thoerup/circuitbreaker/TestCircuitBreaker.java
ViewVC logotype

Diff of /CircuitBreaker/test/dk/thoerup/circuitbreaker/TestCircuitBreaker.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 452 by torben, Tue Oct 20 10:47:36 2009 UTC revision 456 by torben, Tue Oct 20 20:42:36 2009 UTC
# Line 12  import org.junit.Test; Line 12  import org.junit.Test;
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 {
# Line 36  public class TestCircuitBreaker { Line 36  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() {
# Line 86  public class TestCircuitBreaker { Line 85  public class TestCircuitBreaker {
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() );
# Line 95  public class TestCircuitBreaker { Line 100  public class TestCircuitBreaker {
100                          cb.invoke( new FailingInvocation() );                          cb.invoke( new FailingInvocation() );
101                  } catch (IOException e) {}                  } catch (IOException e) {}
102                                    
103                  cb.reset();                  cb.reset();
104                    
105                  assertTrue( cb.isClosed() );                  assertTrue( cb.isClosed() );
106                  assertTrue( cb.getFailureCount() == 0 ); //currently an externally triggered reset doesn't reset failure count - should a forced reset be possible at all ?                  assertTrue( cb.getFailureCount() == 0 );
107          }          }
108    
109    

Legend:
Removed from v.452  
changed lines
  Added in v.456

  ViewVC Help
Powered by ViewVC 1.1.20