use of org.apache.camel.util.StopWatch in project camel by apache.
the class FailoverLoadBalancerBreakoutDuringShutdownTest method testFailover.
public void testFailover() throws Exception {
getMockEndpoint("mock:before").expectedMessageCount(1);
getMockEndpoint("mock:after").expectedMessageCount(0);
template.sendBody("seda:start", "Hello World");
assertMockEndpointsSatisfied();
// use a stop watch to time how long it takes to force the shutdown
StopWatch watch = new StopWatch();
// force quicker shutdown
context.getShutdownStrategy().setTimeout(1);
context.stop();
// should take less than 5 seconds
assertTrue("Should take less than 5 seconds, was " + watch.taken(), watch.stop() < 5000);
}
use of org.apache.camel.util.StopWatch 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.util.StopWatch in project camel by apache.
the class PropertyEditorTypeConverterIssueTest method testPropertyEditorTypeConverter.
public void testPropertyEditorTypeConverter() throws Exception {
// test that converters a custom object (MyBean) to a String which causes
// PropertyEditorTypeConverter to be used. And this test times how fast
// this is. As we want to optimize PropertyEditorTypeConverter to be faster
MyBean bean = new MyBean();
bean.setBar("Hello");
StopWatch watch = new StopWatch();
for (int i = 0; i < 500; i++) {
String s = context.getTypeConverter().convertTo(String.class, bean);
log.debug(s);
assertNotNull(s);
}
log.info("Time taken: " + watch.stop());
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class TypeConverterRegistryPerformanceTest method disbledtestPerformance.
public void disbledtestPerformance() throws Exception {
// force converter to be loaded on startup
Document dom = context.getTypeConverter().convertTo(Document.class, "<hello>World</hello>");
assertNotNull(dom);
StopWatch watch = new StopWatch();
latch = new CountDownLatch(size);
executorService = Executors.newFixedThreadPool(pool);
for (int i = 0; i < size; i++) {
executorService.submit(new Runnable() {
@Override
public void run() {
for (int j = 0; j < inner; j++) {
Document dom = context.getTypeConverter().convertTo(Document.class, "<hello>World</hello>");
assertNotNull(dom);
}
latch.countDown();
}
});
}
assertTrue("Should all work", latch.await(2, TimeUnit.MINUTES));
log.info("Took " + watch.taken());
executorService.shutdownNow();
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class MockEndpoint method waitForCompleteLatch.
protected void waitForCompleteLatch() throws InterruptedException {
if (latch == null) {
fail("Should have a latch!");
}
StopWatch watch = new StopWatch();
waitForCompleteLatch(resultWaitTime);
long delta = watch.stop();
LOG.debug("Took {} millis to complete latch", delta);
if (resultMinimumWaitTime > 0 && delta < resultMinimumWaitTime) {
fail("Expected minimum " + resultMinimumWaitTime + " millis waiting on the result, but was faster with " + delta + " millis.");
}
}
Aggregations