use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ElSqlConsumerDeleteTest method testConsume.
@Test
public void testConsume() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(3);
assertMockEndpointsSatisfied();
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(3, exchanges.size());
assertEquals(1, exchanges.get(0).getIn().getBody(Map.class).get("ID"));
assertEquals("Camel", exchanges.get(0).getIn().getBody(Map.class).get("PROJECT"));
assertEquals(2, exchanges.get(1).getIn().getBody(Map.class).get("ID"));
assertEquals("AMQ", exchanges.get(1).getIn().getBody(Map.class).get("PROJECT"));
assertEquals(3, exchanges.get(2).getIn().getBody(Map.class).get("ID"));
assertEquals("Linux", exchanges.get(2).getIn().getBody(Map.class).get("PROJECT"));
// some servers may be a bit slow for this
for (int i = 0; i < 5; i++) {
// give it a little tine to delete
Thread.sleep(1000);
int rows = jdbcTemplate.queryForObject("select count(*) from projects", Integer.class);
if (rows == 0) {
break;
}
}
assertEquals("Should have deleted all 3 rows", new Integer(0), jdbcTemplate.queryForObject("select count(*) from projects", Integer.class));
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ElSqlProducerBatchTest method testBatchMode.
@Test
public void testBatchMode() throws InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.message(0).header(SqlConstants.SQL_UPDATE_COUNT).isEqualTo(1);
Map<String, Object> batchParams = new HashMap<>();
batchParams.put("id", "4");
batchParams.put("license", "GNU");
batchParams.put("project", "Batch");
template.sendBody("direct:batch", batchParams);
mock.assertIsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ElSqlProducerStreamListTest method testSplitWithModel.
@Test
public void testSplitWithModel() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(3);
template.sendBody("direct:withSplitModel", "testmsg");
mock.assertIsSatisfied();
assertThat(resultBodyAt(mock, 0), instanceOf(Project.class));
assertThat(resultBodyAt(mock, 1), instanceOf(Project.class));
assertThat(resultBodyAt(mock, 2), instanceOf(Project.class));
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class DropboxProducerGetSingleTest method testCamelDropbox.
@Test
public void testCamelDropbox() throws Exception {
template.send("direct:start", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader("test", "test");
}
});
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
assertMockEndpointsSatisfied();
List<Exchange> exchanges = mock.getReceivedExchanges();
Exchange exchange = exchanges.get(0);
Object header = exchange.getIn().getHeader(DropboxResultHeader.DOWNLOADED_FILE.name());
Object body = exchange.getIn().getBody();
assertNotNull(header);
assertNotNull(body);
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class DropboxProducerPutSingleFileTest method testCamelDropbox.
@Test
public void testCamelDropbox() throws Exception {
template.send("direct:start", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader("test", "test");
}
});
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
assertMockEndpointsSatisfied();
List<Exchange> exchanges = mock.getReceivedExchanges();
Exchange exchange = exchanges.get(0);
Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name());
Object body = exchange.getIn().getBody();
assertNotNull(header);
assertNotNull(body);
}
Aggregations