use of org.apache.camel.dsl.yaml.deserializers.CustomResolver in project camel-k-runtime by apache.
the class CronTest method testCronTimerActivation.
@ParameterizedTest
@MethodSource("parameters")
public void testCronTimerActivation(String code, String cronOverride) throws Exception {
final Runtime runtime = Runtime.on(new DefaultCamelContext());
runtime.getRegistry().bind("__camel_k_resolver", new CustomResolver());
final YamlRoutesBuilderLoader loader = new YamlRoutesBuilderLoader();
loader.setCamelContext(runtime.getCamelContext());
loader.start();
final CronSourceLoaderInterceptor interceptor = new CronSourceLoaderInterceptor();
interceptor.setRuntime(runtime);
interceptor.setOverridableComponents(cronOverride);
final RouteBuilder builder = (RouteBuilder) loader.loadRoutesBuilder(ResourceHelper.fromBytes("my-cron.yaml", code.getBytes(StandardCharsets.UTF_8)));
builder.addLifecycleInterceptor(interceptor);
runtime.getCamelContext().addRoutes(builder);
CountDownLatch termination = new CountDownLatch(1);
runtime.getCamelContext().addLifecycleStrategy(new LifecycleStrategySupport() {
@Override
public void onContextStopped(CamelContext context) {
termination.countDown();
}
});
MockEndpoint mock = runtime.getCamelContext().getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
mock.setResultWaitTime(10000);
runtime.getCamelContext().start();
mock.assertIsSatisfied();
termination.await(10, TimeUnit.SECONDS);
assertThat(termination.getCount()).isZero();
}
Aggregations