Search in sources :

Example 1 with MuleContextLifecycleManager

use of org.mule.runtime.core.internal.lifecycle.MuleContextLifecycleManager in project mule by mulesoft.

the class DefaultMuleContextTestCase method callDisposeIfInitFails.

@Test
public void callDisposeIfInitFails() throws Exception {
    ServerNotificationManager mockNotificationManager = mock(ServerNotificationManager.class);
    doThrow(MuleRuntimeException.class).when(mockNotificationManager).initialise();
    DefaultMuleContextBuilder muleContextBuilder = new DefaultMuleContextBuilder(APP);
    muleContextBuilder.setLifecycleManager(new MuleContextLifecycleManager());
    muleContextBuilder.setNotificationManager(mockNotificationManager);
    DefaultMuleContext defaultMuleContext = (DefaultMuleContext) muleContextBuilder.buildMuleContext();
    try {
        defaultMuleContext.initialise();
        fail("exception expected");
    } catch (Exception e) {
        verify(mockNotificationManager).dispose();
    }
}
Also used : MuleContextLifecycleManager(org.mule.runtime.core.internal.lifecycle.MuleContextLifecycleManager) ServerNotificationManager(org.mule.runtime.core.api.context.notification.ServerNotificationManager) MuleException(org.mule.runtime.api.exception.MuleException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 MuleException (org.mule.runtime.api.exception.MuleException)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 ServerNotificationManager (org.mule.runtime.core.api.context.notification.ServerNotificationManager)1 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)1 MuleContextLifecycleManager (org.mule.runtime.core.internal.lifecycle.MuleContextLifecycleManager)1