Search in sources :

Example 26 with StopWatch

use of org.apache.camel.util.StopWatch in project camel by apache.

the class JmsRequestReplyExclusiveReplyToTest method testJmsRequestReplyExclusiveFixedReplyTo.

@Test
public void testJmsRequestReplyExclusiveFixedReplyTo() throws Exception {
    StopWatch watch = new StopWatch();
    assertEquals("Hello A", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "A"));
    assertEquals("Hello B", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "B"));
    assertEquals("Hello C", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "C"));
    assertEquals("Hello D", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "D"));
    assertEquals("Hello E", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Exclusive", "E"));
    long delta = watch.stop();
    assertTrue("Should be faster than about 4 seconds, was: " + delta, delta < 4200);
}
Also used : StopWatch(org.apache.camel.util.StopWatch) Test(org.junit.Test)

Example 27 with StopWatch

use of org.apache.camel.util.StopWatch in project camel by apache.

the class AsyncJmsInOutTest method testAsyncJmsInOut.

@Test
public void testAsyncJmsInOut() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(100);
    mock.expectsNoDuplicates(body());
    StopWatch watch = new StopWatch();
    for (int i = 0; i < 100; i++) {
        template.sendBody("seda:start", "" + i);
    }
    // just in case we run on slow boxes
    assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
    log.info("Took " + watch.stop() + " ms. to process 100 messages request/reply over JMS");
}
Also used : 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 28 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 29 with StopWatch

use of org.apache.camel.util.StopWatch in project camel by apache.

the class ConnectionResourceIT method testConnectionResourceRouter.

@Test
public void testConnectionResourceRouter() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(100);
    mock.expectsNoDuplicates(body());
    StopWatch watch = new StopWatch();
    for (int i = 0; i < 100; i++) {
        template.sendBody("seda:start", "" + i);
    }
    // just in case we run on slow boxes
    assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
    log.info("Took " + watch.stop() + " ms. to process 100 messages request/reply over JMS");
}
Also used : 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 30 with StopWatch

use of org.apache.camel.util.StopWatch in project camel by apache.

the class SyncJmsInOutTempDestIT method testSynchronous.

@Test
public void testSynchronous() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(100);
    mock.expectsNoDuplicates(body());
    StopWatch watch = new StopWatch();
    for (int i = 0; i < 100; i++) {
        template.sendBody("seda:start", "" + i);
    }
    // just in case we run on slow boxes
    assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
    log.info("Took " + watch.stop() + " ms. to process 100 messages request/reply over JMS");
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) 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