use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class TokenPairIteratorSplitChoicePerformanceTest method xxxtestTokenPairPerformanceRoute.
public void xxxtestTokenPairPerformanceRoute() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(size).create();
boolean matches = notify.matches(5, TimeUnit.MINUTES);
log.info("Processed file with " + size + " elements in: " + TimeUtils.printDuration(watch.stop()));
log.info("Processed " + tiny.get() + " tiny messages");
log.info("Processed " + small.get() + " small messages");
log.info("Processed " + med.get() + " medium messages");
log.info("Processed " + large.get() + " large messages");
assertEquals((size / 10) * 4, tiny.get());
assertEquals((size / 10) * 2, small.get());
assertEquals((size / 10) * 3, med.get());
assertEquals((size / 10) * 1, large.get());
assertTrue("Should complete route", matches);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class ManagedThrottlerTest method testThrottleAsyncExceptionVisableViaJmx.
public void testThrottleAsyncExceptionVisableViaJmx() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
if (isPlatform("windows")) {
// windows needs more sleep to read updated jmx values so we skip as we dont want further delays in core tests
return;
}
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName throttlerName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mythrottler4\"");
// use route to get the total time
ObjectName routeName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=routes,name=\"route4\"");
// reset the counters
mbeanServer.invoke(routeName, "reset", null, null);
getMockEndpoint("mock:endAsyncException").expectedMessageCount(10);
NotifyBuilder notifier = new NotifyBuilder(context).from("seda:throttleCountAsyncException").whenReceived(5).create();
for (int i = 0; i < 10; i++) {
template.sendBody("seda:throttleCountAsyncException", "Message " + i);
}
assertTrue(notifier.matches(2, TimeUnit.SECONDS));
assertMockEndpointsSatisfied();
// give a sec for exception handling to finish..
Thread.sleep(500);
// since all exchanges ended w/ exception, they are not completed
Long completed = (Long) mbeanServer.getAttribute(routeName, "ExchangesCompleted");
assertEquals(0, completed.longValue());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class ManagedThrottlerTest method testThrottleVisableViaJmx.
public void testThrottleVisableViaJmx() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
if (isPlatform("windows")) {
// windows needs more sleep to read updated jmx values so we skip as we dont want further delays in core tests
return;
}
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName throttlerName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mythrottler2\"");
// use route to get the total time
ObjectName routeName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=routes,name=\"route2\"");
// reset the counters
mbeanServer.invoke(routeName, "reset", null, null);
getMockEndpoint("mock:end").expectedMessageCount(10);
NotifyBuilder notifier = new NotifyBuilder(context).from("seda:throttleCount").whenReceived(5).create();
for (int i = 0; i < 10; i++) {
template.sendBody("seda:throttleCount", "Message " + i);
}
assertTrue(notifier.matches(2, TimeUnit.SECONDS));
assertMockEndpointsSatisfied();
Long completed = (Long) mbeanServer.getAttribute(routeName, "ExchangesCompleted");
assertEquals(10, completed.longValue());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class ApplicationTest method newOrderTest.
@Test
public void newOrderTest() {
// Wait for maximum 5s until the first order gets inserted and processed
NotifyBuilder notify = new NotifyBuilder(camelContext).fromRoute("generate-order").whenDone(1).and().fromRoute("process-order").whenDone(1).create();
assertThat(notify.matches(5, TimeUnit.SECONDS)).isTrue();
// Then call the REST API
ResponseEntity<Order> response = restTemplate.getForEntity("/camel-rest-jpa/books/order/1", Order.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
Order order = response.getBody();
assertThat(order.getId()).isEqualTo(1);
assertThat(order.getAmount()).isBetween(1, 10);
assertThat(order.getBook().getItem()).isIn("Camel", "ActiveMQ");
assertThat(order.getBook().getDescription()).isIn("Camel in Action", "ActiveMQ in Action");
assertThat(order.isProcessed()).isTrue();
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class ZipFileDataFormatTest method testZipToFileWithFileName.
@Test
public void testZipToFileWithFileName() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
MockEndpoint mock = getMockEndpoint("mock:zipToFile");
mock.expectedMessageCount(1);
File file = new File(TEST_DIR, "poem.txt.zip");
assertFalse("The zip should not exit.", file.exists());
template.sendBodyAndHeader("direct:zipToFile", TEXT, FILE_NAME, "poem.txt");
// just make sure the file is created
mock.assertIsSatisfied();
// use builder to ensure the exchange is fully done before we check for file exists
assertTrue("The exchange is not done in time.", notify.matches(5, TimeUnit.SECONDS));
assertTrue("The file should exist.", file.exists());
assertArrayEquals("Get a wrong message content.", getZippedText("poem.txt"), getBytes(file));
}
Aggregations