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

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

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

revision 445 by torben, Mon Oct 19 13:01:46 2009 UTC revision 449 by torben, Mon Oct 19 20:10:09 2009 UTC
# Line 36  public class TestCircuitBreaker { Line 36  public class TestCircuitBreaker {
36                  cb.invoke( new FailingInvocation() );                  cb.invoke( new FailingInvocation() );
37          }          }
38                    
39          @Test public void failingTest() throws Throwable {          @Test public void failingTest() {
40                  try {                  try {
41                          cb.invoke( new FailingInvocation() );                          cb.invoke( new FailingInvocation() );
42                  }catch (Throwable t) {}                  }catch (Throwable t) {}
43                  assertTrue(cb.getFailureCount() == 1);                  assertTrue(cb.getFailureCount() == 1);
44          }          }
45                    
46            @Test public void failAndResetTest() throws Throwable {
47                    try {
48                            cb.invoke( new FailingInvocation() );
49                    }catch (Throwable t) {}
50                    
51                    cb.invoke(new SucceedingInvocation() ); //after one good it should reset back to closed
52                    
53                    assertTrue(cb.isClosed());
54                    assertTrue(cb.getFailureCount() == 0);          
55            }
56            
57          @Test public void normalOpenTest() throws Throwable {          @Test public void normalOpenTest() throws Throwable {
58                  try{                  try{
59                          cb.invoke( new FailingInvocation() );                          cb.invoke( new FailingInvocation() );
# Line 52  public class TestCircuitBreaker { Line 63  public class TestCircuitBreaker {
63                          cb.invoke( new FailingInvocation() );                          cb.invoke( new FailingInvocation() );
64                  } catch (IOException e) {}                  } catch (IOException e) {}
65    
66                  assertTrue( cb.getStateName().equalsIgnoreCase("open") );                                assertTrue( cb.isOpen() );              
67            }
68            
69            @Test public void forcedResetTest() throws Throwable {
70                    try{
71                            cb.invoke( new FailingInvocation() );
72                    } catch (IOException e) {}
73                    
74                    try{
75                            cb.invoke( new FailingInvocation() );
76                    } catch (IOException e) {}
77                    
78                    cb.reset();
79    
80                    assertTrue( cb.isClosed() );            
81          }          }
82    
83  }  }

Legend:
Removed from v.445  
changed lines
  Added in v.449

  ViewVC Help
Powered by ViewVC 1.1.20