use of org.apache.camel.util.StopWatch in project camel by apache.
the class ProducerCacheHitsTest method runTest.
protected Object runTest(String uri, String body, int iterations, int threads) {
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(PerformanceTestComponent.HEADER_ITERATIONS, iterations);
headers.put(PerformanceTestComponent.HEADER_THREADS, threads);
StopWatch watch = new StopWatch();
Object result = template.requestBodyAndHeaders(uri, body, headers);
template.sendBody("mock:results", new TestResult(uri, iterations, threads, watch.stop()));
return result;
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class StopWatchTestExecutionListener method afterTestMethod.
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
StopWatch watch = threadStopWatch.get();
if (watch != null) {
long time = watch.stop();
Logger log = LoggerFactory.getLogger(testContext.getTestClass());
log.info("********************************************************************************");
log.info("Testing done: " + testContext.getTestMethod().getName() + "(" + testContext.getTestClass().getName() + ")");
log.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");
log.info("********************************************************************************");
threadStopWatch.remove();
}
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class StopWatchTestExecutionListener method beforeTestMethod.
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
StopWatch stopWatch = new StopWatch();
threadStopWatch.set(stopWatch);
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class CamelSpringRunnerUseAdviceWithTest method testStopwatch.
@Test
public void testStopwatch() {
StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
assertNotNull(stopWatch);
long taken = stopWatch.taken();
assertTrue(taken + " > 0, but was: " + taken, taken > 0);
assertTrue(taken + " < 3000, but was: " + taken, taken < 3000);
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class AbstractCamelTestNGSpringContextTestsPlainTest method testStopwatch.
@Test
public void testStopwatch() {
StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
// some servers is slower
assertNotNull(stopWatch);
assertTrue(stopWatch.taken() < 1000);
}
Aggregations