use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FileConsumerNoopTest method testNoop.
public void testNoop() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
assertMockEndpointsSatisfied();
notify.matchesMockWaitTime();
File file = new File("target/filenoop");
assertEquals("There should be 2 files", 2, file.list().length);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class SplitterParallelBigFileTest method xxxtestSplitParallelBigFile.
// disabled due manual test
public void xxxtestSplitParallelBigFile() throws Exception {
StopWatch watch = new StopWatch();
NotifyBuilder builder = new NotifyBuilder(context).whenDone(lines + 1).create();
boolean done = builder.matches(120, TimeUnit.SECONDS);
log.info("Took " + TimeUtils.printDuration(watch.stop()));
if (!done) {
throw new CamelException("Could not split file in 2 minutes");
}
// need a little sleep for capturing memory profiling
// Thread.sleep(60 * 1000);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class ThreadsRejectedExecutionTest method testThreadsRejectedAbortNoRedelivery.
public void testThreadsRejectedAbortNoRedelivery() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(Exception.class).maximumRedeliveries(3).handled(true).to("mock:error");
from("seda:start").to("log:before").threads(1, 1).maxPoolSize(1).maxQueueSize(2).rejectedPolicy(ThreadPoolRejectedPolicy.Abort).delay(1000).to("log:after").to("mock:result");
}
});
context.start();
NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
// there should be error handling for aborted tasks (eg no redeliveries and no error handling)
getMockEndpoint("mock:error").expectedMessageCount(0);
getMockEndpoint("mock:result").expectedMinimumMessageCount(2);
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 ThreadsRejectedExecutionTest method testThreadsRejectedDiscardOldest.
public void testThreadsRejectedDiscardOldest() 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.DiscardOldest).delay(1000).to("log:after").to("mock:result");
}
});
context.start();
NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
getMockEndpoint("mock:result").expectedMinimumMessageCount(2);
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 ThreadsRejectedExecutionTest method testThreadsRejectedAbort.
public void testThreadsRejectedAbort() 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.Abort).delay(1000).to("log:after").to("mock:result");
}
});
context.start();
NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
getMockEndpoint("mock:result").expectedMinimumMessageCount(2);
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);
}
Aggregations