use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class StringDataFormatTest method testUnMarshalString.
public void testUnMarshalString() throws Exception {
// include a UTF-8 char in the text จ is a Thai elephant
byte[] body = "Hello Thai Elephant จ".getBytes();
MockEndpoint mock = getMockEndpoint("mock:unmarshal");
mock.expectedMessageCount(1);
String out = (String) template.requestBody("direct:unmarshal", body);
assertMockEndpointsSatisfied();
assertEquals(new String(body, "UTF-8"), out);
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class JdbcSpringAggregateTest method testJdbcAggregate.
@Test
public void testJdbcAggregate() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:aggregated");
mock.expectedBodiesReceived("ABCDE");
template.sendBodyAndHeader("direct:start", "A", "id", 123);
template.sendBodyAndHeader("direct:start", "B", "id", 123);
template.sendBodyAndHeader("direct:start", "C", "id", 123);
template.sendBodyAndHeader("direct:start", "D", "id", 123);
template.sendBodyAndHeader("direct:start", "E", "id", 123);
assertMockEndpointsSatisfied(30, TimeUnit.SECONDS);
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ScanStreamDelayTest method testScanFile.
@Test
public void testScanFile() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(6);
assertMockEndpointsSatisfied(1, TimeUnit.SECONDS);
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class JdbcAggregateConcurrentSameGroupTest method doSendMessages.
private void doSendMessages(int files, int poolSize) throws Exception {
MockEndpoint mock = getMockEndpoint("mock:aggregated");
mock.setResultWaitTime(30 * 1000L);
mock.expectedMessageCount(1);
ExecutorService executor = Executors.newFixedThreadPool(poolSize);
for (int i = 0; i < files; i++) {
final int index = i;
executor.submit(new Callable<Object>() {
public Object call() throws Exception {
template.sendBodyAndHeader("direct:start", index, "id", 123);
// simulate a little delay
Thread.sleep(3);
return null;
}
});
}
assertMockEndpointsSatisfied();
executor.shutdownNow();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class JdbcAggregateLoadAndRecoverTest method testLoadAndRecoverJdbcAggregate.
@Test
public void testLoadAndRecoverJdbcAggregate() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(SIZE / 10);
mock.setResultWaitTime(50 * 1000);
LOG.info("Staring to send " + SIZE + " messages.");
for (int i = 0; i < SIZE; i++) {
final int value = 1;
char id = 'A';
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("id", id);
headers.put("seq", i);
LOG.debug("Sending {} with id {}", value, id);
template.sendBodyAndHeaders("seda:start?size=" + SIZE, value, headers);
// simulate a little delay
Thread.sleep(3);
}
LOG.info("Sending all " + SIZE + " message done. Now waiting for aggregation to complete.");
assertMockEndpointsSatisfied();
int recovered = 0;
for (Exchange exchange : mock.getReceivedExchanges()) {
if (exchange.getIn().getHeader(Exchange.REDELIVERED) != null) {
recovered++;
}
}
int expected = SIZE / 10 / 10;
assertEquals("There should be " + expected + " recovered", expected, recovered);
}
Aggregations