use of org.apache.camel.util.StopWatch in project camel by apache.
the class MailDefaultDelayForMailConsumeTest method testConsuming.
@Test
public void testConsuming() throws Exception {
// clear mailbox
Mailbox.clearAll();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello London");
template.sendBody("smtp://bond@localhost", "Hello London");
// first poll should happen immediately
mock.setResultWaitTime(2000L);
mock.assertIsSatisfied();
mock.reset();
mock.expectedBodiesReceived("Hello Paris");
mock.setResultWaitTime(5000L + 2000L);
StopWatch watch = new StopWatch();
template.sendBody("smtp://bond@localhost", "Hello Paris");
// poll next mail and that is should be done within the default delay (overrule to 5 sec) + 2 sec slack
mock.assertIsSatisfied();
long delta = watch.stop();
assertTrue("Camel should not default poll the mailbox to often", delta > 5000 - 1000L);
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class CamelSpringRunnerPlainTest method testStopwatch.
@Test
public void testStopwatch() {
StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
assertNotNull(stopWatch);
assertTrue(stopWatch.taken() < 100);
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class SjmsBatchConsumerTest method testConsumption.
@Test
public void testConsumption() throws Exception {
final int messageCount = 10000;
final int consumerCount = 5;
final String queueName = getQueueName();
context.addRoutes(new TransactedSendHarness(queueName));
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
int completionTimeout = 1000;
int completionSize = 200;
fromF("sjms-batch:%s?completionTimeout=%s&completionSize=%s&consumerCount=%s&aggregationStrategy=#testStrategy", queueName, completionTimeout, completionSize, consumerCount).routeId("batchConsumer").startupOrder(10).autoStartup(false).split(body()).to("mock:split");
}
});
context.start();
MockEndpoint mockBefore = getMockEndpoint("mock:before");
mockBefore.setExpectedMessageCount(messageCount);
MockEndpoint mockSplit = getMockEndpoint("mock:split");
mockSplit.setExpectedMessageCount(messageCount);
LOG.info("Sending messages");
template.sendBody("direct:in", generateStrings(messageCount));
LOG.info("Send complete");
StopWatch stopWatch = new StopWatch();
context.startRoute("batchConsumer");
assertMockEndpointsSatisfied();
long time = stopWatch.stop();
LOG.info("Processed {} messages in {} ms", messageCount, time);
LOG.info("Average throughput {} msg/s", (long) (messageCount / (time / 1000d)));
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class ProxyEsbPerformanceIntegrationTest method testProxy.
@Test
public void testProxy() throws Exception {
// warm up with 1.000 messages so that the JIT compiler kicks in
send("http://127.0.0.1:8192/service/DirectProxy", 1000);
StopWatch watch = new StopWatch();
send("http://127.0.0.1:8192/service/DirectProxy", count);
log.warn("Ran {} tests in {}ms", count, watch.taken());
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class SoapHbrEsbPerformanceIntegrationTest method testSoapHbr.
@Test
public void testSoapHbr() throws Exception {
// warm up with 1.000 messages so that the JIT compiler kicks in
send("http://127.0.0.1:8192/service/CBRSOAPHeaderProxy", 1000);
StopWatch watch = new StopWatch();
send("http://127.0.0.1:8192/service/CBRSOAPHeaderProxy", count);
log.warn("Ran {} tests in {}ms", count, watch.taken());
}
Aggregations