use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SearchByExchangeDirectTest method testSearchTimelineWithStaticQuery.
@Test
public void testSearchTimelineWithStaticQuery() throws Exception {
template.sendBody(null);
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
mock.assertIsSatisfied();
List<Exchange> tweets = mock.getExchanges();
for (Exchange e : tweets) {
log.info("Tweet: " + e.getIn().getBody(String.class));
}
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SearchByExchangeDirectTest method testDoubleSearchKeepingOld.
@Test
public void testDoubleSearchKeepingOld() throws Exception {
templateDouble.sendBodyAndHeader(null, TwitterConstants.TWITTER_KEYWORDS, "java");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
mock.assertIsSatisfied();
List<Exchange> tweets = mock.getExchanges();
for (Exchange e : tweets) {
log.info("Tweet: " + e.getIn().getBody(String.class));
}
// calls the same query again, expecting to receive the same amount of
// tweets, because we told this route to not filter old(consumed) tweets
int total = mock.getReceivedCounter();
templateDouble.sendBodyAndHeader(null, TwitterConstants.TWITTER_KEYWORDS, "java");
// due race condition
assertTrue(mock.getReceivedCounter() >= total);
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ECDSASignatureTest method setupMock.
private MockEndpoint setupMock(String payload) {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived(payload);
return mock;
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SignatureAlgorithmTest method setupMock.
private MockEndpoint setupMock(String payload) {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived(payload);
return mock;
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SignatureAlgorithmTest method doSignatureRouteTest.
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(builder);
context.start();
MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
mock.setExpectedMessageCount(1);
ProducerTemplate template = context.createProducerTemplate();
if (e != null) {
template.send("direct:in", e);
} else {
template.sendBodyAndHeaders("direct:in", payload, headers);
}
assertMockEndpointsSatisfied();
return mock.getReceivedExchanges().get(0);
} finally {
context.stop();
}
}
Aggregations