use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class SqsConcurrentConsumerTest method consumeMessagesFromQueue.
@Test
public void consumeMessagesFromQueue() throws Exception {
// simple test to make sure that concurrent consumers were used in the test
NotifyBuilder notifier = new NotifyBuilder(context).whenCompleted(NUM_MESSAGES).create();
assertTrue("We didn't process " + NUM_MESSAGES + " messages as we expected!", notifier.matches(5, TimeUnit.SECONDS));
if (isPlatform("windows")) {
// threading is different on windows
} else {
// usually we use all threads evenly but sometimes threads are reused so just test that 50%+ was used
if (threadNumbers.size() < (NUM_CONCURRENT / 2)) {
fail(String.format("We were expecting to have about half of %d numbers of concurrent consumers, but only found %d", NUM_CONCURRENT, threadNumbers.size()));
}
}
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class ThreadsRejectedExecutionTest method testThreadsRejectedCallerRuns.
public void testThreadsRejectedCallerRuns() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("seda:start").to("log:before").threads(1, 1).maxPoolSize(1).maxQueueSize(2).rejectedPolicy(ThreadPoolRejectedPolicy.CallerRuns).delay(200).to("log:after").to("mock:result");
}
});
context.start();
NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
getMockEndpoint("mock:result").expectedMessageCount(10);
for (int i = 0; i < 10; i++) {
template.sendBody("seda:start", "Message " + i);
}
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
int inflight = context.getInflightRepository().size();
assertEquals(0, inflight);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FlexibleAggregationStrategiesTest method testLinkedList.
@Test
public void testLinkedList() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).and().whenExactlyFailed(0).create();
template.sendBody("direct:linkedlist", Arrays.asList("FIRST", "SECOND"));
assertTrue(notify.matches(10, TimeUnit.SECONDS));
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FlexibleAggregationStrategiesTest method testHashSet.
@Test
public void testHashSet() throws Exception {
HashSet<String> r = new HashSet<>();
r.add("FIRST");
r.add("SECOND");
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).and().whenExactlyFailed(0).create();
Set result = template.requestBody("direct:hashset", Arrays.asList("FIRST", "SECOND"), Set.class);
assertTrue(notify.matches(10, TimeUnit.SECONDS));
assertEquals(r, result);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class CacheProducerTest method testAddingDataToCacheWithNonStringCacheKey.
@Test
public void testAddingDataToCacheWithNonStringCacheKey() throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:a").setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_ADD)).setHeader(CacheConstants.CACHE_KEY, constant(10L)).to("cache://TestCache1");
}
});
context.start();
NotifyBuilder notify = new NotifyBuilder(context).whenExactlyDone(1).create();
log.debug("------------Beginning CacheProducer Add Test---------------");
sendOriginalFile();
notify.matches(10, TimeUnit.SECONDS);
assertNotNull(fetchElement("10"));
}
Aggregations