use of org.mule.runtime.core.api.context.notification.MuleContextNotificationListener in project mule by mulesoft.
the class AbstractMuleContextTestCase method startMuleContext.
private void startMuleContext() throws MuleException, InterruptedException {
final AtomicReference<Latch> contextStartedLatch = new AtomicReference<>();
contextStartedLatch.set(new Latch());
// Do not inline it, otherwise the type of the listener is lost
final MuleContextNotificationListener<MuleContextNotification> listener = new MuleContextNotificationListener<MuleContextNotification>() {
@Override
public boolean isBlocking() {
return false;
}
@Override
public void onNotification(MuleContextNotification notification) {
contextStartedLatch.get().countDown();
}
};
muleContext.getNotificationManager().addListener(listener);
muleContext.start();
contextStartedLatch.get().await(20, SECONDS);
}
use of org.mule.runtime.core.api.context.notification.MuleContextNotificationListener in project mule by mulesoft.
the class MuleContextLifecycleTestCase method notificationHasMuleContextRef.
@Test
public void notificationHasMuleContextRef() throws Exception {
ctx.initialise();
new DefaultsConfigurationBuilder().configure(ctx);
final AtomicReference<MuleContext> contextFromNotification = new AtomicReference<>();
final AtomicReference<String> resourceId = new AtomicReference<>();
MuleContextNotificationListener<MuleContextNotification> listener = notification -> {
contextFromNotification.set(notification.getMuleContext());
resourceId.set(notification.getResourceIdentifier());
};
notificationListenerRegistry.registerListener(listener);
ctx.start();
assertNotNull(contextFromNotification.get());
assertSame(ctx, contextFromNotification.get());
assertEquals(ctx.getConfiguration().getId(), resourceId.get());
}
Aggregations