Search in sources :

Example 1 with StopWatch

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);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StopWatch(org.apache.camel.util.StopWatch) Test(org.junit.Test)

Example 2 with StopWatch

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);
}
Also used : StopWatch(org.apache.camel.util.StopWatch) Test(org.junit.Test)

Example 3 with StopWatch

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)));
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StopWatch(org.apache.camel.util.StopWatch) Test(org.junit.Test)

Example 4 with StopWatch

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());
}
Also used : StopWatch(org.apache.camel.util.StopWatch) Test(org.junit.Test)

Example 5 with StopWatch

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());
}
Also used : StopWatch(org.apache.camel.util.StopWatch) Test(org.junit.Test)

Aggregations

StopWatch (org.apache.camel.util.StopWatch)101 Test (org.junit.Test)40 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)14 CamelExecutionException (org.apache.camel.CamelExecutionException)10 Exchange (org.apache.camel.Exchange)8 CamelExchangeException (org.apache.camel.CamelExchangeException)6 File (java.io.File)5 ExecutorService (java.util.concurrent.ExecutorService)5 AsyncProcessor (org.apache.camel.AsyncProcessor)5 Producer (org.apache.camel.Producer)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Future (java.util.concurrent.Future)4 AsyncCallback (org.apache.camel.AsyncCallback)4 Endpoint (org.apache.camel.Endpoint)4 ExchangeTimedOutException (org.apache.camel.ExchangeTimedOutException)4 NotifyBuilder (org.apache.camel.builder.NotifyBuilder)4 Date (java.util.Date)3 GenericFile (org.apache.camel.component.file.GenericFile)3