use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class RedisConsumerIntegrationTest method consumerReceivesMessages.
@Test
public void consumerReceivesMessages() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
mock.expectedBodiesReceived("message");
sendHeaders(RedisConstants.COMMAND, "PUBLISH", RedisConstants.CHANNEL, "two", RedisConstants.MESSAGE, "message");
mock.assertIsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SpringAggregatorWithCustomStrategyTest method testSendingMessagesWithCustomAggregator.
public void testSendingMessagesWithCustomAggregator() throws Exception {
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedBodiesReceived("message:1 message:2 message:3");
// lets send a large batch of messages
for (int i = 1; i <= 3; i++) {
String body = "message:" + i;
template.sendBodyAndHeader("direct:start", body, "cheese", 123);
}
resultEndpoint.assertIsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SpringIdempotentConsumerNoSkipDuplicateTest method testDuplicateMessagesAreFilteredOut.
public void testDuplicateMessagesAreFilteredOut() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("one", "two", "one", "two", "one", "three");
mock.message(0).property(Exchange.DUPLICATE_MESSAGE).isNull();
mock.message(1).property(Exchange.DUPLICATE_MESSAGE).isNull();
mock.message(2).property(Exchange.DUPLICATE_MESSAGE).isEqualTo(Boolean.TRUE);
mock.message(3).property(Exchange.DUPLICATE_MESSAGE).isEqualTo(Boolean.TRUE);
mock.message(4).property(Exchange.DUPLICATE_MESSAGE).isEqualTo(Boolean.TRUE);
mock.message(5).property(Exchange.DUPLICATE_MESSAGE).isNull();
sendMessage("1", "one");
sendMessage("2", "two");
sendMessage("1", "one");
sendMessage("2", "two");
sendMessage("1", "one");
sendMessage("3", "three");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class TransactionalClientDataSourceWithOnExceptionTest method testTransactionRollback.
public void testTransactionRollback() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:error");
mock.expectedMessageCount(1);
try {
template.sendBody("direct:fail", "Hello World");
fail("Should have thrown exception");
} catch (RuntimeCamelException e) {
// expected as we fail
assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
assertTrue(e.getCause().getCause() instanceof IllegalArgumentException);
assertEquals("We don't have Donkeys, only Camels", e.getCause().getCause().getMessage());
}
assertMockEndpointsSatisfied();
int count = jdbc.queryForObject("select count(*) from books", Integer.class);
assertEquals("Number of books", 1, count);
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class TransactionalClientWithAnnotatedBeanTest method testTransactionSuccess.
@Override
public void testTransactionSuccess() throws Exception {
MockEndpoint book = getMockEndpoint("mock:book");
book.expectedMessageCount(2);
super.testTransactionSuccess();
assertMockEndpointsSatisfied();
}
Aggregations