@Test
    @Configuration("{" + 
            "    \"errorCodes\" : [ \"5**\", \"4**\" ]," + 
            "    \"window\" : 1," + 
            "    \"limit\" : 5," + 
            "    \"reset\" : 2," + 
            "    \"failureCode\" : 503" + 
            "}")
    public void testTripAndReset() throws PolicyFailureError, Throwable {
        for (int iterations = 0; iterations < 2; iterations++) {
            PolicyTestRequest okRequest = PolicyTestRequest.build(PolicyTestRequestType.GET, "/path/to/resource");
            okRequest.header("Accept", "application/json");
            PolicyTestRequest errorRequest = PolicyTestRequest.build(PolicyTestRequestType.GET, "/path/to/resource");
            errorRequest.header("Accept", "application/json");
            errorRequest.header("X-Echo-ErrorCode", "500");
            
            PolicyTestResponse response;
            
            int numOK, numError;
            
            // Send a bunch of requests that return 200.  Everything should work fine.
            for (numOK = 0; numOK < 10; numOK++) {
                System.out.println(getClass().getName() + "::testTripAndReset:: OK request #" + (numOK+1));
                response = send(okRequest);
                Assert.assertEquals(200, response.code());
            }
    
            // Now send three that will respond with errors.
            for (numError = 0; numError < 3; numError++) {
                System.out.println(getClass().getName() + "::testTripAndReset:: ERROR request #" + (numError+1));
                response = send(errorRequest);
                Assert.assertEquals(500, response.code());
            }
            
            // The circuit was not yet tripped.  Try a couple of OK requests again.  Should work.
            for (; numOK < 12; numOK++) {
                System.out.println(getClass().getName() + "::testTripAndReset:: OK redux request #" + (numOK+1));
                response = send(okRequest);
                Assert.assertEquals(200, response.code());
            }
            
            // Now send two more failures.  The second one (making 5 within the time window) should trip the circuit.
            for (; numError < 5; numError++) {
                System.out.println(getClass().getName() + "::testTripAndReset:: ERROR request #" + (numError+1));
                response = send(errorRequest);
                Assert.assertEquals(500, response.code());
            }
    
            // Now that the circuit is tripped, the policy should fail with a 503
            try {
                response = send(okRequest);
            } catch (PolicyFailureError pf) {
                Assert.assertEquals(503, pf.getFailure().getResponseCode());
                Assert.assertEquals(20001, pf.getFailure().getFailureCode());
            }
            
            // Wait for the circuit reset time to elapse.
            Thread.sleep(2001);
    
            // Send a bunch more OK requests!  The circuit should now be reset.
            for (; numOK < 15; numOK++) {
                System.out.println(getClass().getName() + "::testTripAndReset:: OK request #" + (numOK+1));
                response = send(okRequest);
                Assert.assertEquals(200, response.code());
            }
        }
    }
Test method for {@link io.apiman.plugins.circuit_breaker.CircuitBreakerPolicy#isMatch(int, java.lang.String)}.
plugins/circuit-breaker-policy/src/test/java/io/apiman/plugins/circuit_breaker/CircuitBreakerPolicyTest.java