use of org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder in project mule by mulesoft.
the class MuleContextLifecycleTestCase method disposeOnStopped.
@Test
public void disposeOnStopped() throws Exception {
ctx.initialise();
new DefaultsConfigurationBuilder().configure(ctx);
ctx.start();
ctx.stop();
ctx.dispose();
assertFalse(ctx.isInitialised());
assertFalse(ctx.isInitialising());
assertFalse(ctx.isStarted());
assertTrue(ctx.isDisposed());
assertFalse(ctx.isDisposing());
assertLifecycleManagerDidApplyAllPhases();
}
use of org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder 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());
}
use of org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder in project mule by mulesoft.
the class MuleContextLifecycleTestCase method disposeOnStarted.
@Test
public void disposeOnStarted() throws Exception {
ctx.initialise();
assertTrue("onInitialization never called on listener", callbackListener.wasInitialized);
new DefaultsConfigurationBuilder().configure(ctx);
final TestNotificationListener notificationListener = new TestNotificationListener();
notificationListenerRegistry.registerListener(notificationListener);
ctx.start();
assertTrue("onStart never called on listener", callbackListener.wasStarted);
ctx.dispose();
assertFalse(ctx.isInitialised());
assertFalse(ctx.isInitialising());
assertFalse(ctx.isStarted());
assertTrue(ctx.isDisposed());
assertFalse(ctx.isDisposing());
// disposing started must go through stop
assertLifecycleManagerDidApplyAllPhases();
assertTrue("CONTEXT_STOPPING notification never fired", notificationListener.stoppingNotificationFired.get());
assertTrue("CONTEXT_STOPPED notification never fired", notificationListener.stoppedNotificationFired.get());
assertTrue("onStop never called on listener", callbackListener.wasStopped);
}
use of org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder in project mule by mulesoft.
the class MuleContextLifecycleTestCase method initialiseOnDisposed.
@Test(expected = IllegalStateException.class)
public void initialiseOnDisposed() throws Exception {
ctx.initialise();
new DefaultsConfigurationBuilder().configure(ctx);
ctx.start();
ctx.stop();
ctx.dispose();
// Attempt to initialise once disposed should fail!
ctx.initialise();
}
use of org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder in project mule by mulesoft.
the class MuleContextLifecycleTestCase method startOnInitialised.
@Test
public void startOnInitialised() throws Exception {
ctx.initialise();
new DefaultsConfigurationBuilder().configure(ctx);
TestNotificationListener notificationListener = new TestNotificationListener();
notificationListenerRegistry.registerListener(notificationListener);
ctx.start();
assertTrue(ctx.isInitialised());
assertFalse(ctx.isInitialising());
assertTrue(ctx.isStarted());
assertFalse(ctx.isDisposed());
assertFalse(ctx.isDisposing());
assertTrue("CONTEXT_STARTING notification never fired", notificationListener.startingNotificationFired);
assertTrue("CONTEXT_STARTED notification never fired", notificationListener.startedNotificationFired);
assertTrue("onInitialization never called on listener", callbackListener.wasInitialized);
assertTrue("onStart never called on listener", callbackListener.wasStarted);
}
Aggregations