Search in sources :

Example 41 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class SedaNoConsumerTest method testInOnly.

public void testInOnly() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("seda:foo?timeout=1000");
        }
    });
    context.start();
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
    // no problem for in only as we do not expect a reply
    template.sendBody("direct:start", "Hello World");
    notify.matches(2, TimeUnit.SECONDS);
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) RouteBuilder(org.apache.camel.builder.RouteBuilder) ExchangeTimedOutException(org.apache.camel.ExchangeTimedOutException) CamelExecutionException(org.apache.camel.CamelExecutionException)

Example 42 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class NotifyBuilderOnFailureShutdownCamelIssueTest method testIssue.

public void testIssue() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
    assertTrue(notify.matchesMockWaitTime());
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder)

Example 43 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class RetryRouteScopedUntilRecipientListIssueTest method testRetryUntilRecipientNotFailAndFail.

public void testRetryUntilRecipientNotFailAndFail() throws Exception {
    invoked.set(0);
    NotifyBuilder event = event().whenDone(1).create();
    getMockEndpoint("mock:result").expectedMessageCount(0);
    getMockEndpoint("mock:foo").expectedMinimumMessageCount(0);
    template.sendBodyAndHeader("seda:start", "Hello World", "recipientListHeader", "not-fail,fail");
    assertMockEndpointsSatisfied();
    // wait until its done before we stop and check that retry was invoked
    boolean matches = event.matches(10, TimeUnit.SECONDS);
    assertTrue(matches);
    context.stop();
    assertEquals(3, invoked.get());
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder)

Example 44 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class SamplingThrottlerTest method testBurstySampling.

public void testBurstySampling() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(2);
    mock.setResultWaitTime(3000);
    List<Exchange> sentExchanges = new ArrayList<Exchange>();
    // send a burst of 5 exchanges, expecting only one to get through
    sendExchangesThroughDroppingThrottler(sentExchanges, 5);
    // sleep through a complete period
    Thread.sleep(1100);
    // send another 5 now
    sendExchangesThroughDroppingThrottler(sentExchanges, 5);
    notify.matchesMockWaitTime();
    mock.assertIsSatisfied();
    validateDroppedExchanges(sentExchanges, mock.getReceivedCounter());
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList)

Example 45 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class SamplingThrottlerTest method testSamplingFromExchangeStream.

public void testSamplingFromExchangeStream() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(15).create();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(2);
    mock.setResultWaitTime(3000);
    List<Exchange> sentExchanges = new ArrayList<Exchange>();
    sendExchangesThroughDroppingThrottler(sentExchanges, 15);
    notify.matchesMockWaitTime();
    mock.assertIsSatisfied();
    validateDroppedExchanges(sentExchanges, mock.getReceivedCounter());
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList)

Aggregations

NotifyBuilder (org.apache.camel.builder.NotifyBuilder)109 Test (org.junit.Test)72 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)30 File (java.io.File)24 Exchange (org.apache.camel.Exchange)10 RouteBuilder (org.apache.camel.builder.RouteBuilder)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 HashSet (java.util.HashSet)4 MBeanServer (javax.management.MBeanServer)4 ObjectName (javax.management.ObjectName)4 Processor (org.apache.camel.Processor)4 StopWatch (org.apache.camel.util.StopWatch)4 ConnectException (java.net.ConnectException)3 ExecutorService (java.util.concurrent.ExecutorService)3 Ignore (org.junit.Ignore)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Future (java.util.concurrent.Future)2 ZipFile (java.util.zip.ZipFile)2