public void testClosedCircuitPassesMessages() throws Exception { expectsMessageCount(3, result); sendMessage("direct:start", "message one"); sendMessage("direct:start", "message two"); sendMessage("direct:start", "message three"); assertMockEndpointsSatisfied(); }
public void testHalfOpenCircuitClosesAfterTimeout() throws Exception { expectsMessageCount(2, result); result.whenAnyExchangeReceived( new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.setException(new MyCustomException()); } }); sendMessage("direct:start", "message one"); sendMessage("direct:start", "message two"); sendMessage("direct:start", "message three"); assertMockEndpointsSatisfied(); result.reset(); expectsMessageCount(1, result); Thread.sleep(1000); sendMessage("direct:start", "message four"); assertMockEndpointsSatisfied(); }
public void testFailedMessagesOpenCircuitToPreventMessageThree() throws Exception { expectsMessageCount(2, result); result.whenAnyExchangeReceived( new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.setException(new MyCustomException()); } }); Exchange exchangeOne = sendMessage("direct:start", "message one"); Exchange exchangeTwo = sendMessage("direct:start", "message two"); Exchange exchangeThree = sendMessage("direct:start", "message three"); assertMockEndpointsSatisfied(); assertTrue(exchangeOne.getException() instanceof MyCustomException); assertTrue(exchangeTwo.getException() instanceof MyCustomException); assertTrue(exchangeThree.getException() instanceof RejectedExecutionException); }