use of org.apache.camel.util.StopWatch in project camel by apache.
the class TimerDrivenTimePatternConverterTest method testTimerUsingStopWatch.
public void testTimerUsingStopWatch() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(2);
StopWatch watch = new StopWatch();
assertMockEndpointsSatisfied();
long interval = watch.stop();
LOG.trace("Should take approx 2000 milliseconds, was: {}", interval);
assertTrue("Should take approx 2000 milliseconds, was: " + interval, interval >= 1700);
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class PrimitiveTypeConverterIssueTest method testPrimitiveTypeConverter.
public void testPrimitiveTypeConverter() throws Exception {
StopWatch watch = new StopWatch();
for (int i = 0; i < 10000; i++) {
int num = context.getTypeConverter().convertTo(int.class, "123");
assertEquals(123, num);
}
log.info("Time taken: " + watch.stop());
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class SplitterParallelAggregateTest method timeSplitRoutes.
protected void timeSplitRoutes(int numberOfRequests) throws Exception {
String[] endpoints = new String[] { "direct:splitSynchronizedAggregation", "direct:splitUnsynchronizedAggregation" };
List<Future<File>> futures = new ArrayList<Future<File>>();
StopWatch stopWatch = new StopWatch(false);
for (String endpoint : endpoints) {
stopWatch.restart();
for (int requestIndex = 0; requestIndex < numberOfRequests; requestIndex++) {
futures.add(template.asyncRequestBody(endpoint, null, File.class));
}
for (int i = 0; i < futures.size(); i++) {
Future<File> future = futures.get(i);
future.get();
}
stopWatch.stop();
log.info(String.format("test%d.%s=%d\n", numberOfRequests, endpoint, stopWatch.taken()));
}
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class JettyAsyncDefaultContinuationTimeoutTest method testJettyAsyncTimeout.
@Test
public void testJettyAsyncTimeout() throws Exception {
getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
StopWatch watch = new StopWatch();
try {
template.requestBody("http://localhost:{{port}}/myservice", null, String.class);
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
log.info("Timeout hit and client got reply with failure status code");
long taken = watch.stop();
HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
assertEquals(504, cause.getStatusCode());
// should be approx 30-34 sec.
assertTrue("Timeout should occur faster than " + taken, taken < 34000);
}
assertMockEndpointsSatisfied(2, TimeUnit.MINUTES);
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class JmsRequestReplySharedReplyToTest method testJmsRequestReplySharedReplyTo.
@Test
public void testJmsRequestReplySharedReplyTo() throws Exception {
StopWatch watch = new StopWatch();
// shared is more slower than exclusive, due it need to use a JMS Message Selector
// and has a receiveTimeout of 1 sec per default, so it react slower to new messages
assertEquals("Hello A", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "A"));
assertEquals("Hello B", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "B"));
assertEquals("Hello C", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "C"));
assertEquals("Hello D", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "D"));
assertEquals("Hello E", template.requestBody("activemq:queue:foo?replyTo=bar&replyToType=Shared", "E"));
long delta = watch.stop();
assertTrue("Should be slower than about 2 seconds, was: " + delta, delta > 2000);
}
Aggregations