Skip to content

Commit

Permalink
CAMEL-8584 Update half-open test to assert circuit stays open during
Browse files Browse the repository at this point in the history
halfOpenAfter period
  • Loading branch information
jpgamesys authored and davsclaus committed Apr 2, 2015
1 parent d85f2f0 commit 323ab6b
Showing 1 changed file with 10 additions and 8 deletions.
Expand Up @@ -102,17 +102,17 @@ public void process(Exchange exchange) throws Exception {
assertTrue(exchangeThree.getException() instanceof RejectedExecutionException); assertTrue(exchangeThree.getException() instanceof RejectedExecutionException);
} }


public void testHalfOpenAfterMessageThreeSync() throws Exception { public void testHalfOpenAfterTimeoutSync() throws Exception {
String endpoint = "direct:start"; String endpoint = "direct:start";
halfOpenAfterMessageThree(endpoint); halfOpenAfterTimeout(endpoint);
} }


public void testHalfOpenAfterMessageThreeAsync() throws Exception { public void testHalfOpenAfterTimeoutAsync() throws Exception {
String endpoint = "direct:start-async"; String endpoint = "direct:start-async";
halfOpenAfterMessageThree(endpoint); halfOpenAfterTimeout(endpoint);
} }


private void halfOpenAfterMessageThree(String endpoint) throws InterruptedException, Exception { private void halfOpenAfterTimeout(String endpoint) throws InterruptedException, Exception {
expectsMessageCount(2, result); expectsMessageCount(2, result);


result.whenAnyExchangeReceived(new Processor() { result.whenAnyExchangeReceived(new Processor() {
Expand All @@ -125,6 +125,7 @@ public void process(Exchange exchange) throws Exception {
Exchange exchangeOne = sendMessage(endpoint, "message one"); Exchange exchangeOne = sendMessage(endpoint, "message one");
Exchange exchangeTwo = sendMessage(endpoint, "message two"); Exchange exchangeTwo = sendMessage(endpoint, "message two");
Exchange exchangeThree = sendMessage(endpoint, "message three"); Exchange exchangeThree = sendMessage(endpoint, "message three");
Exchange exchangeFour = sendMessage(endpoint, "message four");
assertMockEndpointsSatisfied(); assertMockEndpointsSatisfied();
Thread.sleep(1000); Thread.sleep(1000);
result.reset(); result.reset();
Expand All @@ -135,15 +136,16 @@ public void process(Exchange exchange) throws Exception {
} }
}); });
expectsMessageCount(1, result); expectsMessageCount(1, result);
Exchange exchangeFour = sendMessage(endpoint, "message four");
Exchange exchangeFive = sendMessage(endpoint, "message five"); Exchange exchangeFive = sendMessage(endpoint, "message five");
Exchange exchangeSix = sendMessage(endpoint, "message six");
assertMockEndpointsSatisfied(); assertMockEndpointsSatisfied();


assertTrue(exchangeOne.getException() instanceof MyCustomException); assertTrue(exchangeOne.getException() instanceof MyCustomException);
assertTrue(exchangeTwo.getException() instanceof MyCustomException); assertTrue(exchangeTwo.getException() instanceof MyCustomException);
assertTrue(exchangeThree.getException() instanceof RejectedExecutionException); assertTrue(exchangeThree.getException() instanceof RejectedExecutionException);
assertTrue(exchangeFour.getException() instanceof MyCustomException); assertTrue(exchangeFour.getException() instanceof RejectedExecutionException);
assertTrue(exchangeFive.getException() instanceof RejectedExecutionException); assertTrue(exchangeFive.getException() instanceof MyCustomException);
assertTrue(exchangeSix.getException() instanceof RejectedExecutionException);
} }


public void testHalfOpenToCloseTransitionSync() throws Exception { public void testHalfOpenToCloseTransitionSync() throws Exception {
Expand Down

0 comments on commit 323ab6b

Please sign in to comment.