Search in sources :

Example 46 with StopWatch

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;
}
Also used : HashMap(java.util.HashMap) StopWatch(org.apache.camel.util.StopWatch)

Example 47 with StopWatch

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();
    }
}
Also used : Logger(org.slf4j.Logger) StopWatch(org.apache.camel.util.StopWatch)

Example 48 with StopWatch

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);
}
Also used : StopWatch(org.apache.camel.util.StopWatch)

Example 49 with 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);
}
Also used : StopWatch(org.apache.camel.util.StopWatch) Test(org.junit.Test)

Example 50 with StopWatch

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);
}
Also used : StopWatch(org.apache.camel.util.StopWatch) Test(org.testng.annotations.Test)

Aggregations

StopWatch (org.apache.camel.util.StopWatch)101 Test (org.junit.Test)40 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)14 CamelExecutionException (org.apache.camel.CamelExecutionException)10 Exchange (org.apache.camel.Exchange)8 CamelExchangeException (org.apache.camel.CamelExchangeException)6 File (java.io.File)5 ExecutorService (java.util.concurrent.ExecutorService)5 AsyncProcessor (org.apache.camel.AsyncProcessor)5 Producer (org.apache.camel.Producer)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Future (java.util.concurrent.Future)4 AsyncCallback (org.apache.camel.AsyncCallback)4 Endpoint (org.apache.camel.Endpoint)4 ExchangeTimedOutException (org.apache.camel.ExchangeTimedOutException)4 NotifyBuilder (org.apache.camel.builder.NotifyBuilder)4 Date (java.util.Date)3 GenericFile (org.apache.camel.component.file.GenericFile)3